Skip to content

Instantly share code, notes, and snippets.

@dbirks
Last active June 21, 2018 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbirks/3134e5f5298f183573514d50ee9e428c to your computer and use it in GitHub Desktop.
Save dbirks/3134e5f5298f183573514d50ee9e428c to your computer and use it in GitHub Desktop.
Helpful Powershell commands

Helpful Powershell commands

Add a computer to the domain

Add-Computer -DomainName corp.contoso.com 

I've found the FQDN is required in my environment.

It will also prompt for the credentials.

Relevant StackOverflow

Export a message trace in Exchange to a .csv file

Get-MessageTrace -SenderAddress kukuri@internetcompany.com -StartDate 12/20/2017 -EndDate
12/22/2017 | Select-Object received, recipientaddress, subject | Export-Csv report-csv.csv

Open a remote share

Since cd is an alias for Set-Location, you can change directory to the UNC path like so:

cd \\server\share

Rename computer

Rename-Computer WS-238SH67

Renames nicely in Active Directory as well.

Restart computer

Restart-Computer

Check if a disk is a HDD or SSD

Get-PhysicalDisk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment