0

Is it possible to create AD Users (and generally run AD cmdlets) with Custom Script Extension on Azure machines?

I see that CSE is running as SYSTEM. It also doesn't start any scripts that I am trying to run as a different user, e.g.

#try1
Start-Process Powershell.exe -ArgumentList C:\MyScript.ps1 -Credential $VMcred

#try2
$farmSession = New-PSSession -Credential $VMcred -ComputerName $env:computername            
Invoke-Command -Session $farmSession -Script `
{ #MyScriptHere}

Is the solution to assign AD permissions to a SYSTEM account?
Or PSRemoting is a must in this case?

1 Answer 1

2

I think your scripts won't work. Since the Custom Script Extension is running as a System account, you cannot change it running as another different user.

Solution:

First, you can run the regular powershell cmdlets with Custom script extension. But you will failed with it, Then you should RDP to your VM and find the error massage in the Event Viewer. Then you can follow this blog to assign permissions to System account.

After assigning permissions, you will succeed running the same powershell cmdlets with Custom script extension.

By the way, I don't understand why you need CSE to add ad users for your DC on Azure VM. Why not just add it by RDP the VM and run powershell or else. Custom script extension is usually used for some tasks when user cannot RDP the VM .

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.