Skip to content

Instantly share code, notes, and snippets.

@rezamt
Created July 21, 2025 06:26
Show Gist options
  • Select an option

  • Save rezamt/54657f42b0e0082a9dcc6f214d18f7e5 to your computer and use it in GitHub Desktop.

Select an option

Save rezamt/54657f42b0e0082a9dcc6f214d18f7e5 to your computer and use it in GitHub Desktop.

Revisions

  1. rezamt created this gist Jul 21, 2025.
    7 changes: 7 additions & 0 deletions psh.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    $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"