Reset Azure VM Admin password with Domain Controller installed

&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;94 -->&NewLine;<div class&equals;"quads-location quads-ad2531 " id&equals;"quads-ad2531" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;<h2>Active Directory Admin Password<&sol;h2>&NewLine;<p>We had a security lab on Azure with 12 machines&comma; It included 2 DCs and 10 other machines of different OS and had RDP closed on all the machines except one machine to use&period;<&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;94 -->&NewLine;<div class&equals;"quads-location quads-ad2526 " id&equals;"quads-ad2526" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;94 -->&NewLine;<div class&equals;"quads-location quads-ad2528 " id&equals;"quads-ad2528" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;94 -->&NewLine;<div class&equals;"quads-location quads-ad2526 " id&equals;"quads-ad2526" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<p>The Password was set for something simple however it seems that someone has changed it and no one was able to access the domain controller anymore nor any of the machines&period;<&sol;p>&NewLine;<p>I had another user created for backup but it seems that user was also changed&period;<&sol;p>&NewLine;<p>The usual method of resetting Azure VM is going through portal or PowerShell<&sol;p>&NewLine;<h2>Resetting Via Azure Portal<&sol;h2>&NewLine;<p>When you try to reset the password from Azure Virtual machine itself&period; If the VM has Domain Controller it will fail to reset the password with the following error&colon;<&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;portal&period;azure&period;com&sol;&num;">Failed to reset RDP configuration<&sol;a><&sol;p>&NewLine;<p>VM has reported a failure when processing extension &&num;8216&semi;enablevmaccess&&num;8217&semi;&period; Error message&colon; &&num;8220&semi;VMAccess Extension does not support Domain Controller&period;&&num;8221&semi; More information on troubleshooting is available at <a href&equals;"https&colon;&sol;&sol;aka&period;ms&sol;vmextensionwindowstroubleshoot">https&colon;&sol;&sol;aka&period;ms&sol;vmextensionwindowstroubleshoot<&sol;a><&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&period;png"><img style&equals;"margin&colon; 0px&semi; display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb&period;png" alt&equals;"image" width&equals;"498" height&equals;"157" border&equals;"0" &sol;><&sol;a> &NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;94 -->&NewLine;<div class&equals;"quads-location quads-ad2526 " id&equals;"quads-ad2526" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine; &NewLine;<&sol;p>&NewLine;<h2>Through PowerShell<&sol;h2>&NewLine;<p>To reset a password&comma; we first need to define the VM we&&num;8217&semi;re working with&period; To do this&comma; we can use the Get-AzureRmVm cmdlet&period; I&&num;8217&semi;ll go ahead and assign variables to both the VM name and the resource group since we&&num;8217&semi;ll need to reference those later&comma; as well&period;<&sol;p>&NewLine;<pre>&dollar;vmName &equals; 'YOURVMNAMEHERE'&NewLine;&dollar;resourceGroupName &equals; 'YOURRGHERE'&NewLine;&dollar;vm &equals; Get-AzureRmVm -Name &dollar;vmName -ResourceGroupName &dollar;resourceGroupName<&sol;pre>&NewLine;<h2><&sol;h2>&NewLine;<p>Next&comma; we&&num;8217&semi;ll need some way to pass the username and password into the script&period; A great way to do that is through the Get-Credential cmdlet&period;<&sol;p>&NewLine;<pre>&dollar;credential &equals; Get-Credential<&sol;pre>&NewLine;<p>Once the credential is saved&comma; we can then execute the command to actually make the password change using the variables we set earlier&period; Notice we had to use the GetNetworkCredential&lpar;&rpar; method on the pscredential object&period; This method will <em>not<&sol;em> work if the credential is retrieved from another computer or from another user account&period; This shouldn&&num;8217&semi;t be a problem&comma; though&comma; since you&&num;8217&semi;re likely to execute this in a single script&period;<&sol;p>&NewLine;<pre>&dollar;extensionParams &equals; &commat;&lbrace;&NewLine; 'VMName' &equals; &dollar;vmName&NewLine; 'Username' &equals; &dollar;Credential&period;UserName&NewLine; 'Password' &equals; &dollar;Credential&period;GetNetworkCredential&lpar;&rpar;&period;Password&NewLine; 'ResourceGroupName' &equals; &dollar;resourceGroupName&NewLine; 'Name' &equals; 'AdminPasswordReset'&NewLine; 'Location' &equals; &dollar;vm&period;Location&NewLine;&rcub;&NewLine;&NewLine;&dollar;result &equals; Set-AzureRmVMAccessExtension &commat;extensionParams<&sol;pre>&NewLine;<p>Once this completed &lpar;hopefully successfully&rpar;&comma; the VM will need to be rebooted&period; We can do that by using the Restart-AzureRmVm cmdlet&period;<&sol;p>&NewLine;<pre>&dollar;vm &vert; Restart-AzureRmVM<&sol;pre>&NewLine;<p>While this PowerShell script might work with a normal VM&comma; It will not work with a DC and would result in the same error as in the portal&period;<&sol;p>&NewLine;<h2>Solution<&sol;h2>&NewLine;<p>The solution is to write a script which would run through the CustomScriptExtension that you can deploy from the Azure Portal on the intended VM that has the Domain Controller Deployed on it&period;<&sol;p>&NewLine;<p>Once you get the script ready to change the administrator Password you can upload the script and deploy it&period;<&sol;p>&NewLine;<p>Let’s get the script ready and demonstrate these steps one by one&period;<&sol;p>&NewLine;<p>&&num;8211&semi; On my Computer I will write a tiny script that will say<&sol;p>&NewLine;<p><strong>Net User domainadmin Adm&excl;nPassw0rd1<&sol;strong><&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image-1&period;png"><img style&equals;"margin&colon; 0px&semi; display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb-1&period;png" alt&equals;"image" width&equals;"426" height&equals;"151" border&equals;"0" &sol;><&sol;a><&sol;p>&NewLine;<p>&&num;8211&semi; Save the file on your desktop for later use&period; Go to Azure Portal&comma; Virtual Machines and select your Domain Controller&period;<&sol;p>&NewLine;<p>&&num;8211&semi; Go to Extensions&period;<&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;94 -->&NewLine;<div class&equals;"quads-location quads-ad2531 " id&equals;"quads-ad2531" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<p>&&num;8211&semi; Click on Add<&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image-2&period;png"><img style&equals;"display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb-2&period;png" alt&equals;"image" width&equals;"905" height&equals;"553" border&equals;"0" &sol;><&sol;a><&sol;p>&NewLine;<p>&&num;8211&semi; Select Custom script Extension<&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image-3&period;png"><img style&equals;"margin&colon; 0px&semi; display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb-3&period;png" alt&equals;"image" width&equals;"559" height&equals;"553" border&equals;"0" &sol;><&sol;a><&sol;p>&NewLine;<p>&&num;8211&semi; Click Create<&sol;p>&NewLine;<p>&&num;8211&semi; Browse the PowerShell script on your Desktop&period;<&sol;p>&NewLine;<p>&&num;8211&semi; Select Storage Account<&sol;p>&NewLine;<p>&&num;8211&semi; Select an existing container or create new one<&sol;p>&NewLine;<p>&&num;8211&semi; Upload the file to the container<&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image-4&period;png"><img style&equals;"margin&colon; 0px&semi; display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb-4&period;png" alt&equals;"image" width&equals;"1028" height&equals;"277" border&equals;"0" &sol;><&sol;a><&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image-5&period;png"><img style&equals;"display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb-5&period;png" alt&equals;"image" width&equals;"706" height&equals;"772" border&equals;"0" &sol;><&sol;a><&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image-6&period;png"><img style&equals;"margin&colon; 0px&semi; display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb-6&period;png" alt&equals;"image" width&equals;"359" height&equals;"276" border&equals;"0" &sol;><&sol;a><&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image-7&period;png"><img style&equals;"margin&colon; 0px&semi; display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb-7&period;png" alt&equals;"image" width&equals;"790" height&equals;"432" border&equals;"0" &sol;><&sol;a><&sol;p>&NewLine;<h2><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image-8&period;png"><img style&equals;"display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb-8&period;png" alt&equals;"image" width&equals;"1028" height&equals;"323" border&equals;"0" &sol;><&sol;a><&sol;h2>&NewLine;<h3>Result<&sol;h3>&NewLine;<p>Once deployed&comma; it’ll take few mins to reset the password and you don’t have to restart the server&period;<&sol;p>&NewLine;<h2>Through PowerShell<&sol;h2>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image-9&period;png"><img style&equals;"margin&colon; 0px&semi; display&colon; inline&semi; background-image&colon; none&semi;" title&equals;"image" src&equals;"https&colon;&sol;&sol;www&period;moh10ly&period;com&sol;wp-content&sol;uploads&sol;2020&sol;04&sol;image&lowbar;thumb-9&period;png" alt&equals;"image" width&equals;"940" height&equals;"525" border&equals;"0" &sol;><&sol;a><&sol;p>&NewLine;<p>After this I was able to access the machine again using the new password in the script&period;<&sol;p>&NewLine;<p>ref&colon;<&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;docs&period;microsoft&period;com&sol;en-us&sol;azure&sol;virtual-machines&sol;extensions&sol;features-windows&num;troubleshoot-vm-extensions">https&colon;&sol;&sol;docs&period;microsoft&period;com&sol;en-us&sol;azure&sol;virtual-machines&sol;extensions&sol;features-windows&num;troubleshoot-vm-extensions<&sol;a><&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;docs&period;microsoft&period;com&sol;en-us&sol;azure&sol;virtual-machines&sol;windows&sol;run-command">https&colon;&sol;&sol;docs&period;microsoft&period;com&sol;en-us&sol;azure&sol;virtual-machines&sol;windows&sol;run-command<&sol;a><&sol;p>&NewLine;<p><a href&equals;"https&colon;&sol;&sol;mcpmag&period;com&sol;articles&sol;2017&sol;12&sol;13&sol;azure-vm-password-with-powershell&period;aspx">https&colon;&sol;&sol;mcpmag&period;com&sol;articles&sol;2017&sol;12&sol;13&sol;azure-vm-password-with-powershell&period;aspx<&sol;a><&sol;p>&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;94 -->&NewLine;<div class&equals;"quads-location quads-ad2527 " id&equals;"quads-ad2527" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;<p><a href&equals;"https&colon;&sol;&sol;docs&period;microsoft&period;com&sol;en-us&sol;azure&sol;virtual-machines&sol;troubleshooting&sol;reset-local-password-without-agent">https&colon;&sol;&sol;docs&period;microsoft&period;com&sol;en-us&sol;azure&sol;virtual-machines&sol;troubleshooting&sol;reset-local-password-without-agent<&sol;a><&sol;p>&NewLine;&NewLine;<&excl;-- WP QUADS Content Ad Plugin v&period; 2&period;0&period;94 -->&NewLine;<div class&equals;"quads-location quads-ad2525 " id&equals;"quads-ad2525" style&equals;"float&colon;none&semi;margin&colon;0px 3px 3px 3px&semi;padding&colon;0px 0px 0px 0px&semi;" data-lazydelay&equals;"0">&NewLine;&NewLine;<&sol;div>&NewLine;&NewLine;

moh10ly

View Comments

Recent Posts

Reset passwords for Active Directory Users

Reset and manage your Active Directory users' Passwords Active Directory is one of the most…

3 years ago

Finding Exchange Database hidden mailboxes. ​

Finding Exchange Database hidden mailboxes. Story:Maybe you have been in this situation before, trying to…

3 years ago

Setting up ADConnect and PTA (Password auth through) servers agents behind proxy

If you're using a Proxy server in your firewall or in your network and have…

3 years ago

Get Report of Active Directory Locked Accounts and Machine they logged in from

Story:I got some clients  that have reported some of their users being locked out and…

3 years ago

Checking and Providing Full and SendAs delegate access on O365 Exchange Online

Delegate Permissions This is a code that I have wrote recently to check if an…

3 years ago

Retrieving attachments from Exchange mailbox using python

Story: I got a request from a client who constantly gets CVs and have to…

4 years ago

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298

Warning: Undefined array key "adsense_ad_type" in /www/wwwroot/www.moh10ly.com/wp-content/plugins/quick-adsense-reloaded/includes/amp-condition-display.php on line 298