Chapter 4 Quick Reference


Open table as spreadsheet

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




Microsoft Press - Microsoft Windows PowerShell Step by Step
MicrosoftВ® Windows PowerShell(TM) Step By Step (Step By Step (Microsoft))
ISBN: 0735623953
EAN: 2147483647
Year: 2007
Pages: 128
Authors: Ed Wilson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net