All notes

Intro // 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 $ -startupType Disabled}

Run script syntex run.


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:
:: 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
:: If the batch script contains any internal commands
C:\windows\system32\cmd /c c:\batch\demo.cmd
:: VBScript
cscript c:\batch\demo.vbs



ss64: set-executionPolicy.