Forked from gregjhogan/azure-custom-script-extension-run-as-user.ps1
Created
January 6, 2020 22:31
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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