Skip to main content

Posts

Showing posts from 2022

Export Site Owners form SharePoint Online

 $AdminCenterURL = ""   #Connect to SharePoint Online Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)   #Get Site owners of all site collections Get-SPOSite -limit ALL | Select URL, Owner| Export-Csv d:\sites.txt get-sposite | %{ $user = get-spouser -site $_ -loginName "emailid1@rbeerla.onmicrosoft.com"; if($user.Groups.Count -gt 0){write-output $_.url ":" $user.Groups} } 

Download All Files From Library in SharePoint online

 #Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"   Function Download-AllFilesFromLibrary() {     param     (         [Parameter(Mandatory=$true)] [string] $SiteURL,         [Parameter(Mandatory=$true)] [Microsoft.SharePoint.Client.Folder] $SourceFolder,         [Parameter(Mandatory=$true)] [string] $TargetFolder     )     Try {                   #Create Local Folder, if it doesn't exist         $FolderName = ($SourceFolder.ServerRelativeURL) -replace "/","\"         $LocalFolder = $TargetFolder + $FolderName         If (!(Test-Path -...

Delete all Items from SharePoint Online List

 Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"       #Config Parameters $SiteURL="SharePoint Site URL" $ListName="List Name" $BatchSize = 500     #Setup Credentials to connect $Cred = Get-Credential     Try {     #Setup the context     $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)     $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)         #Get the web and List     $Web = $Ctx.Web     $List=$web.Lists.GetByTitle($ListName)     $Ctx.Load($List)     $Ctx.ExecuteQuery()     Write-host "Total Number of Items Found in the List:"$List.ItemCount  ...

Copy Items from One List to Another List

 #Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"   Function Copy-ListItems() {     param     (         [Parameter(Mandatory=$true)] [string] $SiteURL,         [Parameter(Mandatory=$true)] [string] $SourceListName,         [Parameter(Mandatory=$true)] [string] $TargetListName     )         Try {         #Setup Credentials to connect         $Cred = Get-Credential         $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)               #Setup the context       ...