Wed. Jun 8th, 2022
cls

#Parameters value
$spopasswordFile = "c:\PSscripts\Credentials\" + $Server + "_"+$Initials+"_"+$dst_username+"_password.txt";
$spopassword = Get-Content $spopasswordFile | ConvertTo-SecureString

$inputFile = 'c:\PSscripts\Migration\sitelist.csv'
$sitesList = Import-Csv $inputFile -Delimiter ","

#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)
{

try
{
    foreach($row in $sitesList)
    {
        $site = Get-PnPTenantSite -Url $row.dstUrl
        $site.DefaultLinkToExistingAccess = $true
        $site.Update()
        $site.Context.ExecuteQuery()
        Write-host "DefaultLinkToExistingAccess has be updated on $($row.dstUrl)" -ForegroundColor Green
    }

}catch
{
    Write-Host "Unable to connect to site" $_.Exception.Message -ForegroundColor Red
}
}

This website uses cookies. By continuing to use this site, you accept our use of cookies.