Windows powershell commands
windows powershell
- computer checkpoint
- Create: Checkpoint-Computer -Description adhoc
- View: Get-ComputerRestorePoint
- find version
- PS C:> $PSVersionTable.PSVersion
- Basic Commands
- Get-Help (get-help get-process)
- Set-ExecutionPolicy (set-executionpolicy restricted)
- Get-ExecutionPolicy
- Get-Service (get-service | sort-object status | format-table)
- ConvertTo-HTML (Get-Service | ConvertTo-HTML -Property Name,Status > c:\tmp\services.html
- Export-CSV (Get-Service | Export-CSV c:\tmp\services.csv)
- Select-Object (Get-Service | Select-Object Name,Status | Export-CSV c:\tmp\services.csv
- Get-EventLog (Get-EventLog -Log “Application”)
- Get-Process
- Stop-Process (Stop-Process -Name notepad)(Stop-Process -ID 2668)
- Search-ADAccount -PasswordNeverExpires | FT Name, ObjectClass, UserPrincipalName
- Get-AdUser -Filter * -Properties OfficePhone | FT OfficePhone, UserPrincipalName
- Psdrive
- Running script (& “C:\MyScripts\Test.ps1”)
- system commands
- Automate with powershell the upload to backblaze
PS Z:\172.19.10.10\SVN_repositories> Get-Content .\dir_names.txt | ForEach-Object {
echo "Wait for start of sync of $_"
sleep 4
b2 sync --delete --compareVersions size $_ "b2://allRepositories/weeklyBackup/$_"
echo "$_ is done"
sleep 3
}
- powershell with Active Directory
- PS scripts to automate AD activity from ThePoShWolf.