Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $AdminURL = "https://tenant-admin.sharepoint.com/"
- $AdminName = "admin@tenant.onmicrosoft.com"
- $NewUser = "newuser@tenant.onmicrosoft.com"
- #User Names Password to connect
- $Password = Read-host -assecurestring "Enter Password for $AdminName"
- $Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $Password
- #Connect to SharePoint Online
- Connect-SPOService -url $AdminURL -credential $Credential
- $Sites = Get-SPOSite -Limit ALL
- Foreach ($Site in $Sites)
- {
- Write-host "Adding Site Collection Admin for:"$Site.URL
- Set-SPOUser -site $Site -LoginName $NewUser -IsSiteCollectionAdmin $True
- }
Add Comment
Please, Sign In to add comment