Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $credential = Get-Credential
  2.     Import-Module MsOnline
  3.     Connect-MSolService -Credential $credential
  4. $NewPassword = Read-Host -Prompt "What is the new Password you would like to use?"
  5. $Username = <Insert Username with @ at the end - i.e. admin@)>
  6. $AllTenants = Get-MsolPartnerContract -All
  7. $ClientDomains = $AllTenants | foreach {$TenantID = $_.TenantId; $Domain = Get-MsolDomain -TenantId $TenantID |
  8.     Where-Object {($_.Status -eq "Verified") -and ($_.Name -notlike "*.onmicrosoft.com") -and ($_.isdefault -eq "True")}
  9.     foreach-object {$EmailAddress = $Username + $Domain.name
  10.         ForEach-Object {Write-Host "The password for $EmailAddress was changed successfully!"
  11.         }
  12.     }
  13.     Set-MsolUserPassword -TenantId $TenantID -UserPrincipalName $EmailAddress -NewPassword $NewPassword -ForceChangePassword $false
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement