PowerShell: Difference between revisions

From Dave-Wiki
Jump to navigation Jump to search
(Replaced content with "==Updating== # <code>winget search Microsoft.PowerShell</code> # <code>winget install --id Microsoft.PowerShell --source winget</code> ==Check Version== <code>$PSVersionTable.PSVersion</code>")
Tag: Replaced
 
Line 1: Line 1:
=General=
==Updating==
==Updating==


Line 9: Line 7:


<code>$PSVersionTable.PSVersion</code>
<code>$PSVersionTable.PSVersion</code>
=Network=
==Useful network information==
<code>net config workstation</code>
==Change a network interface to use dynamic DHCP to get its IP==
<code>netsh interface ip show config</code>
<code>netsh interface ip set address "Ethernet" dhcp</code>
==Reset a network interface==
<code>netsh int ip reset</code>
<code>netsh winsock reset</code>
==Release and renew an IP address==
<code>ipconfig /release & ipconfig /renew</code>
==Mount a Windows file share==
<code>net use \\path\to\shared\folder /user:<username></code>
==Allow Insecure Logons to an SMB Share==
Allows you to access Anonymous Linux SMB Shares
In gpedit.msc, enable:
<code>Computer Configuration\Administrative Templates\Network\Lanman Workstation\Enable insecure guest logons</code>
==Add a static route==
<code>route add -p <dest-network> MASK <dest-mask> <next-hop-ip> METRIC 0 IF <iface-num></code>
=Other=
==Text-to-speech==
<code>powershell Add-Type -AssemblyName System.speech; $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer; $speak.Speak('I am groot')</code>
=System Info=
==Get PC's serial number==
<code>wmic bios get serialnumber</code>
<code>wmic csproduct get vendor,name,identifyingnumber</code>
==Get Windows build number from an .iso file==
<code>dism /get-wiminfo /wimfile:g:\sources\install.wim</code>
Then, run it again with whichever index number you want to display:
<code>dism /get-wiminfo /wimfile:g:\sources\install.wim /index:3</code>
=Printers=
==List printers==
<code>wmic printer list brief</code>
=Group Policy / AD=
==List which GPO's are applied==
<code>rsop.msc</code> (GUI version)
<code>gpresult /r /scope computer</code> (CLI version)
or save it to an html file with /h:
<code>gpresult /h c:\gpresult.html</code>
=Disk / Filesystem=
==Format a disk==
<code>get-disk</code>
note the disk number, then:
<code>clear-disk -number 1 -removedata -removeoem</code> (removes data partitions and OEM partitions)
<code>new-partition -disknumber 1 -usemaximumsize</code>
<code>get-partition -disknumber 1 | set-partition -newdriveletter D</code>
=Certificates / SSL=
==Convert x.509 (PKCS#12) to PFX==
<code>openssl pkcs12 -export -out cert.pfx -inkey private.key -in cert.crt -certfile CACert.crt</code> (-certfile is not required)

Latest revision as of 21:59, 11 February 2024

Updating

  1. winget search Microsoft.PowerShell
  2. winget install --id Microsoft.PowerShell --source winget

Check Version

$PSVersionTable.PSVersion