1. Start
    1. Enable Unsigned scripts execution
      1. set-executionpolicy Unrestricted
  2. Output
    1. Console
      1. Write-Host "Hello Line!"
      2. "Hello Line!"
      3. Write-Output "Hello Line!"
      4. Outputs Hello Line!
  3. Strings
    1. Interpolation
      1. $x = 10 "Hello $x!" ====== Out: Hello 10!
    2. @" This is Multiline string"@
  4. GUI
    1. BEST! - PowerGUI
  5. Date And Time
    1. (Get-Date).ToString() ========= 3/3/2014 21:41:38
      1. Get-Date
  6. Files
    1. Append file
      1. Out-File "C:\logfile.txt" -Append
    2. Path
      1. if (!(test-path $targetdir)) { md $targetdir }
      2. join-path System *ControlSet* -resolve
      3. Resolve-Path .
    3. Read
      1. $templateContent = Get-Content $viewFileName | Out-String
  7. Statements
    1. Loops
      1. for ($i = 3; $i -lt 100; $i++) { ... }
      2. Get-Service | ForEach {$_.Name}
    2. Functions
      1. function Hello ($a, $b, $c) { "Hello $a, $b, $c" } Hello "111" "10" "20"
        1. Parameters
          1. function Hello { ($a, $b, $c) = $args "Hello $a, $b, $c" } Hello "111" "10" "20"
          2. function Hello { param($a, $b, $c) "Hello $a, $b, $c" }
          3. Param ([int]$x = 0, [int]$y = 0)
          4. Call: Hello -b "B" -a "A" -c "CCCC"
          5. Return Value is Hello 111, 10, 20
  8. Filters
    1. Get-Service | ForEach {$_.Name}
    2. Get-Service | Where {$_.Status -eq "Running"}
  9. Services
    1. get-service lanmanserver | Foreach { start-service $_.name -passthru; start-service $_.DependentServices -passthru}
    2. restart-service spooler -PassThru
    3. Stop-Service -Name Spooler
    4. Start-Service -Name Spooler
  10. Process
    1. Get-Process
    2. Run External Programm
      1. How do I capture the output into a variable from an external process in Powershell?
        1. $OutputVariable = (Shell command) | Out-String
      2. With spaces in path
        1. Call operator: & ' comm and'
    3. Process - Output
      1. Out-String
        1. get-alias | out-string -stream | select-string "Get-"
      2. As Array
    4. Wait Process finished
      1. $proc = Start-Process (MsiExec.exe /qn /x$guild /log "$logname") -PassThru; $proc | Wait-Process
      2. (Start-Process -FilePath msiexec.exe -ArgumentList "/i no.msi /quiet /qb!" -Wait -Passthru).ExitCode
  11. Environment
    1. $($env:COMPUTERNAME)
  12. Regular Expressions
    1. Regular Expressions with Windows PowerShell
      1. 'test' -match '\w'
    2. Appendix B. Regular Expression Reference
      1. PS > "Test" -match '[Tes]' True
      2. PS > 'ATTT' -match 'AT+'; $Matches[0] True ATTT
    3. $_ -replace "\.crl$", "+.crl"
  13. Resources
    1. PowerShell Pro!
      1. Variables, Arrays, and Hash Tables
        1. Arrays
          1. $x = @(1, 2, 3, 4, 5) $y = @(6, 7, 8, 9, 10) $z = $x + $y $z<enter>
        2. Hash Tables
          1. $EmpNumbers = @{“John Doe” = 112233; “Dave Davis” = 223344; “Justine Smith” = 334455}
      2. PowerShell Functions and Filters – The basics
    2. Функции и фильтры в PowerShell
    3. Commands Reference
    4. Learn Powershell
      1. Learn PowerShell – Piping