Tuesday, August 30, 2022

Copy page from one sharepoint site to other sharepoint site

    
    $group_list = Import-Csv 'C:\WW\SiteList.csv'
      
    $srcUrl = "https://shared.sharepoint.com/sites/fj-mech-dev/"
    $pageName = "Home-Team.aspx" 

    #$cred = Get-Credential  
    Connect-PnPOnline -Url $srcUrl -Credentials $cred 

    #$Cred=Get-Credential

  foreach ($group in $group_list) 
    
    {


            try {  
     
            $destUrl = $group.SiteName #Read-Host "Enter the destination site url"  
             
                         
            $tempFile = [System.IO.Path]::GetTempFileName();  
            
            Export-PnPClientSidePage -Force -Identity $pageName -Out $tempFile  
            
            Connect-PnPOnline -Url $destUrl -Credentials $cred  
            
            Invoke-PnPSiteTemplate -Path $tempFile
            
            $group.SiteName  
            Write-Host "ModernPage is successfully copied."  
            
            sleep 10 
            Set-PnPHomePage -RootFolderRelativeUrl "sitepages/Home-Team.aspx"#$pageName
        } catch {  
            $group.SiteName
            Write-Host -ForegroundColor Red 'Error ', ':'  
            $Error[0].ToString(); 
           
            sleep 10  
        }



    }

Wednesday, March 9, 2022

Add all users except guest account as a Sharepoint online site viewer access

 

$SiteURL = "https://test.sharepoint.com/sites/team"
Connect-PnPOnline -Url $SiteURL -UseWebLogin
$Group = Get-PnPGroup -AssociatedVisitorGroup
$User = "Everyone except external users"
Add-PnPGroupMember -LoginName $User -Identity $Group

HTML

Script:

JS