SharePoint Online Powershell
6 TopicsAdministrer les droits des dossiers partagés SPO via powershell
Bonjour, Je dispose d'un SPO dans lequel des dossiers (et sous-dossiers) ont été disposés (actuellement aucun document présent à l'intérieur). l'héritage des droits du SharePoint a été retiré car chaque dossier à la racine des "documents partagés" sera administré par un Groupe de Sécurité qui lui appartient. Cependant, afin que l'arborescence des dossiers ne soit pas "malencontreusement" détruite par d'éventuelles erreurs humaines des membres de ces groupes, nous souhaitons que chaque dossier soit en lecture seule hormis chaque dernier dossier de l'arborescence. (Grand-Parents en Lecture, Parent en Lecture, enfant en Lecture/ecriture en quelques sorte). La quantité de dossier en place représente 6 414 dossiers ce qui, vous vous en doutez ne peux se faire à la main. Je suis donc à la recherche de commande qui pourrait me permettre de faire cette action en powershell. Pourriez-vous m'aider svp ? En pj : un exemple de l'arborescence pour que ce soit plus ... parlant ! Merci beaucoup aux contributeurs1.5KViews0likes2CommentsHelp - need to create a report of all versions of a file for all files in all doc Libraries
Hi all, I can use some help. I'm fairly new to PowerShell. I would appreciate your help dearly. I have been asked to write a script to list all files in all document libraries on a site before a given date. I have searched the internet and found the following script that searches all document libraries in a site and compiles the number of versions for each file. It exports the following to a CSV file with the following data: File Name - Site Name - Version Count - Version size - Library - Url Here is the script: #Import SharePoint Online module Import-Module Microsoft.Online.SharePoint.Powershell Function Generate-VersionHistoryReport() { param ( [Parameter(Mandatory=$true)] [string] $SiteURL, [Parameter(Mandatory=$true)] [string] $ReportOutput ) Try { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = $Credentials #Get all subsites and Lists from the site $Web = $Ctx.Web $Ctx.Load($Web) $Ctx.Load($Web.Webs) $Lists = $Web.Lists $Ctx.Load($Lists) $Ctx.ExecuteQuery() Write-host -f Yellow "Processing Site: "$SiteURL #Exclude system lists $ExcludedLists = @("Access Requests","App Packages","appdata","appfiles","Apps in Testing","Cache Profiles","Composed Looks","Content and Structure Reports","Content type publishing error log","Converted Forms", "Device Channels","Form Templates","fpdatasources","Get started with Apps for Office and SharePoint","List Template Gallery", "Long Running Operation Status","Maintenance Log Library", ,"Master Docs","Master Page Gallery" "MicroFeed","NintexFormXml","Quick Deploy Items","Relationships List","Reusable Content","Reporting Metadata", "Reporting Templates", "Search Config List","Site Assets", "Site Pages", "Solution Gallery", "Style Library","Suggested Content Browser Locations","Theme Gallery", "TaxonomyHiddenList","User Information List","Web Part Gallery","wfpub","wfsvc","Workflow History","Workflow Tasks") #Iterate through each list in a site and get versioning configuration ForEach($List in $Lists) { if(($ExcludedLists -NotContains $List.Title) -and ($List.EnableVersioning) -and ($List.BaseType -eq "DocumentLibrary")) { Write-Host "`tProcessing Library:"$List.Title #Query to Batch process Items from the document library $Query = New-Object Microsoft.SharePoint.Client.CamlQuery $Query.ViewXml = "<View Scope='RecursiveAll'><Query><OrderBy><FieldRef Name='ID' /></OrderBy></Query><RowLimit>2000</RowLimit></View>" $VersionHistoryData = @() Do { $ListItems=$List.GetItems($Query) $Ctx.Load($ListItems) $Ctx.ExecuteQuery() $Query.ListItemCollectionPosition = $ListItems.ListItemCollectionPosition #Iterate through each version of the file $VersionHistoryData = @() #Iterate through each file - Excluding Folder Objects Foreach ($Item in $ListItems | Where { $_.FileSystemObjectType -eq "File"}) { $File = $web.GetFileByServerRelativeUrl($Item["FileRef"]) $Ctx.Load($File) $Ctx.Load($File.Versions) $Ctx.ExecuteQuery() If($File.Versions.Count -ge 1) { $VersionSize=0 #Print File Name write-host $File.name #Calculate Version Size Foreach ($Version in $File.Versions) { write-host $Version.Size write-host $Version.date $VersionSize = $VersionSize + $Version.Size } #Send Data to the object array $VersionHistoryData += New-Object PSObject -Property @{ 'Site' = $SiteURL 'Library' = $List.Title 'File Name' = $File.Name 'Version Count' = $File.Versions.count 'Version Size-KB' = ($VersionSize/1024) 'URL' = $SiteURL+$File.ServerRelativeUrl } } } } While ($Query.ListItemCollectionPosition -ne $null) #Export the data to CSV $VersionHistoryData | Export-Csv $ReportOutput -Append -NoTypeInformation } } #Iterate through each subsite in the current web Foreach ($Subweb in $Web.Webs) { #Call the function recursively to process all subsites underneath the current web Generate-VersionHistoryReport -SiteURL $Subweb.URL -ReportOutput $ReportOutput } } Catch { write-host -f Red "Error Generating version History Report!" $_.Exception.Message } } #Set parameter values $SiteURL="https://tenant.sharepoint.com/sites/Clients" $ReportOutput="C:\Temp\VersionHistoryRpt.csv" #Get Credentials to connect $Cred= Get-Credential $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password) #Delete the Output report file if exists If (Test-Path $ReportOutput) { Remove-Item $ReportOutput } #Call the function to generate the version History Report Generate-VersionHistoryReport -SiteURL $SiteURL -ReportOutput $ReportOutput1.5KViews0likes1CommentSharePoint Powershell
Hi Bulk Import excel to sharepoint using powershell Able to connect to sharepoint admin url (https://y3pbf-admin.sharepoint.com/) as specified in multiple articles But I would like to know how to connect to Sharepoint site url (https://y3pbf.sharepoint.com/sites/SPFXTutorial/) to acheive the above requirement in powershell Thanks in advance944Views0likes1CommentUnable to connect sharepoint online site collection using powershell
I have to upload the CSV file data to the SharePoint list using Powershell, here the connection is established up to the admin site. but it is not accessing the Sharepoint site collection, showing an error like as: Connect-SPOService : Could not authenticate to SharePoint Online https://siteurl(here I am providing actuall site url, till site name)using OAuth 2.0 At line:1 char:1 + Connect-SPOService + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Connect-SPOService], AuthenticationException + FullyQualifiedErrorId : Microsoft.Online.SharePoint.PowerShell.AuthenticationException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService3.1KViews0likes4CommentsAdd-SPOSiteDesignTask : Operation is not valid due to the current state of the object.
I have created site design with two site scripts. applied using below command $Sitedesignout1=Add-SPOSiteDesign -Title "Site Design 2" -WebTemplate "68" -SiteScripts $result1.Id,$result2.Id -Description "Site Desin Sample" But after try to apply Site design using below code throwing an Operation is not valid due to the current state of the object error $adminSiteUrl = "https://myadmin-admin.sharepoint.com" $siteUrl = "https:// myadmin.sharepoint.com/sites/PracticeSiteDesign" $siteDesignId = "04d0e647-5912-4ef7-8069-9186cebb2192" Connect-SPOService $adminSiteUrl $task = Add-SPOSiteDesignTask -SiteDesignId $siteDesignId -WebUrl $siteUrl Add-SPOSiteDesignTask : Operation is not valid due to the current state of the object. At line:6 char:9 + $task = Add-SPOSiteDesignTask -SiteDesignId $siteDesignId -WebUrl $si ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Add-SPOSiteDesignTask], ServerException + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.AddSPOSiteDesignTask947Views0likes0Comments