cmdlets
Run these directly from the command line or use them in your scripts.
New-Item
Creating Files
C:\path\to\somewhere\> New-Item -path C:\scripts\myfile.txt -type "file" -value "Here is some text" C:>cd \scripts C:> ls Mode LastWriteTime Length Name ... -a---- MM/DD/YYYY H:mm 17 myfile.txt ... C:\scripts\> New-Item -path .\myotherfile.txt -type "file" -value "Here is some text" C:> ls Mode LastWriteTime Length Name ... -a---- MM/DD/YYYY H:mm 17 myfile.txt -a---- MM/DD/YYYY H:mm 17 myotherfile.txt ...
Creating Folders
C:\scripts\> New-Item -path . -name myfolder -type "directory C:> ls ... d----- blah blah myfolder ...
Copy-Item
C:> Copy-Item <C:\path\to\source> -destination <C:\path\to\destination>
Move-Item
C:> Move-Item -path <\path\to\source> -destination <\path\to\destination>
Remove-Item
Delete a file/folder/item
C:> Remove-Item <C:\path\to\source>
Rename-Item
C:> Rename-Item -path <\path\to\source> -newname <\path\to\destination>
Test-Path
Check if a file/folder exists. Returns True or False
C:> Test-Path C:\path\to\item True|False