PowerShell sniplets

On the page you can find some read-to-use Code Sniplets to use in the DefinitionType PS1 (Powershell).

Overview Sniplets

Listing the contents of a directory

 

Listing the contents of a directory

Use Get-ChildItem to list the contents of a directory:

   $dir="c:\temp"
   Get-ChildItem  "$dir" 
	   

 

Renaming files in a directory

Use Rename-Item -NewName to rename files in a directory:

  Get-ChildItem C:\temp\*.xml| Rename-Item -NewName { $_.Name -replace '\.xml','_renamed.xml' }