Chapter 4 Quick Reference
To | Do This |
|---|---|
Retrieve the script execution policy | Use the Get-ExecutionPolicy cmdlet |
Set the script execution policy | Use the Set-ExecutionPolicy cmdlet |
Create a variable | Type the variable name in the script |
Create a constant | Use the New-Variable cmdlet and specify constant for the option argument |
Loop through a collection when you do not know how many items are in the collection | Use the ForEach-Object cmdlet |
Pause execution of a script for a certain amount of time | Use the Start-Sleep cmdlet and supply the amount of time to sleep in either seconds or milliseconds |
Print out text in color | Use the Write-Host cmdlet and supply the appropriate color to the foregroundcolor argument |
Read the contents of a text file | Use the Get-Content cmdlet and ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access