Powershell Snippets

List All Commands


List All Commands Beginning with A

Get-Command Get-a*

Replacing Spaces with an Underscore

Renaming files can be a laborious task, especially when there's alot to get through. This command renames all files within your current directory which have a space in the file name, and replaces it with an underscore, for example; 'I need this.jpg' changes to 'I_need_this.jpg'.

Dir | Rename-Item –NewName { $_.name –replace “ “,”_” }

Listing File Names

This command will list all file names in the current directory and put it into a text file. The text file will be saved into the current directory.

ls > filename.txt

More to be added.