All notes
Powershell

Intro

http://powershell.com/cs/blogs/tips/archive/2008/12/19/stopping-and-disabling-services.aspx // Help get-help set-service // Get all services prefixed by wcf: get-service Wcf* // Stop and disable all services prefixed by Wcf stop-service Wcf* get-service Wcf* | foreach-object {set-service $_.name -startupType Disabled}

Run script

ss64.com: syntex run.

Walkthrough:


get-executionPolicy
set-executionPolicy UnRestricted
& "pathTo/script.ps1"

Several ways to run a PS script:


:: 1. Call or Invoke a script

:: When you invoke a script in this way, variables and functions defined in the script will disappear when the script ends.

:: Default way.
& "C:\Belfry\My first Script.ps1"
:: If the path does not contain any spaces:
C:\Belfry\Myscript.ps1
:: An alternative
invoke-command -filepath c:\scripts\test.ps1 -computerName Server64

:: 2. Dot sourcing

:: When you dot source a script, all variables and functions defined in the script will persist even when the script ends.

. "C:\Belfry\My first Script.ps1"

:: 3. Run other scripts

:: CMD
./demo.cmd
:: If the batch script contains any internal commands
C:\windows\system32\cmd /c c:\batch\demo.cmd
:: VBScript
cscript c:\batch\demo.vbs

Commands

set-executionPolicy

ss64: set-executionPolicy.