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