Guest User

Untitled

a guest
May 28th, 2018
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. $AdminURL = "https://tenant-admin.sharepoint.com/"
  2. $AdminName = "admin@tenant.onmicrosoft.com"
  3. $NewUser = "newuser@tenant.onmicrosoft.com"
  4.  
  5. #User Names Password to connect
  6. $Password = Read-host -assecurestring "Enter Password for $AdminName"
  7. $Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $Password
  8.  
  9. #Connect to SharePoint Online
  10. Connect-SPOService -url $AdminURL -credential $Credential
  11.  
  12. $Sites = Get-SPOSite -Limit ALL
  13.  
  14. Foreach ($Site in $Sites)
  15. {
  16. Write-host "Adding Site Collection Admin for:"$Site.URL
  17. Set-SPOUser -site $Site -LoginName $NewUser -IsSiteCollectionAdmin $True
  18. }
Add Comment
Please, Sign In to add comment