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 supply the path to the file as the value for the path argument |
To produce a beep in a script | Use the `a special escape character sequence inside a string |
Delete a folder | Use the Remove-Item cmdlet and supply the path to the folder as the value for the path argument |