Skip to content

Instantly share code, notes, and snippets.

View BinkyWong's full-sized avatar

Binky Wong BinkyWong

  • UK
View GitHub Profile
@BinkyWong
BinkyWong / example.ps1
Last active April 10, 2023 08:01
Powershell example running a process as another user with a SecureString object
# Create secure text file
"secret_pass" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString > creds.secure
# Set username
$User="myDomain.com\svc_account"
# Load secure string from file and convert to a SecureString object
$pass = (Get-Content -Path "creds.secure" | ConvertTo-SecureString)
# Create credential object