-
- Check PowerShell versions installed:
$PSVersionTable.PSVersion
- Install PowerShell on Windows
- https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows?view=powershell-7.5
- List Available Versions:
winget search --id Microsoft.PowerShell
- Install by version name:
winget install --id Microsoft.PowerShell --source winget
- List Available Versions:
- https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows?view=powershell-7.5
- See Known Limitations:
- Check PowerShell versions installed:
- https://www.powershellgallery.com/
- "The central repository for sharing and acquiring PowerShell code including PowerShell modules, scripts, and DSC resources."
- https://docs.microsoft.com/en-us/powershell/gallery/overview
- https://docs.microsoft.com/en-us/powershell/gallery/getting-started
-
Windows Server 2019 & PowerShell All-in-One For Dummies, 1st Edition
-
Learn PowerShell Toolmaking in a Month of Lunches, 1st Edition
-
Windows PowerShell Pocket Reference: Portable Help for PowerShell Scripters, Second Edition
-
Windows PowerShell in 24 Hours, Sams Teach Yourself, 1st Edtion
-
Learn PowerShell Core 6.0: Automate and control administrative tasks using DevOps principle
-
Pro PowerShell for Amazon Web Services: DevOps for the AWS Cloud
-
2020 Books to look for...
-
What Version am I running?
$PSVersionTable.PSVersion
-
Add a firewall rule
netsh advfirewall firewall add rule name="docker engine" dir=in action=allow protocol=TCP localport=2375
-
Generate a GID
[guid]::newguid()
-
Get Hash
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-filehash?view=powershell-7.3
Get-FileHash- Algorithms supported: SHA1, SHA256, SHA384, SHA512, MD5
-
Get Serial Numbers:
wmic memorychip get serialnumberwmic diskdrive get serialnumberwmic baseboard get serialnumberwmic cdrom where drive='d:' get SerialNumber
-
Disable WiFi
netsh interface set interface name="Wireless Network Connection" admin=DISABLED
-
Hybernation
powercfg /hibernate onpowercfg /hibernate off
-
Explore a command...
<command> | Get-Member- Will return:
- Properties
- Methods
- AliasProperty
- Event
- ScriptMethod
- ...
- Examples:
get-localuser | Get-Member
- Also see:
Get-CommandGet-HelpGet-Member
- https://groupby.org/conference-session-abstracts/powershell-for-the-sql-dba/
Enable-PSRemotingSet ExecutionPolicy RemoteSignted -force- (...many other examples in the video...)
-
PowerShell script files end in ".ps1"
-
To pass parameters into a sccript:
- Define parameters on first line, such as:
Param([string]$clsid)
-
To execute a file, use the command line form of
.\{sciprt.ps1} -
Get BIOS info
Get-WmiObject win32_biosGet-WmiObject -Class Win32_BIOS | Format-List *- https://sumtips.com/snippets/powershell/get-bios-information-with-powershell-cmd/
-
"Start Using Constrained Language Mode"
- https://blog.danskingdom.com/allow-others-to-run-your-powershell-scripts-from-a-batch-file-they-will-love-you-for-it/
- https://stackoverflow.com/questions/19335004/how-to-run-a-powershell-script-from-a-batch-file
Powershell.exe -executionpolicy remotesigned -File ps.ps1-
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""C:\Users\SE\Desktop\ps.ps1""' -Verb RunAs}"- If you need to run as Admin
powershell.exe -ExecutionPolicy Bypass -Command "Path\xxx.ps1"- If you launch PowerShell as administrator...