Windows powershell commands


windows powershell

  1. computer checkpoint
    • Create: Checkpoint-Computer -Description adhoc
    • View: Get-ComputerRestorePoint
  2. find version
    • PS C:> $PSVersionTable.PSVersion
  3. 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”)
  4. 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
    }
  1. powershell with Active Directory