Hello All,
I have a generic users accounts that needs to have their password changed occasionally. I have been trying to resolve it with Powershell however I stuck on one particular problem.
All the users names have similar pattern which suppose to ease the pain.
Anyway, there is my code so far…
If anyone could shed some light I’d be very grateful.
Thanks in advance
’ $objectid = @(get-azureaduser -all $true | Where-Object {$_.userprincipalname -like “prorel*”} | select objectid)
foreach ($i in $objectid){
Set-AzureADUserPassword -ObjectId $i -password (convertto-securestring “Passwords2022” -AsPlainText -Force)
}’
I’m receiving the following error message:
'Set-AzureADUserPassword : Error occurred while executing SetUser
Code: Request_ResourceNotFound
Message: Resource '@{ObjectId=badd5c83-7f61-48a4-b475-37154dc17886}' does not exist or one of its queried reference-property objects are not present.
RequestId: 04979a93-8672-4f47-bb8e-3f2ca70d643d
DateTimeStamp: Tue, 12 Apr 2022 14:01:12 GMT
HttpStatusCode: NotFound
HttpStatusDescription: Not Found
HttpResponseStatus: Completed
At line:6 char:2
+ Set-AzureADUserPassword -ObjectId $i -password (convertto-securestri ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-AzureADUserPassword], ApiException
+ FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.Graph.PowerShell.Custom.Cmdlet.SetUserPassword'
I'm welcoming all suggestions.
Thanks
Arek