Skip to content

Instantly share code, notes, and snippets.

@rezamt
Created July 21, 2025 06:26
Show Gist options
  • Save rezamt/54657f42b0e0082a9dcc6f214d18f7e5 to your computer and use it in GitHub Desktop.
Save rezamt/54657f42b0e0082a9dcc6f214d18f7e5 to your computer and use it in GitHub Desktop.
PSH
$username = "DOMAIN\ServiceAccount"
$password = "YourPassword"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($username, $securePassword)
# Now use the credential
Start-Process powershell.exe -Credential $credential -ArgumentList "-File C:\path\to\script.ps1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment