Skip to main content

PowerShell

Save Credentials to File

NOTE: this should only be done on Windows 

# prompt for creds
$creds = Get-Credential

# dump to file
$creds | Export-Clixml -Path C:\<somewhere>\<name-for-creds>.xml

# load from file
$creds = Import-Clixml -Path C:\<somewhere>\<name-for-creds>.xml

 

Initiate a Remote PowerShell Session

$Cred = Get-Credential
Enter-PSSession -ComputerName dc01 -Credential $Cred

Kill a Process from a Remote Session

# find the offending process PID
Get-Process

# kill it
taskkill /F /PID <PID>