Skip to content

Cheatsheet – PowerShell Pentesting

Creating PSCredential Objects

# username and password
$userName = 'user'
$userPassword = 'pass'

# Convert passwird to SecureString
$secStringPassword = ConvertTo-SecureString $userPassword -AsPlainText -Force

# Create PSCredential Object
$credObject = New-Object System.Management.Automation.PSCredential ($userName, $secStringPassword)

Oneliner

$credObject = New-Object System.Management.Automation.PSCredential ('username', (ConvertTo-SecureString 'password' -AsPlainText -Force))

Published inCheat Sheet