Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save manualbashing/b0a812119ef967c94ddf6d83509cd50c to your computer and use it in GitHub Desktop.
Save manualbashing/b0a812119ef967c94ddf6d83509cd50c to your computer and use it in GitHub Desktop.
How to run a script as a different user in an Azure VM Custom Script Extension
Enable-PSRemoting -Force
$credential = New-Object System.Management.Automation.PSCredential @(($AdminDomain + "\" + $AdminUsername), (ConvertTo-SecureString -String $AdminPassword -AsPlainText -Force))
Invoke-Command -FilePath $PSScriptRoot\setup-as-user.ps1 -Credential $credential -ComputerName localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment