#Parameters value
$spopasswordFile = "c:\PSscripts\Credentials\spo_password.txt";
$spopassword = Get-Content $spopasswordFile | ConvertTo-SecureString
$NetworkpasswordFile = "c:\PSscripts\Credentials\Network_password.txt";
$Networkpassword = Get-Content $NetworkpasswordFile | ConvertTo-SecureString
#Setup Credentials to connect
$Credentials = New-Object System.Net.NetworkCredential($src_username, $Networkpassword, $domain)
$SPOcredentials = New-Object System.Management.Automation.PSCredential($dst_username,$spopassword)
if(ConnectToTenant $SPOcredentials)
{
$siteUrl= "https://domain.sharepoint.com/site/Team001"
try
{
Connect-PnPOnline -Url $siteUrl –credential $SPOcredentials
Add-PnPSiteCollectionAdmin -Owners @("serviceaccount1@domain.com", "serviceaccount2@domain.com", "serviceaccoun3@domain.com")
Write-host "Added SCAs to $siteUrl" -ForegroundColor Green
}catch
{
write-host Could not added administrator for $row.srcUrl - $_.Exception.Message -ForegroundColor Red
}
}
