WINDOWS POWERSHELL

Commands

PowerShell Commands

Compress-Archive

This example creates a zip file of the Documents folder with a datetime string in the zip filename.

Compress-Archive "$env:USERPROFILE\Documents" "$env:USERPROFILE\Documents_$(get-date -f yyyyMMdd'T'HHmmss).zip"

Reference

$env:PSModulePath

List where all modules get installed.

New-Guid

The New-Guid cmdlet creates a random globally unique identifier (GUID).

reference

Remove-Item

Remove-Item deletes one or more items. It can be used to delete many different types of items, including files, directories, registry keys, variables, aliases, and functions.

# delete folder and contents
Remove-Item .\thefolder\* -recurse -force

# alias is `rd`
rd .\thefolder\* -recurse -force

type

Print the contents of a file.

type C:\Windows\System32\drivers\etc\hosts

Create files

C:\> echo "line from file1" > file1.txt
C:\> echo "line from file2" > file2.txt

Concatenate files

C:\> type file1.txt file2.txt > result.txt
C:\> type result.txt
line from file1
line from file2

Also works in Windows Command prompt.

Reference

comments powered by Disqus