I'm using ARM and have created an automation account, with a run book using the PowerShell code snippet below to modify Azure AD users so that their location is updated properly. All resources are within the same subscription and resource group as my Azure AD.
get-msoluser | where{$_.userPrincipalName -like "*@contoso.co.uk"} | set-msoluser -Usagelocation "GB" When I run this in Azure, I get a failure as below:
The term 'get-msoluser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:2 char:1 + get-msoluser | where{$_.userPrincipalName -like "*@contoso.co.uk."} | s ... + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (get-msoluser:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
When I run the PowerShell manually using "connect-msolservice" and enter my credentials it works fine.
I have a couple of questions:
- Do I need to supply credentials so that the PowerShell knows which Azure AD to connect to?
- What modifications do I need to make to ensure get-msoluser cmdlet is recognised?
Thanks