Fork me on GitHub

This is the list of commandlets for file automation.

Folder operations

Clear-FolderContents

Description

Cleans the specified folder if it exists.
This removes any existing content but preserves the actual folder.

Parameters

Name Type Required Description Example
Path string Path to the folder to clean C:\Target\Folder

Code sample

Clear-FolderContents -Path "C:\Target\Folder"

New-Backup

Description

Creates a backup of the specified folder if it exists.
The backup is created as a subfolder of the destination, using the current date as part of the folder name.
This cmdlet does not do anything if the source folder does not exist.

Parameters

Name Type Required Description Example
Source string Path to the folder to backup C:\Target\MyApplication
Destination string Folder that will contain the backup C:\Backups

Code sample

New-Backup -Source "C:\Target\MyApplication" -Destination "C:\Backups"

Archives

Expand-Zip

Description

Extracts the contents of a ZIP archive to the specified folder.

Parameters

Name Type Required Description Example
File string Path to the ZIP file C:\Builds\Version1.zip
Destination string Target folder to extract to C:\Target
CleanDestinationFirst switch Add this switch to deleted the destination folder before extracting

Code sample

Expand-Zip -File "C:\Builds\Version1.zip" -Destination "C:\Target"