Wednesday, February 8, 2012

PowerShell Cmdlets

Here are some PowerShell cmdlets that others might find helpful (as they are very much helpful to me). For more details, you may refer to http://technet.microsoft.com/en-us/library/ee156818.aspx.

Cmdlet
Usage
Example
Get-ChildItem Returns items in the specified folder Get-ChildItem $folder -include *.cs -force -recurse
Copy-Item (cpi) Copy files or folders Copy-Item $folder/$file -force -recurse
cpi $folder/$file -force -recurse
Remove-Item (ri) Delete files or folders Remove-Item $folder -force -recurse
ri $file -force
New-Item (ni) Create new files or folders New-Item $folder -type directory
ni $file -type file -force
Invoke-Item (ii) Run executable file or open a file. Alternatively prefix the script with an ampersand (&) and make sure to enclose parameters with spaces in double quotes Invoke-Item $script
ii $script
& $script "parameter1" "parameter2"
Get-Location (gl) Returns the current folder $currentDirectory = Get-Location
Set-Location (sl) Change the current folder Set-Location $newFolder
sl $newFolder


*joychua97

No comments:

Post a Comment