diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/description.md b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/description.md index a0d6f92d..fdc22124 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/description.md +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/description.md @@ -22,9 +22,9 @@ $Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" $ContentTypesEnabled=$true ``` -###Please share your thoughts in the Q&A section! +### Please share your thoughts in the Q&A section! -####Related scripts
+#### Related scripts
[Set direction of the reading order for a single list](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) [Set-SPOList properties (module)](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795) diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 index 9e762df4..71ad751b 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 @@ -3,61 +3,52 @@ # Created by Arleta Wanat, 2015 # -function Set-SPOListsContentTypesEnabled -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SPOListsContentTypesEnabled{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [bool]$ContentTypesEnabled -) - -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.ExecuteQuery() - -$Lists=$ctx.Web.Lists - $ctx.Load($ctx.Web) - $ctx.Load($ctx.Web.Webs) -$ctx.Load($Lists) -$ctx.ExecuteQuery() - -Foreach($ll in $Lists) -{ - $ll.ContentTypesEnabled = $ContentTypesEnabled - $ll.Update() - - - try - { - $ctx.ExecuteQuery() - Write-Host $ll.Title " Done" -ForegroundColor Green - } - - catch [Net.WebException] - { - - Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red - } + ) + + $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.ExecuteQuery() + + $Lists=$ctx.Web.Lists + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Web.Webs) + $ctx.Load($Lists) + $ctx.ExecuteQuery() + + Foreach($ll in $Lists){ + $ll.ContentTypesEnabled = $ContentTypesEnabled + $ll.Update() + + try{ + $ctx.ExecuteQuery() + Write-Host $ll.Title " Done" -ForegroundColor Green + } + catch [Net.WebException]{ + Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + } + } + + if($ctx.Web.Webs.Count -gt 0){ + Write-Host "--"-ForegroundColor DarkGreen + + for($i=0;$i -lt $ctx.Web.Webs.Count ;$i++){ + Set-SPOListsContentTypesEnabled -Username $Username -Url $ctx.Web.Webs[$i].Url -AdminPassword $AdminPassword -ContentTypesEnabled $ContentTypesEnabled + } + } } -if($ctx.Web.Webs.Count -gt 0) - { - Write-Host "--"-ForegroundColor DarkGreen - for($i=0;$i -lt $ctx.Web.Webs.Count ;$i++) - { - Set-SPOListsContentTypesEnabled -Username $Username -Url $ctx.Web.Webs[$i].Url -AdminPassword $AdminPassword -ContentTypesEnabled $ContentTypesEnabled - } - } - -} - @@ -80,4 +71,4 @@ $ContentTypesEnabled=$true -Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled \ No newline at end of file +Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md index bc34af8c..eec2be23 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md @@ -1,29 +1,17 @@ A short Powershell script to allow management of content types for all SharePoint Online lists and libraries across all sites in a site collection - - -It is an equivalent of List>>List Settings>>Advanced>>Content types in Graphic User Interface (see screenshot) - - - - - - +It is an equivalent of **List**>>**List Settings**>>**Advanced**>>**Content types in Graphic User Interface** ([see screenshot](https://github.com/PowershellScripts/AllGalleryScriptsSamples/blob/develop/Content%20Types/Content%20Types%20Management%20Setting/Allow%20content%20type%20management%20for%20all%20lists%20in%20site%20collection/contentTypeManagement.png)) Applies to lists and libraries. - - -It requires installed SharePoint Online SDK +*It requires installed* [SharePoint Online SDK](www.microsoft.com/en-us/download/details.aspx?id=42038) You have to enter the list information before running the script: - - ```PowerShell # Paths to SDK. Please verify location on your computer. @@ -36,33 +24,26 @@ $AdminPassword="Pass" $Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" $ContentTypesEnabled=$true ``` - - - - - -Please share your thoughts in the Q&A section! - - +### Please share your thoughts in the Q&A section! -Wiki article with detailed code description: +#### Wiki article with detailed code description: [SharePoint Online: Turn on support for multiple content types in a list or library using Powershell](http://social.technet.microsoft.com/wiki/contents/articles/30038.sharepoint-online-turn-on-support-for-multiple-content-types-in-a-list-or-library-using-powershell.aspx) -Related scripts -Set-SPOList properties (module) +#### Related scripts +[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) -Disable or enable attachments to list items using Powershell +[Disable or enable attachments to list items using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795) -Change search setting for all lists in a site using CSOM and Powershell +[Change search setting for all lists in a site using CSOM and Powershell](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48) -Allow content type management for all lists in a site using Powershell +[Allow content type management for all lists in a site using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Allow-content-type-5bca5157) -Set content type management setting for SharePoint Online list using Powershell +[Set content type management setting for SharePoint Online list using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Set-content-type-39ae4bce)

diff --git a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 index db6603cf..a18ba4af 100644 --- a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 +++ b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 @@ -3,58 +3,45 @@ # Created by Arleta Wanat, 2015 # -function Set-SPOList -{ -param ( - [Parameter(Mandatory=$true,Position=0)] +function Set-SPOList{ + param( + [Parameter(Mandatory=$true,Position=0)] [string]$ListName, - [Parameter(Mandatory=$true,Position=1)] + [Parameter(Mandatory=$true,Position=1)] [bool]$ContentTypesEnabled - ) + ) -$ll=$ctx.Web.Lists.GetByTitle($ListName) + $ll=$ctx.Web.Lists.GetByTitle($ListName) -$ll.ContentTypesEnabled = $ContentTypesEnabled - $ll.Update() - - try - { - $ctx.ExecuteQuery() - Write-Host "Done" -ForegroundColor Green - } - - catch [Net.WebException] - { - - Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red - } - + $ll.ContentTypesEnabled = $ContentTypesEnabled + $ll.Update() + try{ + $ctx.ExecuteQuery() + Write-Host "Done" -ForegroundColor Green + } + catch [Net.WebException]{ + Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + } } - - - -function Connect-SPOCSOM -{ - param ( - [Parameter(Mandatory=$true,Position=1)] +function Connect-SPOCSOM{ + param( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] [string]$Url -) + ) - -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.ExecuteQuery() -$global:ctx=$ctx + $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.ExecuteQuery() + $global:ctx=$ctx } - $global:ctx @@ -77,4 +64,4 @@ $ContentTypesEnabled =$false Connect-SPOCSOM -Username $Username -AdminPassword $AdminPassword -Url $Url -Set-SPOList -ListName $ListName -ContentTypesEnabled $ContentTypesEnabled \ No newline at end of file +Set-SPOList -ListName $ListName -ContentTypesEnabled $ContentTypesEnabled diff --git a/Content Types/Create/Add Content Type to Lists with Workflows/AddContentTypetoListsWithWorkflows.ps1 b/Content Types/Create/Add Content Type to Lists with Workflows/AddContentTypetoListsWithWorkflows.ps1 index 503a5f26..c3693164 100644 --- a/Content Types/Create/Add Content Type to Lists with Workflows/AddContentTypetoListsWithWorkflows.ps1 +++ b/Content Types/Create/Add Content Type to Lists with Workflows/AddContentTypetoListsWithWorkflows.ps1 @@ -1,61 +1,51 @@ -function New-SPOContentType -{ -param( -[Parameter(Mandatory=$true,Position=1)] +function New-SPOContentType{ + param( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url, -[Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string]$Description, -[Parameter(Mandatory=$true,Position=5)] + [Parameter(Mandatory=$true,Position=5)] [string]$Name, -[Parameter(Mandatory=$true,Position=6)] + [Parameter(Mandatory=$true,Position=6)] [string]$Group, -[Parameter(Mandatory=$true,Position=7)] + [Parameter(Mandatory=$true,Position=7)] [string]$ParentContentTypeID + ) - ) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ctx.Load($ctx.Web.Lists) - $ctx.ExecuteQuery() + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.Load($ctx.Web.Lists) + $ctx.ExecuteQuery() - - $lci =New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation - $lci.Description=$Description - $lci.Name=$Name - #$lci.ID="0x0100aa862727aed04408b2599b25356e7000" - $lci.ParentContentType=$ctx.Web.ContentTypes.GetById($ParentContentTypeID) - $lci.Group=$Group - - foreach($ll in $ctx.Web.Lists) - { - $ctx.Load($ll.WorkflowAssociations) - $ctx.ExecuteQuery() + $lci =New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation + $lci.Description=$Description + $lci.Name=$Name + #$lci.ID="0x0100aa862727aed04408b2599b25356e7000" + $lci.ParentContentType=$ctx.Web.ContentTypes.GetById($ParentContentTypeID) + $lci.Group=$Group - if($ll.WorkflowAssociations.Count -gt 0) - { - $ContentType = $ll.ContentTypes.Add($lci) - $ctx.Load($contentType) - try - { - - $ctx.ExecuteQuery() - Write-Host "Adding content type " $Name " to " $ll.Title - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } + foreach($ll in $ctx.Web.Lists){ + $ctx.Load($ll.WorkflowAssociations) + $ctx.ExecuteQuery() - - } - } + if($ll.WorkflowAssociations.Count -gt 0){ + $ContentType = $ll.ContentTypes.Add($lci) + $ctx.Load($contentType) + try{ + $ctx.ExecuteQuery() + Write-Host "Adding content type " $Name " to " $ll.Title + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } + } + } } @@ -75,4 +65,4 @@ $Group="List Content Types" -New-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -Description $Description -Name $Name -Group $Group -ParentContentTypeID $ParentContentTypeID \ No newline at end of file +New-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -Description $Description -Name $Name -Group $Group -ParentContentTypeID $ParentContentTypeID diff --git a/Content Types/Create/Add Content Type to Lists with Workflows/description.md b/Content Types/Create/Add Content Type to Lists with Workflows/description.md index 29aee1dd..b97da707 100644 --- a/Content Types/Create/Add Content Type to Lists with Workflows/description.md +++ b/Content Types/Create/Add Content Type to Lists with Workflows/description.md @@ -9,11 +9,9 @@ http://social.technet.microsoft.com/wiki/contents/articles/31051.sharepoint-onli ### How to use? +1. Download and install [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038). - -1. Download and install SharePoint Online SDK. - -2. Download the .ps1 file. +2. Download the *.ps1* file. 3. Open the file (you can do it also in NotePad) @@ -33,15 +31,14 @@ $Name="Name of the Content Type2" $ParentContentTypeID="0x01" $Group="List Content Types" ``` -a) Find on your computer where SharePoint.Clitent.dll and SharePoint.Client.Runtime.dll libraries are located and insert the correct paths -b) Instead of "admin@tenant.onmicrosoft.com" enter you username -c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter the name of the site collection where you want to find the content types -d) Fill in the properties of the content type. +a) Find on your computer where SharePoint.Clitent.dll and SharePoint.Client.Runtime.dll libraries are located and insert the correct paths
+b) Instead of "admin@tenant.onmicrosoft.com" enter you username
+c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter the name of the site collection where you want to find the content types
+d) Fill in the properties of the content type.
- 5. Run the script in Powershell (any module). -6. When the script has executed, Powershell will show a message Content Type Name of the Content Type2 has been added to Title of the List. +6. When the script has executed, Powershell will show a message *Content Type Name of the Content Type2 has been added to Title of the List*.

Enjoy and please share feedback! diff --git a/Content Types/Create/Add Content Type to Task Lists/description.md b/Content Types/Create/Add Content Type to Task Lists/description.md index 5b9a24e8..23db2c0a 100644 --- a/Content Types/Create/Add Content Type to Task Lists/description.md +++ b/Content Types/Create/Add Content Type to Task Lists/description.md @@ -11,9 +11,9 @@ http://social.technet.microsoft.com/wiki/contents/articles/31051.sharepoint-onli -1. Download and install SharePoint Online SDK. +1. Download and install [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038). -2. Download the .ps1 file. +2. Download the *.ps1* file. 3. Open the file (you can do it also in NotePad) @@ -33,15 +33,14 @@ $Name="Name of the Content Type2" $ParentContentTypeID="0x01" $Group="List Content Types" ``` -a) Find on your computer where SharePoint.Clitent.dll and SharePoint.Client.Runtime.dll libraries are located and insert the correct paths -b) Instead of "admin@tenant.onmicrosoft.com" enter you username -c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter the name of the site collection where you want to find the content types -d) Fill in the properties of the content type. +a) Find on your computer where SharePoint.Clitent.dll and SharePoint.Client.Runtime.dll libraries are located and insert the correct paths
+b) Instead of "admin@tenant.onmicrosoft.com" enter you username
+c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter the name of the site collection where you want to find the content types
+d) Fill in the properties of the content type.
- 5. Run the script in Powershell (any module). -6. When the script has executed, Powershell will show a message Content Type Name of the Content Type2 has been added to Title of the List. +6. When the script has executed, Powershell will show a message *Content Type Name of the Content Type2 has been added to Title of the List*. diff --git a/Content Types/Create/Create a content type/description.md b/Content Types/Create/Create a content type/description.md index b80d4a22..d07b7ff8 100644 --- a/Content Types/Create/Create a content type/description.md +++ b/Content Types/Create/Create a content type/description.md @@ -1,26 +1,14 @@ A short script to create a content type. -The script is fully described in an article here: - -http://social.technet.microsoft.com/wiki/contents/articles/31051.sharepoint-online-content-types-in-powershell.aspx - - - - - - - - - - +The script is fully described in an article [here](http://social.technet.microsoft.com/wiki/contents/articles/31051.sharepoint-online-content-types-in-powershell.aspx). ### How to use? -1. Download and install SharePoint Online SDK. +1. Download and install [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038). -2. Download the .ps1 file. +2. Download the *.ps1* file. 3. Open the file (you can do it also in NotePad) @@ -40,14 +28,14 @@ $ParentContentTypeID="0x01" $Group="List Content Types" ``` -a) Find on your computer where SharePoint.Clitent.dll and SharePoint.Client.Runtime.dll libraries are located and insert the correct paths -b) Instead of "admin@tenant.onmicrosoft.com" enter you username -c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter the name of the site collection where you want to find the content types -d) Fill in the properties of the content type. +a) Find on your computer where SharePoint.Clitent.dll and SharePoint.Client.Runtime.dll libraries are located and insert the correct paths
+b) Instead of "admin@tenant.onmicrosoft.com" enter you username
+c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter the name of the site collection where you want to find the content types
+d) Fill in the properties of the content type.
5. Run the script in Powershell (any module). -6. When the script has executed, Powershell will show a message Content Type Name of the Content Type2 has been added to Url of the Site. +6. When the script has executed, Powershell will show a message *Content Type Name of the Content Type2 has been added to Url of the Site*. diff --git a/Content Types/Display Forms/Modify the Display Form Template Name/ModifyDisplayFormTemplateName.ps1 b/Content Types/Display Forms/Modify the Display Form Template Name/ModifyDisplayFormTemplateName.ps1 index f8f61ca4..083555b7 100644 --- a/Content Types/Display Forms/Modify the Display Form Template Name/ModifyDisplayFormTemplateName.ps1 +++ b/Content Types/Display Forms/Modify the Display Form Template Name/ModifyDisplayFormTemplateName.ps1 @@ -1,34 +1,31 @@ -function Set-SPOContentType -{ - param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SPOContentType{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string]$ListTitle - ) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ll=$ctx.Web.Lists.GetByTitle($ListTitle) - $ctx.Load($ll) - $ctx.Load($ll.ContentTypes) - $ctx.ExecuteQuery() - - - foreach($cc in $ll.ContentTypes) - { - Write-Host $cc.DisplayFormTemplateName - $cc.DisplayFormTemplateName="DocumentLibraryForm" - $cc.Update($false) - $ctx.ExecuteQuery() - } - - $ctx.Dispose() - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ll=$ctx.Web.Lists.GetByTitle($ListTitle) + $ctx.Load($ll) + $ctx.Load($ll.ContentTypes) + $ctx.ExecuteQuery() + + + foreach($cc in $ll.ContentTypes){ + Write-Host $cc.DisplayFormTemplateName + $cc.DisplayFormTemplateName="DocumentLibraryForm" + $cc.Update($false) + $ctx.ExecuteQuery() + } + + $ctx.Dispose() } diff --git a/Content Types/Get/Find content types added to your lists/checkallcontenttypes.ps1 b/Content Types/Get/Find content types added to your lists/checkallcontenttypes.ps1 index ff953eda..d2803259 100644 --- a/Content Types/Get/Find content types added to your lists/checkallcontenttypes.ps1 +++ b/Content Types/Get/Find content types added to your lists/checkallcontenttypes.ps1 @@ -1,68 +1,43 @@  -function Get-SPOList -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOList{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url - ) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ctx.ExecuteQuery() - - $ctx.Load($ctx.Web.Lists) - $ctx.ExecuteQuery() - Write-Host - Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - foreach( $ll in $ctx.Web.Lists) - { - - $ctx.Load($ll.RootFolder) - $ctx.Load($ll.DefaultView) - $ctx.Load($ll.Views) - $ctx.Load($ll.WorkflowAssociations) - $ctx.Load($ll.ContentTypes) - - try - { - $ctx.ExecuteQuery() - } - catch - { - } - - - - - Write-Host $ll.Title -ForegroundColor Green - - foreach($cc in $ll.ContentTypes) - { - Write-Host $cc.Name - } - - - - - - - } - - - - } - - - - - - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.ExecuteQuery() + + $ctx.Load($ctx.Web.Lists) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + + foreach( $ll in $ctx.Web.Lists){ + $ctx.Load($ll.RootFolder) + $ctx.Load($ll.DefaultView) + $ctx.Load($ll.Views) + $ctx.Load($ll.WorkflowAssociations) + $ctx.Load($ll.ContentTypes) + + try{ + $ctx.ExecuteQuery() + } + catch{} + + Write-Host $ll.Title -ForegroundColor Green + + foreach($cc in $ll.ContentTypes){ + Write-Host $cc.Name + } + } +} # Paths to SDK. Please verify location on your computer. diff --git a/Content Types/Get/Get All Detailed Properties of All Content Types/ContentTypesWithoutPSObject.ps1 b/Content Types/Get/Get All Detailed Properties of All Content Types/ContentTypesWithoutPSObject.ps1 index a21b170e..d8eea6bc 100644 --- a/Content Types/Get/Get All Detailed Properties of All Content Types/ContentTypesWithoutPSObject.ps1 +++ b/Content Types/Get/Get All Detailed Properties of All Content Types/ContentTypesWithoutPSObject.ps1 @@ -1,74 +1,51 @@  -function Get-SPOContentType -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOContentType{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url - ) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ctx.ExecuteQuery() - - $ctx.Load($ctx.Web) - $ctx.Load($ctx.Web.ContentTypes) - $ctx.ExecuteQuery() - Write-Host - Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - foreach( $cc in $ctx.Web.ContentTypes) - { - - - $ctx.Load($cc) - $ctx.Load($cc.FieldLinks) - $ctx.Load($cc.Fields) - $ctx.Load($cc.WorkflowAssociations) - $ctx.ExecuteQuery() - $cc | Add-Member NoteProperty Web($url) - foreach($field in $cc.Fields) - { - $PropertyName="Field"+$field.ID - $cc | Add-Member NoteProperty $PropertyName($field.Title) - } - foreach($fieldlink in $cc.FieldLinks) - { - $PropertyName="Fieldlink"+$fieldlink.ID - $cc | Add-Member NoteProperty $PropertyName($fieldlink.Name) - } - foreach($workflow in $cc.WorkflowAssociations) - { - $PropertyName="Workflow"+$workflow.ID - $cc | Add-Member NoteProperty $PropertyName($workflow.Name) - } - Write-Output $cc - } - - - - - - - } - - - - - - - - - - - - - - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.ExecuteQuery() + + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Web.ContentTypes) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + + foreach( $cc in $ctx.Web.ContentTypes){ + $ctx.Load($cc) + $ctx.Load($cc.FieldLinks) + $ctx.Load($cc.Fields) + $ctx.Load($cc.WorkflowAssociations) + $ctx.ExecuteQuery() + $cc | Add-Member NoteProperty Web($url) + + foreach($field in $cc.Fields){ + $PropertyName="Field"+$field.ID + $cc | Add-Member NoteProperty $PropertyName($field.Title) + } + + foreach($fieldlink in $cc.FieldLinks){ + $PropertyName="Fieldlink"+$fieldlink.ID + $cc | Add-Member NoteProperty $PropertyName($fieldlink.Name) + } + + foreach($workflow in $cc.WorkflowAssociations){ + $PropertyName="Workflow"+$workflow.ID + $cc | Add-Member NoteProperty $PropertyName($workflow.Name) + } + + Write-Output $cc + } +} # Paths to SDK. Please verify location on your computer. @@ -82,4 +59,4 @@ $AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" -Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl \ No newline at end of file +Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl diff --git a/Content Types/Get/Get All Properties of All Content Types in All Lists (Detailed) across one site/GetContentTypeProperties.ps1 b/Content Types/Get/Get All Properties of All Content Types in All Lists (Detailed) across one site/GetContentTypeProperties.ps1 index 3cd8768f..33b0ee07 100644 --- a/Content Types/Get/Get All Properties of All Content Types in All Lists (Detailed) across one site/GetContentTypeProperties.ps1 +++ b/Content Types/Get/Get All Properties of All Content Types in All Lists (Detailed) across one site/GetContentTypeProperties.ps1 @@ -1,126 +1,94 @@  -function Get-SPOContentType -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOContentType{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url - ) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ctx.ExecuteQuery() - - $ctx.Load($ctx.Web.Lists) - $ctx.Load($ctx.Web.Webs) - $ctx.ExecuteQuery() - Write-Host - Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - foreach( $ll in $ctx.Web.Lists) - { - - $ctx.Load($ll.ContentTypes) - - try - { - $ctx.ExecuteQuery() - } - catch - { - } - - Write-Host $ll.Title - - - - - foreach($cc in $ll.ContentTypes) - { - $ctx.Load($cc) - $ctx.Load($cc.FieldLinks) - $ctx.Load($cc.Fields) - $ctx.Load($cc.WorkflowAssociations) - $ctx.ExecuteQuery() - $obj = New-Object PSObject - $obj | Add-Member NoteProperty Title($cc.Name) - $obj | Add-Member NoteProperty List($ll.Title) - $obj | Add-Member NoteProperty Web($url) - $obj | Add-Member NoteProperty Description($cc.Description) - $obj | Add-Member NoteProperty DisplayFormTemplateName($cc.DisplayFormTemplateName) - $obj | Add-Member NoteProperty DisplayFormUrl($cc.DisplayFormUrl) - $obj | Add-Member NoteProperty DocumentTemplate($cc.DocumentTemplate) - $obj | Add-Member NoteProperty DocumentTemplateUrl($cc.DocumentTemplateUrl) - $obj | Add-Member NoteProperty EditFormTemplateName($cc.EditFormTemplateName) - $obj | Add-Member NoteProperty EditFormUrl($cc.EditFormUrl) - - foreach($field in $cc.Fields) - { - $PropertyName="Field"+$field.ID - $obj | Add-Member NoteProperty $PropertyName($field.Title) - } - foreach($fieldlink in $cc.FieldLinks) - { - $PropertyName="Fieldlink"+$fieldlink.ID - $obj | Add-Member NoteProperty $PropertyName($fieldlink.Name) - } - - $obj | Add-Member NoteProperty Group($cc.Group) - $obj | Add-Member NoteProperty Hidden($cc.Hidden) - $obj | Add-Member NoteProperty ID($cc.ID) - $obj | Add-Member NoteProperty JSLink($cc.JSLink) - $obj | Add-Member NoteProperty NewFormTemplateName($cc.NewFormTemplateName) - $obj | Add-Member NoteProperty NewFormUrl($cc.NewFormUrl) - $obj | Add-Member NoteProperty Parent($cc.Parent) - $obj | Add-Member NoteProperty ReadOnly($cc.ReadOnly) - $obj | Add-Member NoteProperty SchemaXML($cc.SchemaXML) - $obj | Add-Member NoteProperty SchemaXmlWithResourceTokens($cc.SchemaXmlWithResourceTokens) - $obj | Add-Member NoteProperty Scope($cc.Scope) - $obj | Add-Member NoteProperty Sealed($cc.Sealed) - $obj | Add-Member NoteProperty ServerObjectIsNull($cc.ServerObjectIsNull) - $obj | Add-Member NoteProperty StringID($cc.StringID) - $obj | Add-Member NoteProperty Tag($cc.Tag) - $obj | Add-Member NoteProperty TypedObject($cc.TypedObject) - - foreach($workflow in $cc.WorkflowAssociations) - { - $PropertyName="Workflow"+$workflow.ID - $obj | Add-Member NoteProperty $PropertyName($workflow.Name) - } - - Write-Output $obj - } - - - - - - - } - - - - if($ctx.Web.Webs.Count -gt 0) - { - foreach ($web in $ctx.Web.Webs) - { - Get-SPOContentType -Username $Username -Url $web.Url -AdminPassword $AdminPassword - } - } - - - - } - - - - - - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.ExecuteQuery() + + $ctx.Load($ctx.Web.Lists) + $ctx.Load($ctx.Web.Webs) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + foreach( $ll in $ctx.Web.Lists){ + $ctx.Load($ll.ContentTypes) + + try{ + $ctx.ExecuteQuery() + } + catch{} + + Write-Host $ll.Title + + foreach($cc in $ll.ContentTypes){ + $ctx.Load($cc) + $ctx.Load($cc.FieldLinks) + $ctx.Load($cc.Fields) + $ctx.Load($cc.WorkflowAssociations) + $ctx.ExecuteQuery() + $obj = New-Object PSObject + $obj | Add-Member NoteProperty Title($cc.Name) + $obj | Add-Member NoteProperty List($ll.Title) + $obj | Add-Member NoteProperty Web($url) + $obj | Add-Member NoteProperty Description($cc.Description) + $obj | Add-Member NoteProperty DisplayFormTemplateName($cc.DisplayFormTemplateName) + $obj | Add-Member NoteProperty DisplayFormUrl($cc.DisplayFormUrl) + $obj | Add-Member NoteProperty DocumentTemplate($cc.DocumentTemplate) + $obj | Add-Member NoteProperty DocumentTemplateUrl($cc.DocumentTemplateUrl) + $obj | Add-Member NoteProperty EditFormTemplateName($cc.EditFormTemplateName) + $obj | Add-Member NoteProperty EditFormUrl($cc.EditFormUrl) + + foreach($field in $cc.Fields){ + $PropertyName="Field"+$field.ID + $obj | Add-Member NoteProperty $PropertyName($field.Title) + } + + foreach($fieldlink in $cc.FieldLinks){ + $PropertyName="Fieldlink"+$fieldlink.ID + $obj | Add-Member NoteProperty $PropertyName($fieldlink.Name) + } + + $obj | Add-Member NoteProperty Group($cc.Group) + $obj | Add-Member NoteProperty Hidden($cc.Hidden) + $obj | Add-Member NoteProperty ID($cc.ID) + $obj | Add-Member NoteProperty JSLink($cc.JSLink) + $obj | Add-Member NoteProperty NewFormTemplateName($cc.NewFormTemplateName) + $obj | Add-Member NoteProperty NewFormUrl($cc.NewFormUrl) + $obj | Add-Member NoteProperty Parent($cc.Parent) + $obj | Add-Member NoteProperty ReadOnly($cc.ReadOnly) + $obj | Add-Member NoteProperty SchemaXML($cc.SchemaXML) + $obj | Add-Member NoteProperty SchemaXmlWithResourceTokens($cc.SchemaXmlWithResourceTokens) + $obj | Add-Member NoteProperty Scope($cc.Scope) + $obj | Add-Member NoteProperty Sealed($cc.Sealed) + $obj | Add-Member NoteProperty ServerObjectIsNull($cc.ServerObjectIsNull) + $obj | Add-Member NoteProperty StringID($cc.StringID) + $obj | Add-Member NoteProperty Tag($cc.Tag) + $obj | Add-Member NoteProperty TypedObject($cc.TypedObject) + + foreach($workflow in $cc.WorkflowAssociations){ + $PropertyName="Workflow"+$workflow.ID + $obj | Add-Member NoteProperty $PropertyName($workflow.Name) + } + + Write-Output $obj + } + } + + if($ctx.Web.Webs.Count -gt 0){ + foreach ($web in $ctx.Web.Webs){ + Get-SPOContentType -Username $Username -Url $web.Url -AdminPassword $AdminPassword + } + } +} # Paths to SDK. Please verify location on your computer. @@ -134,4 +102,4 @@ $AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" -Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl \ No newline at end of file +Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl diff --git a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 index d5c99a27..45c10140 100644 --- a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 +++ b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 @@ -1,64 +1,41 @@ - - -function Get-SPOList -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOList{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url - ) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ctx.ExecuteQuery() - - $ctx.Load($ctx.Web.Lists) - $ctx.ExecuteQuery() - Write-Host - Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - foreach( $ll in $ctx.Web.Lists) - { + ) - $ctx.Load($ll.ContentTypes) + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.ExecuteQuery() - try - { - $ctx.ExecuteQuery() - } - catch - { - } + $ctx.Load($ctx.Web.Lists) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + foreach( $ll in $ctx.Web.Lists){ + $ctx.Load($ll.ContentTypes) - + try{ + $ctx.ExecuteQuery() + } + catch{ + } - Write-Host $ll.Title -ForegroundColor Green - - foreach($cc in $ll.ContentTypes) - { - Write-Output $cc.Name - } + Write-Host $ll.Title -ForegroundColor Green - - + foreach($cc in $ll.ContentTypes){ + Write-Output $cc.Name + } - - - } - - - - } - - - - - + } +} + # Paths to SDK. Please verify location on your computer. @@ -71,4 +48,4 @@ $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" -Get-SPOList -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl \ No newline at end of file +Get-SPOList -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl diff --git a/Items Management/Attachments/Copy list attachments to a separate library/CopyAttachments.ps1 b/Items Management/Attachments/Copy list attachments to a separate library/CopyAttachments.ps1 index b0d2db7d..d1ebfc5d 100644 --- a/Items Management/Attachments/Copy list attachments to a separate library/CopyAttachments.ps1 +++ b/Items Management/Attachments/Copy list attachments to a separate library/CopyAttachments.ps1 @@ -1,19 +1,15 @@ -function Get-SPOListFields -{ - -<# - .link - http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx - - #> - - - param ( - [Parameter(Mandatory=$true,Position=3)] - [string]$ListTitle, - [Parameter(Mandatory=$false,Position=4)] - [bool]$IncludeSubsites=$false - ) +function Get-SPOListFields{ + <# + .link + http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx + #> + + param ( + [Parameter(Mandatory=$true,Position=3)] + [string]$ListTitle, + [Parameter(Mandatory=$false,Position=4)] + [bool]$IncludeSubsites=$false + ) $ll=$ctx.Web.Lists.GetByTitle($ListTitle) $ctx.Load($ll) @@ -23,51 +19,48 @@ function Get-SPOListFields $fieldsArray=@() $fieldslist=@() - foreach ($fiel in $ll.Fields) - { - #Write-Host $fiel.Description `t $fiel.EntityPropertyName `t $fiel.Id `t $fiel.InternalName `t $fiel.StaticName `t $fiel.Tag `t $fiel.Title `t $fiel.TypeDisplayName + + foreach ($fiel in $ll.Fields){ + #Write-Host $fiel.Description `t $fiel.EntityPropertyName `t $fiel.Id `t $fiel.InternalName `t $fiel.StaticName `t $fiel.Tag `t $fiel.Title `t $fiel.TypeDisplayName - $array=@() - $array+="InternalName" + $array=@() + $array+="InternalName" $array+="StaticName" - $array+="Title" + $array+="Title" - $obj = New-Object PSObject - $obj | Add-Member NoteProperty $array[0]($fiel.InternalName) - $obj | Add-Member NoteProperty $array[1]($fiel.StaticName) - $obj | Add-Member NoteProperty $array[2]($fiel.Title) + $obj = New-Object PSObject + $obj | Add-Member NoteProperty $array[0]($fiel.InternalName) + $obj | Add-Member NoteProperty $array[1]($fiel.StaticName) + $obj | Add-Member NoteProperty $array[2]($fiel.Title) - $fieldsArray+=$obj - $fieldslist+=$fiel.InternalName - Write-Output $obj - } + $fieldsArray+=$obj + $fieldslist+=$fiel.InternalName + Write-Output $obj + } - - $ctx.Dispose() + $ctx.Dispose() + return $fieldsArray - } -function Get-SPOListItems -{ +function Get-SPOListItems{ <# .link http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx - #> - param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$ListTitle, - [Parameter(Mandatory=$false,Position=2)] - [bool]$IncludeAllProperties=$false, - [switch]$Recursive, - [Parameter(Mandatory=$false,Position=4)] - $DestinationLibrary, - [Parameter(Mandatory=$false,Position=5)] - [bool]$Overwrite - ) + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$ListTitle, + [Parameter(Mandatory=$false,Position=2)] + [bool]$IncludeAllProperties=$false, + [switch]$Recursive, + [Parameter(Mandatory=$false,Position=4)] + $DestinationLibrary, + [Parameter(Mandatory=$false,Position=5)] + [bool]$Overwrite + ) $ll=$ctx.Web.Lists.GetByTitle($ListTitle) @@ -76,90 +69,75 @@ function Get-SPOListItems $ctx.ExecuteQuery() $i=0 + $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + # $spqQuery.ViewAttributes = "Scope='Recursive'" + $spqQuery.ViewXml = "1"; - - $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -# $spqQuery.ViewAttributes = "Scope='Recursive'" -$spqQuery.ViewXml = "1"; -if($Recursive) -{ -$spqQuery.ViewXml +=""; -} - $bobo=Get-SPOListFields -ListTitle $ListTitle + if($Recursive){ + $spqQuery.ViewXml +=""; + } + + $bobo=Get-SPOListFields -ListTitle $ListTitle $itemki=$ll.GetItems($spqQuery) $ctx.Load($itemki) $ctx.ExecuteQuery() - - $objArray=@() - for($j=0;$j -lt $itemki.Count ;$j++) - { + for($j=0;$j -lt $itemki.Count ;$j++){ $attache=$itemki[$j].AttachmentFiles $ctx.Load($attache) $ctx.ExecuteQuery() Write-Host $itemki[$j]["Title"] -BackgroundColor DarkCyan - foreach($att in $attache) - { + + foreach($att in $attache){ #Write-Output $att $file = - $ctx.Web.GetFileByServerRelativeUrl($att.ServerRelativeUrl); - $ctx.Load($file) - $ctx.ExecuteQuery() + $ctx.Web.GetFileByServerRelativeUrl($att.ServerRelativeUrl); + $ctx.Load($file) + $ctx.ExecuteQuery() $NewName=$file.Name - - if($DestinationLibrary.EndsWith("/")){} - else {$DestinationLibrary=$DestinationLibrary+"/"} - Write-Host "Processing " $file.Name -$file.CopyTo($DestinationLibrary+$NewName, $Overwrite) - try - { - $ctx.ExecuteQuery() + if($DestinationLibrary.EndsWith("/")){} + else {$DestinationLibrary=$DestinationLibrary+"/"} - Write-Host $file.Name " has been copied to" $DestinationLibrary -ForegroundColor DarkGreen - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } + Write-Host "Processing " $file.Name + $file.CopyTo($DestinationLibrary+$NewName, $Overwrite) + + try{ + $ctx.ExecuteQuery() + Write-Host $file.Name " has been copied to" $DestinationLibrary -ForegroundColor DarkGreen + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } } - - } +} - } - - - function Connect-SPOCSOM -{ - -<# - .link - http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx - +function Connect-SPOCSOM{ + <# + .link + http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx #> - param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=3)] - [string]$Url - - -) - - $password = Read-Host "Password" -AsSecureString - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.ExecuteQuery() -$global:ctx=$ctx + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=3)] + [string]$Url + ) + + $password = Read-Host "Password" -AsSecureString + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.ExecuteQuery() + $global:ctx=$ctx } diff --git a/Items Management/Attachments/Copy list attachments to a separate library/description.md b/Items Management/Attachments/Copy list attachments to a separate library/description.md index dce9a8ba..c9e497d5 100644 --- a/Items Management/Attachments/Copy list attachments to a separate library/description.md +++ b/Items Management/Attachments/Copy list attachments to a separate library/description.md @@ -1,37 +1,26 @@ -Description +# Description The following script copies list attachments to another library within the same site. - - -Scenario: +# Scenario: - List with attachments: - - - + sometimes several attachments per item: - - - + The attachments are to be copied to another library: + - - - -Requirements +# Requirements The script requires SharePoint Online SDK. - - -How to use? +# How to use? 1. Download and open the file. 2. Enter correct paths to the SDK: @@ -52,4 +41,8 @@ Connect-SPOCSOM -Username "user@tenant.onmicrosoft.com" -Url "https://tenant.sha

-Enjoy and please share feedback! \ No newline at end of file + +Enjoy and please share feedback! + +Enjoy and please share feedback! + diff --git a/Items Management/Attachments/Disable or enable attachments to list items/AttachmentsForAllLists.ps1 b/Items Management/Attachments/Disable or enable attachments to list items/AttachmentsForAllLists.ps1 index a08647c4..007c6cc6 100644 --- a/Items Management/Attachments/Disable or enable attachments to list items/AttachmentsForAllLists.ps1 +++ b/Items Management/Attachments/Disable or enable attachments to list items/AttachmentsForAllLists.ps1 @@ -1,49 +1,41 @@ - + # # Created by Arleta Wanat, 2015 # -function Set-SPOListsAttachments -{ -param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$AdminPassword, +function Set-SPOListsAttachments{ + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=3)] - [string]$Url, + [string]$Url, [Parameter(Mandatory=$true,Position=4)] - [bool]$Attachments -) + [bool]$Attachments + ) -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) $ctx.ExecuteQuery() -$Lists=$ctx.Web.Lists -$ctx.Load($Lists) -$ctx.ExecuteQuery() - -Foreach($ll in $Lists) -{ - $ll.EnableAttachments = $Attachments - $ll.Update() - - - try - { - $ctx.ExecuteQuery() - Write-Host $ll.Title " Done" -ForegroundColor Green - } - - catch [Net.WebException] - { - - Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + $Lists=$ctx.Web.Lists + $ctx.Load($Lists) + $ctx.ExecuteQuery() + + Foreach($ll in $Lists){ + $ll.EnableAttachments = $Attachments + $ll.Update() + + try{ + $ctx.ExecuteQuery() + Write-Host $ll.Title " Done" -ForegroundColor Green } - -} + catch [Net.WebException] { + Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + } + } } @@ -68,4 +60,4 @@ $Attachments=$false -Set-SPOListsAttachments -Username $Username -AdminPassword $AdminPassword -Url $Url -Attachments $Attachments \ No newline at end of file +Set-SPOListsAttachments -Username $Username -AdminPassword $AdminPassword -Url $Url -Attachments $Attachments diff --git a/Items Management/Attachments/Disable or enable attachments to list items/description.md b/Items Management/Attachments/Disable or enable attachments to list items/description.md index 48cab2ef..6e93a62e 100644 --- a/Items Management/Attachments/Disable or enable attachments to list items/description.md +++ b/Items Management/Attachments/Disable or enable attachments to list items/description.md @@ -1,15 +1,20 @@ -Want to keep your lists tidy? Saving space?? This is a solution for you! Looking for a quick way to restore the option for all lists? This is also a solution for you! :) +Want to keep your lists tidy? Saving space?? This is a solution for you! Looking for a quick way to restore the option for all lists? +
**This is also a solution for you! :)** Want to keep your lists tidy? Saving space? Do you want to prevent users from adding unnecessary attachments to the list because their place belongs elsewhere? This is a solution for you! Or maybe you already disabled the feature? For some of the lists - for some not, and now you are looking for a quick way to restore the option for all lists? + This is also a solution for you! :) + +
**This is also a solution for you! :)** + ```Powershell # Paths to SDK. Please verify location on your computer. @@ -29,16 +34,16 @@ Set-SPOListsAttachments -Username $Username -AdminPassword $AdminPassword -Url $ ``` -For full description please refer here to the Wiki Article +For full description please refer here to the [Wiki Article](https://social.technet.microsoft.com/wiki/contents/articles/30024.sharepoint-online-disable-or-enable-attachments-to-list-items-using-powershell.aspx)

Enjoy and please share feedback! -Related scripts -Set direction of the reading order for a single list +**Related scripts**
+[Set direction of the reading order for a single list](https://gallery.technet.microsoft.com/office/Set-the-direction-of-the-f17ca66a) -Set-SPOList properties (module) +[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) -Allow or disallow your users to create folders in SPO lists +[Allow or disallow your users to create folders in SPO lists](https://gallery.technet.microsoft.com/scriptcenter/Allow-or-disallow-your-20f7b44a) diff --git a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 index 275e2759..874aabc2 100644 --- a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 +++ b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 @@ -1,57 +1,49 @@ - + # # Created by Arleta Wanat, 2015 # -function Set-SPOList -{ -param ( +function Set-SPOList{ + param ( [Parameter(Mandatory=$true,Position=0)] - [string]$ListName, + [string]$ListName, [Parameter(Mandatory=$true,Position=1)] - [bool]$Attachments - ) + [bool]$Attachments + ) -$ll=$ctx.Web.Lists.GetByTitle($ListName) + $ll=$ctx.Web.Lists.GetByTitle($ListName) -$ll.EnableAttachments = $Attachments - $ll.Update() + $ll.EnableAttachments = $Attachments + $ll.Update() - try - { + try{ $ctx.ExecuteQuery() Write-Host "Done" -ForegroundColor Green - } - - catch [Net.WebException] - { - - Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red - } - - + } + catch [Net.WebException] { + Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + } } -function Connect-SPOCSOM -{ - param ( - [Parameter(Mandatory=$true,Position=1)] +function Connect-SPOCSOM{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$AdminPassword, [Parameter(Mandatory=$true,Position=2)] [string]$Url -) + ) -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) $ctx.ExecuteQuery() -$global:ctx=$ctx + $global:ctx=$ctx } @@ -78,4 +70,4 @@ $Attachments =$true Connect-SPOCSOM -Username $Username -AdminPassword $AdminPassword -Url $Url -Set-SPOList -ListName $ListName -Attachments $Attachments \ No newline at end of file +Set-SPOList -ListName $ListName -Attachments $Attachments diff --git a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md index e17f799d..ae4331ff 100644 --- a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md +++ b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md @@ -1,22 +1,10 @@ -A short Powershell script to set the EnableAttachments property for a SharePoint Online list. The property is responsible for the Attach File icon under new item tab. If you disable the button, you and your users will not be able to add the attachments to list items. +A short Powershell script to set the EnableAttachments property for a SharePoint Online list. The property is responsible for the **Attach File** icon under **new item** tab. If you disable the button, you and your users will not be able to add the attachments to list items. -A short Powershell script to set the EnableAttachments property for a SharePoint Online list. The property is responsible for the Attach File icon under new item tab (see screenshot). The button allows you to add attachments to the list item. - - - - - - - - + If you disable the button, you and your users will not be able to add the attachments to list items: - - - - - + Applies to lists. @@ -24,7 +12,7 @@ Applies to lists. -It requires installed SharePoint Online SDK +It requires installed [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038) You have to enter the list information before running the script: @@ -45,18 +33,14 @@ $ListName="Tasks list" $Attachments =$false ``` -### Related scripts -Set direction of the reading order for a single list +## **Related scripts** +[Set direction of the reading order for a single list](https://gallery.technet.microsoft.com/office/Set-the-direction-of-the-f17ca66a) -Set-SPOList properties (module) - - - - +[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) -### Related article +## **Related article** -SharePoint Online: Disable or enable attachments to list items using Powershell +[SharePoint Online: Disable or enable attachments to list items using Powershell](https://social.technet.microsoft.com/wiki/contents/articles/30024.sharepoint-online-disable-or-enable-attachments-to-list-items-using-powershell.aspx)

diff --git a/Lists and Libraries Management/Delete unique permissions in all items in a large list (5000+ items)/ResetPermissionInheritanceLargeLists.ps1 b/Lists and Libraries Management/Delete unique permissions in all items in a large list (5000+ items)/ResetPermissionInheritanceLargeLists.ps1 new file mode 100644 index 00000000..da8f3d5b --- /dev/null +++ b/Lists and Libraries Management/Delete unique permissions in all items in a large list (5000+ items)/ResetPermissionInheritanceLargeLists.ps1 @@ -0,0 +1,93 @@ +function Restore-SPOListAllItemsInheritance +{ + + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + [SecureString]$AdminPassword, + [Parameter(Mandatory=$true,Position=4)] + [string]$ListTitle + ) + + + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.Load($ctx.Web.Lists) + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Web.Webs) + $ctx.ExecuteQuery() + $ll=$ctx.Web.Lists.GetByTitle($ListTitle) + $ctx.Load($ll) + $ctx.ExecuteQuery() + + ## View XML +$qCommand = @" + + + + + 5000 + +"@ +## Page Position +$position = $null + +## All Items +$allItems = @() +Do{ + $camlQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + $camlQuery.ListItemCollectionPosition = $position + $camlQuery.ViewXml = $qCommand + ## Executing the query + $currentCollection = $ll.GetItems($camlQuery) + $ctx.Load($currentCollection) + $ctx.ExecuteQuery() + + ## Getting the position of the previous page + $position = $currentCollection.ListItemCollectionPosition + + # Adding current collection to the allItems collection + $allItems += $currentCollection + + Write-Host "Collecting items. Current number of items: " $allItems.Count + + +} + while($position -ne $null) + + + Write-Host "Total number of items: " $allItems.Count + + for($j=0;$j -lt $allItems.Count ;$j++) + { + + Write-Host "Resetting permissions for " $allItems[$j]["Title"] ".." $allItems[$j]["FileRef"] + $allItems[$j].ResetRoleInheritance() + $ctx.ExecuteQuery() + + } + + + + + + + } + + +# Paths to SDK. Please verify location on your computer. +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" + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="arleta@TENANT.onmicrosoft.com" +$Url="https://TENANT.sharepoint.com/sites/testID1de" +$ListTitle="testitems" + + +Restore-SPOListAllItemsInheritance -Username $username -Url $Url -AdminPassword $AdminPassword -ListTitle $ListTitle diff --git a/Lists and Libraries Management/Delete unique permissions in all items in a large list (5000+ items)/description.md b/Lists and Libraries Management/Delete unique permissions in all items in a large list (5000+ items)/description.md new file mode 100644 index 00000000..f301226c --- /dev/null +++ b/Lists and Libraries Management/Delete unique permissions in all items in a large list (5000+ items)/description.md @@ -0,0 +1,59 @@ +Powershell script to restore inherited permissions for all items in a SharePoint Online list. + + + +The script works with large (5000+) lists. + +In order to make it possible script uses a solution published here: http://www.sptrenches.com/2016/06/get-all-items-in-5000-large-list-with.html and commented by Sharath Aluri here: https://gallery.technet.microsoft.com/office/Delete-unique-permissions-c6ea2b57/view/Discussions#content. + + + +The script is a variation of Delete unique permissions in all items in one single list using Powershell script available on the Technet Gallery. + + + +Before you run it, you have to modify the last lines of the script! + + + + + +PowerShell +# Paths to SDK. Please verify location on your computer. +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" + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="arleta@TENANT.onmicrosoft.com" +$Url="https://TENANT.sharepoint.com/sites/testID1de" +$ListTitle="testitems" + + +Enter your credentials and the site where you want to modify the inheritance. +Verify if the SharePoint Online SDK is installed in the same location on your computer + + + + + + + + + + +Related scripts: + +Delete unique permissions in all items in one single list using Powershell + +Delete unique permissions for all lists + +Break inheritance for all lists + +Modify inherited permissions for a SharePoint Online site (module) + +Modify list permissions with Powershell cmdlets (module) + +Delete unique permissions (C# program) + +Get lists with unique permissions (C# program) diff --git a/OTHER/C# Create a contact list with internal user data/description.txt b/OTHER/C# Create a contact list with internal user data/description.md similarity index 81% rename from OTHER/C# Create a contact list with internal user data/description.txt rename to OTHER/C# Create a contact list with internal user data/description.md index b3b12309..014a230f 100644 --- a/OTHER/C# Create a contact list with internal user data/description.txt +++ b/OTHER/C# Create a contact list with internal user data/description.md @@ -2,24 +2,19 @@ Short C# application. It retrieves all the users and creates a contact list with -"LastName" +**"LastName"** -"FirstName" +**"FirstName"** -"WorkEmail" +**"WorkEmail"** -"WorkPhone" +**"WorkPhone"** -"CellPhone" - - - - +**"CellPhone"** Screenshot with test data - - + Technicalities: diff --git a/OTHER/C# Create a contact list with internal user data/sample.cs b/OTHER/C# Create a contact list with internal user data/sample.cs index 56239ea5..debba6c1 100644 --- a/OTHER/C# Create a contact list with internal user data/sample.cs +++ b/OTHER/C# Create a contact list with internal user data/sample.cs @@ -1,5 +1,4 @@ -static void PopulateProperties() - { +static void PopulateProperties() { ClientContext ctx = new ClientContext(adminsite); ctx.Credentials = new SharePointOnlineCredentials(userName, ss); @@ -7,35 +6,29 @@ static void PopulateProperties() string[] userProfileProperties = { "LastName", "FirstName", "WorkEmail", "WorkPhone","CellPhone", "AboutMe" }; propertiesforList=new string [userzy.Count, userProfileProperties.Length]; - for (int i = 0; i < userzy.Count;i++ ) - { - try - { + for (int i = 0; i < userzy.Count;i++ ) { + try{ Console.WriteLine("Retrieving properties for " + userzy[i].LoginName); UserProfilePropertiesForUser userProfilePropertiesForUser = new UserProfilePropertiesForUser(ctx, userzy[i].LoginName, userProfileProperties); IEnumerable profileProperties = peopleManager.GetUserProfilePropertiesFor(userProfilePropertiesForUser); ctx.Load(userProfilePropertiesForUser); ctx.ExecuteQuery(); int j = 0; - foreach (string property in profileProperties) - { + + foreach (string property in profileProperties) { propertiesforList[i, j] = property; j++; } } - catch (Exception ex) - { + catch (Exception ex) { } - } + + ctx.Dispose(); +} - - ctx.Dispose(); - } - - static void CreateList() - { +static void CreateList() { ClientContext ctx = new ClientContext(webUri); ctx.Credentials = new SharePointOnlineCredentials(userName,ss); ctx.ExecuteQuery(); diff --git a/OTHER/Change the default language for all the SharePoint Online users/description.md b/OTHER/Change the default language for all the SharePoint Online users/description.md index 185ca3ab..352582db 100644 --- a/OTHER/Change the default language for all the SharePoint Online users/description.md +++ b/OTHER/Change the default language for all the SharePoint Online users/description.md @@ -6,9 +6,9 @@ Have you ever created your tenant in the wrong language? Need to change it for t You know that the steps are: -Newsfeed>About me>Edit my profile> ... (three dots)>Language and region>Add the display language +**Newsfeed** > **About me** > **Edit my profile** > **... (three dots)** > **Language and region>Add the display language** -OneDrive>Gear icon>Site settings>Language settings>Mark alternate language +**OneDrive** > **Gear icon** > **Site settings** > **Language settings** > **Mark alternate language**

@@ -18,23 +18,19 @@ It's cool and awesome and flexible. But what if you have a thousand users? Are y Here it is: - - - - - + The red errors for system accounts are by design. I am expecting to get it better in the next version. The green users indicate for which users the language has been changed and into what. At the end the report will contain all users who did not get their language changed. -List of language ids +[List of language ids](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c?redirectedfrom=MSDN)

-Instructions +## *Instructions* 1. Download the .zip file @@ -52,11 +48,11 @@ Instructions Acknowledgements: -The app is using the new updates and nuggets. +The app is using the [new updates and nuggets.](https://docs.microsoft.com/pl-pl/archive/blogs/) -The app is prone to the known bug, which means it will not add desired alternate language for personal site unless there is one (any) added there already. +The app is prone to the [known bug](https://docs.microsoft.com/pl-pl/archive/blogs/), which means it will not add desired alternate language for personal site unless there is one (any) added there already. -Update on 20th of Dec - Adding additional language to web has unfortunately a bug and it does not work unless site has already one or more additional languages set, which means that this API does not really usable until this bug is fixed. This will be fixed for future releases and to redistributable version of the CSOM package. +**Update on 20th of Dec - Adding additional language to web has unfortunately a bug and it does not work unless site has already one or more additional languages set, which means that this API does not really usable until this bug is fixed. This will be fixed for future releases and to redistributable version of the CSOM package.** diff --git a/OTHER/CreativeDestruction/Description.txt b/OTHER/CreativeDestruction/Description.md similarity index 75% rename from OTHER/CreativeDestruction/Description.txt rename to OTHER/CreativeDestruction/Description.md index 2389df3d..05a4dc2b 100644 --- a/OTHER/CreativeDestruction/Description.txt +++ b/OTHER/CreativeDestruction/Description.md @@ -1,104 +1,119 @@ -What does it do? - - +### *What does it do?* The program has 2 basic functions: creation and destruction. -Godly Creation: +**Godly Creation:** -- it creates the following site collections, all named after the templates they have been created from: + + - it creates the following site collections, all named after the templates they have been created from: + -TeamsiteWithLibraries -TeamsiteWithLists -Empty Teamsite -"WikiSite" -"BlogSite" -"CommunitySite" -"PublishingPortal" -- it creates 2 subsites : subsite1 and subsite2 to the TeamsiteWithLibraries +- TeamsiteWithLibraries +- TeamsiteWithLists +- Empty Teamsite +- "WikiSite" +- "BlogSite" +- "CommunitySite" +- "PublishingPortal" + +- it creates 2 subsites : subsite1 and subsite2 to the TeamsiteWithLibraries + +
+ - it creates 2 document libraries, 2 picture libraries, Wiki Page library, XML Form library and Data Connection library to the TeamsiteWithLibraries - + +
+ - it creates 3 Custom lists in the TeamsiteWithLists: one empty, one with sample data, one with over 5000 items - + +
+ - it creates a default view limited to 70 items for 5000 items list. You can switch between the views using GUI - + +
+ - it creates Links list, Anouncements list, Contacts list, Events list, Tasks list to the TeamsiteWithLists - -- it populates Custom, Anouncements list, Contacts list, Events list, and Tasks list with sample data (ca. 50 items - if you need more please look https://gallery.technet.microsoft.com/scriptcenter/Create-various-lists-with-0e714f70 and https://gallery.technet.microsoft.com/scriptcenter/Create-a-list-with-3f19ba11 ) - + +
+ +- it populates Custom, Anouncements list, Contacts list, Events list, and Tasks list with sample data (ca. 50 items - if you need more please look https://gallery.technet.microsoft.com/scriptcenter/Create-various-lists-with-0e714f70
and
https://gallery.technet.microsoft.com/scriptcenter/Create-a-list-with-3f19ba11 ) +
+
+ - it adds all the available lists and libraries to the Quick Launch Menu. Also added are the lists that were previously accessible only via direct links, like Workflow History. - - - + +
Watch out! The process of creating 5000 items in a list takes time. You will be informed on the progress as the application runs. - - -Total Destruction: - +### Total Destruction: + - it retrieves all your site collections and deletes them, apart from the search, mysite (which cannot be recreated in SharePoint Online) and rootsite - + +
+ - it checks the recycle bin for the deleted sites and removes them from the recycle bin + +
Watch out! Deleting a site collection takes a while and depends on SharePoint Online backend processes. The application waits for the site collections to be deleted and informs you about its attempts with status updates "Trying to delete site XYZ". However, after 6 unsuccessful attempts it may mean that SharePoint is not going to be very cooperative at the moment and the application will ask you whether it should close or keep trying. - - -Only Recycle Bin: - +### Only Recycle Bin: + - as the name suggests, permanently removes the content of the recycle bin - + +
+ - cannot be reversed - + +
+ - can be used instead of Powershell Get-SpoDeletedSite | Remove-SpoDeletedSite + - - -Only Created - +### Only Created + - removes only the site collections created by the program + -TeamsiteWithLibraries -TeamsiteWithLists -Empty Teamsite -"WikiSite" -"BlogSite" -"CommunitySite" -"PublishingPortal" -Watch out! If you added some of your own data to those site collections (other libraries, site mailbox or items) it will also be deleted! - - +- TeamsiteWithLibraries +- TeamsiteWithLists +- Empty Teamsite +- "WikiSite" +- "BlogSite" +- "CommunitySite" +- "PublishingPortal" -What doesn't it do? +Watch out! If you added some of your own data to those site collections (other libraries, site mailbox or items) it will also be deleted! +### *What doesn't it do?* + -Despite the name Non-Empty libraries are still empty - + +
+ -The list with Geolocation column doesn't contain Geolocation column - + +
+ -It doesn't verify your credentials. Change the examples in the fields into your own credentials, following the same pattern (don't put in a teamsite domain.sharepoint.com where it asks you to type admin site url preceded by https://). If you make a mistake, you will get an error at an early stage of the application. - + +
+ - It's not perfect. I have made it as failsafe as the time allowed with a lot of try and catches and bugs handled. However, if it still stops at some point, just run it again. The program will detect the work already done and simply continue. + - - - - -How do I use it? +### *How do I use it?* The zip file contains an .exe which installs the program. You can open it like any other program from Start Menu or a Desktop shortcut. Type in your user credentials in the three available fields following the given example. After that, choose one of the buttons to create or delete data in your tenant. You can perform multiple operations during one run, so if you find it to your liking, you can alternate between creating and destroying content just to test SharePoint Online's behaviour. -When you have finished working with the program, a log will be created at C:\Users\Public\ where you can analyze what has been done. +When you have finished working with the program, a **log will be created at C:\Users\Public\** where you can analyze what has been done. If you need to uninstall the program you can find it in Control Panel>Programs and Features. - - - - -Technicalities +### *Technicalities* The program relies on static classes. @@ -110,6 +125,3 @@ CheckForIllegalCrossThreadCalls is set to false, which may generate some random Updating the status window may slow down or even temporarily hang the execution. Just let it run its course and it should fix itself. This part also forced me to set CheckForIllegalCrossThreadCalls = false; so if anyone knows how to fix it, please post a comment. That part of the code is available in the snippet. - - - diff --git a/OTHER/CreativeDestruction/excerpt.cs b/OTHER/CreativeDestruction/excerpt.cs index f1c358a0..02954a46 100644 --- a/OTHER/CreativeDestruction/excerpt.cs +++ b/OTHER/CreativeDestruction/excerpt.cs @@ -1,104 +1,82 @@ -public Form1() - { - InitializeComponent(); - CheckForIllegalCrossThreadCalls = false; - - label4.Text = Status.StatusText; - RefreshStatusThread = new Thread(RefreshStupidStatus); - RefreshStatusThread.Start(); - } - -private void RefreshStupidStatus() - { - label4.Text = Status.StatusText; - Thread.Sleep(1000); - RefreshStupidStatus(); - } +public Form1() { + InitializeComponent(); + CheckForIllegalCrossThreadCalls = false; + + label4.Text = Status.StatusText; + RefreshStatusThread = new Thread(RefreshStupidStatus); + RefreshStatusThread.Start(); +} -private void button1_Click(object sender, EventArgs e) - { +private void RefreshStupidStatus() { + label4.Text = Status.StatusText; + Thread.Sleep(1000); + RefreshStupidStatus(); +} - if (CredentialVerificationForAllButtons()) - { - +private void button1_Click(object sender, EventArgs e) { + if (CredentialVerificationForAllButtons()) { TotalDestructionFunction.TotalThem(); TotalDestructionFunction.RemoveRecycleBinContent(); - - } - - } +} - private void myshitbtn_Click(object sender, EventArgs e) - { - if (CredentialVerificationForAllButtons()) - { - - +private void myshitbtn_Click(object sender, EventArgs e) { + if (CredentialVerificationForAllButtons()) { TotalDestructionFunction.JustMyShit(); TotalDestructionFunction.RemoveRecycleBinContent(); - - } } +} - -public static void CreateSiteColls(string siteurll, string root, string credUsername, SecureString password) - { - ClientContext tenantContext = new ClientContext(siteurll); - tenantContext.Credentials = new SharePointOnlineCredentials(credUsername, password); - var tenant = new Tenant(tenantContext); - tenantContext.Load(tenant); - Status.StatusText = DateTime.Now.ToString() + " Sending request to create site collections. This may take a while...\r\n" + Status.StatusText; - string[] TeamSiteColls = { "TeamsiteWithLibraries", "TeamsiteWithLists", "Empty Teamsite" }; - foreach (string tsc in TeamSiteColls) - { +public static void CreateSiteColls(string siteurll, string root, string credUsername, SecureString password) { + ClientContext tenantContext = new ClientContext(siteurll); + tenantContext.Credentials = new SharePointOnlineCredentials(credUsername, password); + var tenant = new Tenant(tenantContext); + tenantContext.Load(tenant); + Status.StatusText = DateTime.Now.ToString() + " Sending request to create site collections. This may take a while...\r\n" + Status.StatusText; + string[] TeamSiteColls = { "TeamsiteWithLibraries", "TeamsiteWithLists", "Empty Teamsite" }; + + foreach (string tsc in TeamSiteColls) { var siteCreationProperties = CreateSite(tsc, tsc, credUsername, root); SpoOperation spo = tenant.CreateSite(siteCreationProperties); tenantContext.Load(spo, i => i.IsComplete); - try - { - tenantContext.ExecuteQuery(); + + try{ + tenantContext.ExecuteQuery(); } - catch (Exception e) - { - Status.StatusText = DateTime.Now.ToString() + " " + e.Message + "\r\n" + Status.StatusText; - + catch (Exception e){ + Status.StatusText = DateTime.Now.ToString() + " " + e.Message + "\r\n" + Status.StatusText; } - - - } + } } -public static void CreateLis(string rootsite, string credUsername, SecureString password) - { - string strona = rootsite + "Sites/TeamsiteWithLists"; - var context = new ClientContext(strona); - context.Credentials = new SharePointOnlineCredentials(credUsername, password); - context.Load(context.Web.Webs, wc => wc.Include(w => w.Url, w => w.Lists)); - SiteProperties collprops = new SiteProperties(context, strona); - collprops.StorageMaximumLevel = 700; - context.Web.Lists.Add(CreateList("Generic List", 100)); - context.Web.Lists.Add(CreateList("Empty Generic List", 100)); - context.Web.Lists.Add(CreateList("Custom List With 5005items", 100)); - context.Web.Lists.Add(CreateList("Generic List With GeolocationColumn", 100)); - context.Web.Lists.Add(CreateList("Links list", 103)); - context.Web.Lists.Add(CreateList("Announcements list", 104)); - context.Web.Lists.Add(CreateList("Contacts list", 105)); - context.Web.Lists.Add(CreateList("Events list", 106)); - context.Web.Lists.Add(CreateList("Tasks list", 107)); - //context.Web.Lists.Add(CreateList("User Information list", 112)); - context.Web.QuickLaunchEnabled = true; - try - { +public static void CreateLis(string rootsite, string credUsername, SecureString password) { + string strona = rootsite + "Sites/TeamsiteWithLists"; + var context = new ClientContext(strona); + context.Credentials = new SharePointOnlineCredentials(credUsername, password); + context.Load(context.Web.Webs, wc => wc.Include(w => w.Url, w => w.Lists)); + SiteProperties collprops = new SiteProperties(context, strona); + collprops.StorageMaximumLevel = 700; + context.Web.Lists.Add(CreateList("Generic List", 100)); + context.Web.Lists.Add(CreateList("Empty Generic List", 100)); + context.Web.Lists.Add(CreateList("Custom List With 5005items", 100)); + context.Web.Lists.Add(CreateList("Generic List With GeolocationColumn", 100)); + context.Web.Lists.Add(CreateList("Links list", 103)); + context.Web.Lists.Add(CreateList("Announcements list", 104)); + context.Web.Lists.Add(CreateList("Contacts list", 105)); + context.Web.Lists.Add(CreateList("Events list", 106)); + context.Web.Lists.Add(CreateList("Tasks list", 107)); + //context.Web.Lists.Add(CreateList("User Information list", 112)); + context.Web.QuickLaunchEnabled = true; + + try { context.ExecuteQuery(); - } - catch(Exception e) - { + } + catch(Exception e) { Status.StatusText = DateTime.Now + " Couldn't create list. " + e.Message + Environment.NewLine + Status.StatusText; - } - context.Dispose(); - - Status.StatusText = DateTime.Now + " Lists are created. Proceeding to fill them with content" + Environment.NewLine + Status.StatusText; - + } + + context.Dispose(); + + Status.StatusText = DateTime.Now + " Lists are created. Proceeding to fill them with content" + Environment.NewLine + Status.StatusText; } } diff --git a/OTHER/Get all event receivers on your lists in a site/GetSPOListEventReceivers.ps1 b/OTHER/Get all event receivers on your lists in a site/GetSPOListEventReceivers.ps1 index b6870fdb..158cfc2f 100644 --- a/OTHER/Get all event receivers on your lists in a site/GetSPOListEventReceivers.ps1 +++ b/OTHER/Get all event receivers on your lists in a site/GetSPOListEventReceivers.ps1 @@ -1,48 +1,43 @@ -function Get-SPOListEventreceivers -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOListEventreceivers{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url -) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - -try -{ -$ctx.ExecuteQuery() -} catch [Net.WebException] - { - - Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red -} - - $ctx.Load($ctx.Site) - $ctx.Load($ctx.Web.Lists) - $ctx.ExecuteQuery() - Write-Host $ctx.Web.Lists.Count - for($j=0;$j -lt $ctx.Web.Lists.Count;$j++) - { - $lista=$ctx.Web.Lists[$j] - $ctx.Load($lista) - $ctx.ExecuteQuery() - $recevery=$lista.EventReceivers - $ctx.Load($recevery) - $ctx.ExecuteQuery() - Write-Host $recevery.Count $lista.Title - - for($i=0;$i -lt $recevery.Count ; $i++) - { - $ctx.Load($recevery[$i]) - $ctx.ExecuteQuery() - Write-Output $recevery[$i] - } - - } + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + + try{ + $ctx.ExecuteQuery() + } + catch [Net.WebException] { + Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red + } + + $ctx.Load($ctx.Site) + $ctx.Load($ctx.Web.Lists) + $ctx.ExecuteQuery() + Write-Host $ctx.Web.Lists.Count + + for($j=0;$j -lt $ctx.Web.Lists.Count;$j++){ + $lista=$ctx.Web.Lists[$j] + $ctx.Load($lista) + $ctx.ExecuteQuery() + $recevery=$lista.EventReceivers + $ctx.Load($recevery) + $ctx.ExecuteQuery() + Write-Host $recevery.Count $lista.Title + + for($i=0;$i -lt $recevery.Count ; $i++){ + $ctx.Load($recevery[$i]) + $ctx.ExecuteQuery() + Write-Output $recevery[$i] + } + } } @@ -57,4 +52,4 @@ $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $Url="https://tenant.sharepoint.com/sites/teamsitewithlibraries" -Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url $Url \ No newline at end of file +Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url $Url diff --git a/OTHER/Get all event receivers on your lists in a site/description.md b/OTHER/Get all event receivers on your lists in a site/description.md index 3c098dc4..c5611511 100644 --- a/OTHER/Get all event receivers on your lists in a site/description.md +++ b/OTHER/Get all event receivers on your lists in a site/description.md @@ -2,7 +2,7 @@ A short solution to find event receivers on your SPO lists. -1. Install SharePoint Online SDK +1. Install [SharePoint Online SDK](http://www.microsoft.com/en-us/download/details.aspx?id=42038) 2. Download the file and open (e.g. in NotePad) @@ -31,19 +31,16 @@ Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url It should ask you for your admin password - - If you want to export the event-receivers' data to a .csv file, use PathToTheScript | export-csv c:\users\MyUsers\Desktop\CSVReport.csv + +**Sample Report** - - -Sample Report - -ReceiverAssembly ReceiverClass ReceiverId ReceiverName SequenceNumber Synchronization EventType ReceiverUrl Context Tag Path ObjectVersion ServerObjectIsNull TypedObject -Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c Microsoft.SharePoint.Portal.CommunityEventReceiver f13fb801-b306-42ea-bb1e-2f4c1e4a8e81 10000 Synchronous ItemAdding Microsoft.SharePoint.Client.ClientContext Microsoft.SharePoint.Client.ObjectPathIdentity False Microsoft.SharePoint.Client.EventReceiverDefinition -Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c Microsoft.SharePoint.Portal.CommunityEventReceiver cebe300c-50ac-4d88-8a4b-a63b9d6da400 10000 Synchronous ItemUpdating Microsoft.SharePoint.Client.ClientContext Microsoft.SharePoint.Client.ObjectPathIdentity False Microsoft.SharePoint.Client.EventReceiverDefinition -Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c Microsoft.SharePoint.Portal.CommunityEventReceiver bfc4ca11-32d6-4248-923c-fe16bcf8145d 10000 Synchronous ItemDeleting Microsoft.SharePoint.Client.ClientContext Microsoft.SharePoint.Client.ObjectPathIdentity False Microsoft.SharePoint.Client.EventReceiverDefinition -Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c Microsoft.SharePoint.Portal.CommunityEventReceiver 6f2b105a-4834-40df-a450-c480c5c94ef0 10000 Asynchronous ItemAdded Microsoft.SharePoint.Client.ClientContext Microsoft.SharePoint.Client.ObjectPathIdentity False Microsoft.SharePoint.Client.EventReceiverDefinition +ReceiverAssembly | ReceiverClass | ReceiverId | ReceiverName | SequenceNumber | Synchronization | EventType | ReceiverUrl | Context | Tag | Path | ObjectVersion | ServerObjectIsNull | TypedObject +--|--|--|--|--|--|--|--|--|--|--|--|--|-- +Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c | Microsoft.SharePoint.Portal.CommunityEventReceiver | f13fb801-b306-42ea-bb1e-2f4c1e4a8e81 | | 10000 | Synchronous | ItemAdding | Microsoft.SharePoint.Client.ClientContext | Microsoft.SharePoint.Client.ObjectPathIdentity | False | Microsoft.SharePoint.Client.EventReceiverDefinition +Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c | Microsoft.SharePoint.Portal.CommunityEventReceiver | cebe300c-50ac-4d88-8a4b-a63b9d6da400 | | 10000 | Synchronous | ItemUpdating | Microsoft.SharePoint.Client.ClientContext | Microsoft.SharePoint.Client.ObjectPathIdentity | False | Microsoft.SharePoint.Client.EventReceiverDefinition +Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c | Microsoft.SharePoint.Portal.CommunityEventReceiver | bfc4ca11-32d6-4248-923c-fe16bcf8145d | | 10000 | Synchronous | ItemDeleting | Microsoft.SharePoint.Client.ClientContext | Microsoft.SharePoint.Client.ObjectPathIdentity | False | Microsoft.SharePoint.Client.EventReceiverDefinition +Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c | Microsoft.SharePoint.Portal.CommunityEventReceiver | 6f2b105a-4834-40df-a450-c480c5c94ef0 | | 10000 | Asynchronous | ItemAdded | Microsoft.SharePoint.Client.ClientContext | Microsoft.SharePoint.Client.ObjectPathIdentity | False | Microsoft.SharePoint.Client.EventReceiverDefinition diff --git a/OTHER/Remove a single event receiver/DeleteSingleReceiver.ps1 b/OTHER/Remove a single event receiver/DeleteSingleReceiver.ps1 index 7136c1c6..f70564d6 100644 --- a/OTHER/Remove a single event receiver/DeleteSingleReceiver.ps1 +++ b/OTHER/Remove a single event receiver/DeleteSingleReceiver.ps1 @@ -1,53 +1,46 @@ -function Get-SPOListEventreceivers -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOListEventreceivers{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string]$ListTitle, - [Parameter(Mandatory=$true,Position=5)] + [Parameter(Mandatory=$true,Position=5)] [GUID]$EventReceiverGUID -) + ) $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) -try -{ -$ctx.ExecuteQuery() -} catch [Net.WebException] - { - - Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red -} - - $ctx.Load($ctx.Site) - - $lista=$ctx.Web.Lists.GetByTitle($ListTitle) - $ctx.Load($lista) - $ctx.ExecuteQuery() - $recevery=$lista.EventReceivers - $ctx.Load($recevery) - $ctx.ExecuteQuery() - Write-Host "Found " $recevery.Count " receivers in " $lista.Title - -$recevery.GetById($EventReceiverGUID).DeleteObject() - -try -{ -$ctx.ExecuteQuery() -Write-Host "receiver removed" -} - - catch [Net.WebException] - { - Write-Host "Failed to delete the receiver" $_.Exception.Message.ToString() -ForegroundColor Red - } - + try{ + $ctx.ExecuteQuery() + } + catch [Net.WebException] { + Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red + } + + $ctx.Load($ctx.Site) + + $lista=$ctx.Web.Lists.GetByTitle($ListTitle) + $ctx.Load($lista) + $ctx.ExecuteQuery() + $recevery=$lista.EventReceivers + $ctx.Load($recevery) + $ctx.ExecuteQuery() + Write-Host "Found " $recevery.Count " receivers in " $lista.Title + + $recevery.GetById($EventReceiverGUID).DeleteObject() + + try{ + $ctx.ExecuteQuery() + Write-Host "receiver removed" + } + catch [Net.WebException] { + Write-Host "Failed to delete the receiver" $_.Exception.Message.ToString() -ForegroundColor Red + } } @@ -62,4 +55,4 @@ $Url="https://tenant.sharepoint.com/sites/teamsitewithlibraries" $ListTitle="kriiv" $EventReceiverGUID="154d2ca2-8335-464c-9059-214cdcc1c2c1" -Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url $Url -ListTitle $ListTitle -EventReceiverGUID $EventreceiverGUID \ No newline at end of file +Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url $Url -ListTitle $ListTitle -EventReceiverGUID $EventreceiverGUID diff --git a/OTHER/Remove a single event receiver/description.md b/OTHER/Remove a single event receiver/description.md index d5f18710..21ed399b 100644 --- a/OTHER/Remove a single event receiver/description.md +++ b/OTHER/Remove a single event receiver/description.md @@ -2,7 +2,7 @@ A short solution to remove a single event receiver from your SPO lists. -1. Install SharePoint Online SDK +1. Install [SharePoint Online SDK](http://www.microsoft.com/en-us/download/details.aspx?id=42038) 2. Download the file and open (e.g. in NotePad) @@ -28,7 +28,7 @@ Get-SPOListEventreceivers -Username $Username -AdminPassword $AdminPassword -Url 6. Instead of https://tenant.sharepint.com/sites/teamsitewithlibraries enter name of the site where the list with unwanted event receiver -7. Under $EventReceiverGUID, enter the guid of the receiver. If you need to find it, you can use Get all event receivers on your lists in a SharePoint Online site +7. Under $EventReceiverGUID, enter the guid of the receiver. If you need to find it, you can use [Get all event receivers on your lists in a SharePoint Online site](https://gallery.technet.microsoft.com/Get-all-event-receivers-on-479a1e8d) @@ -36,16 +36,10 @@ Run the script in any Powershell module. It should ask you for your admin password. - + The script will inform you how many receivers it found on the list and if it encountered any issues. - - - - -Please share your feedback in the Q&A section! - - +**Please share your feedback in the Q&A section!** Should you need any assistance or a different script, please let me know - I will be happy to help diff --git a/OTHER/Unified Groups Storage Report/UnifiedGroupStorageWithCSOM.ps1 b/OTHER/Unified Groups Storage Report/UnifiedGroupStorageWithCSOM.ps1 index 2bb3f63f..03dbed40 100644 --- a/OTHER/Unified Groups Storage Report/UnifiedGroupStorageWithCSOM.ps1 +++ b/OTHER/Unified Groups Storage Report/UnifiedGroupStorageWithCSOM.ps1 @@ -2,72 +2,66 @@ # Vadim Gremyachev's method. It is briliant Function Invoke-LoadMethod() { -param( - [Microsoft.SharePoint.Client.ClientObject]$Object = $(throw "Please provide a Client Object"), - [string]$PropertyName -) - $ctx = $Object.Context - $load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load") - $type = $Object.GetType() - $clientLoad = $load.MakeGenericMethod($type) - - - $Parameter = [System.Linq.Expressions.Expression]::Parameter(($type), $type.Name) - $Expression = [System.Linq.Expressions.Expression]::Lambda( - [System.Linq.Expressions.Expression]::Convert( - [System.Linq.Expressions.Expression]::PropertyOrField($Parameter,$PropertyName), - [System.Object] - ), - $($Parameter) - ) + param( + [Microsoft.SharePoint.Client.ClientObject]$Object = $(throw "Please provide a Client Object"), + [string]$PropertyName + ) + + $ctx = $Object.Context + $load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load") + $type = $Object.GetType() + $clientLoad = $load.MakeGenericMethod($type) + + + $Parameter = [System.Linq.Expressions.Expression]::Parameter(($type), $type.Name) + $Expression = [System.Linq.Expressions.Expression]::Lambda( + [System.Linq.Expressions.Expression]::Convert( + [System.Linq.Expressions.Expression]::PropertyOrField($Parameter,$PropertyName), + [System.Object] + ), + $($Parameter) + ) + $ExpressionArray = [System.Array]::CreateInstance($Expression.GetType(), 1) $ExpressionArray.SetValue($Expression, 0) $clientLoad.Invoke($ctx,@($Object,$ExpressionArray)) } -function Get-SPOWeb -{ +function Get-SPOWeb{ + <# + .link + http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx -<# - .link - http://social.technet.microsoft.com/wiki/contents/articles/32334.sharepoint-online-spomod-cmdlets-resources.aspx + #> - #> -param ( - [Parameter(Mandatory=$true,Position=1)] + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $AdminPassword - - ) - - # Connecting to particular personal site - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ctx.Load($ctx.Web) - $ctx.Load($ctx.Site) - $ctx.ExecuteQuery() + ) - # loading usage data for the site - Invoke-LoadMethod -Object $ctx.Site -PropertyName "Usage" - $ctx.ExecuteQuery() - $outputty=1099511627776-$ctx.Site.Usage.StoragePercentageUsed - - # User output, feel free to modify the message content - Write-Host "Storage: " $ctx.Site.Usage.Storage - Write-Host "Percentage used: " $ctx.Site.Usage.StoragePercentageUsed - Write-Host "Storage free: " $outputty - - - - - $ctx.Dispose() - - - + # Connecting to particular personal site + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Site) + $ctx.ExecuteQuery() + + # loading usage data for the site + Invoke-LoadMethod -Object $ctx.Site -PropertyName "Usage" + $ctx.ExecuteQuery() + $outputty=1099511627776-$ctx.Site.Usage.StoragePercentageUsed + + # User output, feel free to modify the message content + Write-Host "Storage: " $ctx.Site.Usage.Storage + Write-Host "Percentage used: " $ctx.Site.Usage.StoragePercentageUsed + Write-Host "Storage free: " $outputty + + $ctx.Dispose() } @@ -99,9 +93,7 @@ $grupki=(get-unifiedgroup).sharepointsiteurl -foreach($group in $grupki) -{ - -Write-Host "Processing "$group -Get-SPOWeb -Username $admin -Url $group -AdminPassword $pass -} \ No newline at end of file +foreach($group in $grupki){ + Write-Host "Processing "$group + Get-SPOWeb -Username $admin -Url $group -AdminPassword $pass +} diff --git a/OTHER/Unified Groups Storage Report/description.md b/OTHER/Unified Groups Storage Report/description.md index 69c03926..0b565251 100644 --- a/OTHER/Unified Groups Storage Report/description.md +++ b/OTHER/Unified Groups Storage Report/description.md @@ -1,4 +1,5 @@ -Short description +## Short description + The script retrieves all unified groups in your tenant and the storage quotas for their associated site collections. Whaaat? (explanation for those whose life doesn't evolve around O365 and who not only believe in but have actually seen the life beyond the firewall) @@ -13,7 +14,8 @@ Whaaat? (explanation for those whose life doesn't evolve around O365 and who not -Prerequisites +## Prerequisites + - SharePoint Online SDK @@ -22,14 +24,14 @@ Make sure the script refers to the library paths on your computer: -PowerShell +```PowerShell # Paths to SDK. Please verify location on your computer. 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" - + ``` -How to use? +## How to use? 1. Download the file. 2. Open in Powershell ISE or even notepad. @@ -42,8 +44,9 @@ How to use? -Expected results +##Expected results + @@ -51,6 +54,4 @@ Expected results - - -I am waiting for your comments in the Q&A section! +**I am waiting for your comments in the Q&A section!** diff --git a/OTHER/Uninstall unwanted app from your site using Powershell/RemoveSPOApp.ps1 b/OTHER/Uninstall unwanted app from your site using Powershell/RemoveSPOApp.ps1 index be5824ab..869551fe 100644 --- a/OTHER/Uninstall unwanted app from your site using Powershell/RemoveSPOApp.ps1 +++ b/OTHER/Uninstall unwanted app from your site using Powershell/RemoveSPOApp.ps1 @@ -1,42 +1,36 @@ -function Uninstall-SPOApp -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Uninstall-SPOApp{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [GUID]$SPOAppGUID -) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - -try -{ -$ctx.ExecuteQuery() -} catch [Net.WebException] - { - - Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red -} - - $ctx.Load($ctx.Site) - $ctx.Load($ctx.Web.Webs) - $ctx.Web.GetAppInstanceById($SPOAppGUID).Uninstall() - - try - { - $ctx.ExecuteQuery() - Write-Host "Success" -ForegroundColor Green - } - catch [Net.WebException] - { - Write-Host "Failed to uninstall the app" $_.Exception.Message.ToString() -ForegroundColor Red - } - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + + try{ + $ctx.ExecuteQuery() + } + catch [Net.WebException] { + Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red + } + + $ctx.Load($ctx.Site) + $ctx.Load($ctx.Web.Webs) + $ctx.Web.GetAppInstanceById($SPOAppGUID).Uninstall() + + try{ + $ctx.ExecuteQuery() + Write-Host "Success" -ForegroundColor Green + } + catch [Net.WebException] { + Write-Host "Failed to uninstall the app" $_.Exception.Message.ToString() -ForegroundColor Red + } } @@ -50,4 +44,4 @@ $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $Url="https://tenant.sharepoint.com/sites/teamsitewithlibraries" $GUID="126d911b-b274-4b69-a52e-2a9e5bbae91b" -Uninstall-SPOApp -Username $Username -AdminPassword $AdminPassword -Url $Url -SPOAppGUID $GUID \ No newline at end of file +Uninstall-SPOApp -Username $Username -AdminPassword $AdminPassword -Url $Url -SPOAppGUID $GUID diff --git a/OTHER/Uninstall unwanted app from your site using Powershell/description.md b/OTHER/Uninstall unwanted app from your site using Powershell/description.md index 3d34a026..89e6fb53 100644 --- a/OTHER/Uninstall unwanted app from your site using Powershell/description.md +++ b/OTHER/Uninstall unwanted app from your site using Powershell/description.md @@ -2,13 +2,13 @@ A simple solution to uninstall an unwanted app from a Sharepoint Online site usi -1. Install SharePoint Online SDK +1. Install [SharePoint Online SDK](http://www.microsoft.com/en-us/download/details.aspx?id=42038) 2. Download the file and open (e.g. in NotePad) 3. Scroll down to these lines -PowerShell +```PowerShell # Paths to SDK. Please verify location on your computer. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" @@ -18,7 +18,7 @@ $Username="admin@tenant.onmicrosoft.com" $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $Url="https://tenant.sharepoint.com/sites/teamsitewithlibraries" $GUID="126d911b-b274-4b69-a52e-2a9e5bbae91b" - + ``` 4. Check if the 2 libraries are in the same location on your computer. If yes, proceed on. If no, change the paths in the file. Usually you will be required to change folder name "15" into "16". 5. Instead of admin@tenant.onmicrosoft.com, enter the name of your site collection admin. @@ -27,22 +27,11 @@ $GUID="126d911b-b274-4b69-a52e-2a9e5bbae91b" 7. Under GUID enter the app's guid. - - - Run the script in any Powershell module. It should ask you for your admin password and report success or detailed error: - - - - - - - - - + -Please share your feedback in the Q&A section! +**Please share your feedback in the Q&A section!** diff --git a/OneDrive for Business/Create OneDrive for Business usage report for all users/description.md b/OneDrive for Business/Create OneDrive for Business usage report for all users/description.md index cd6acad0..963a78d9 100644 --- a/OneDrive for Business/Create OneDrive for Business usage report for all users/description.md +++ b/OneDrive for Business/Create OneDrive for Business usage report for all users/description.md @@ -32,11 +32,8 @@ $mysiteHost="https://tenant-my.sharepoint.com" 4. Expected results: - - - - +

### Acknowledgement: -The script is using Invoke-LoadMethod published here, without which it could not proceed. The method was created and belongs to a brilliant SharePointer and Guru, Vadim Gremyachev. +The script is using Invoke-LoadMethod published here, without which it could not proceed. The method was created and belongs to a brilliant SharePointer and Guru, [Vadim Gremyachev.](https://sharepoint.stackexchange.com/users/10610/vadim-gremyachev) diff --git a/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 index eb9532c5..6068a58a 100644 --- a/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 +++ b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 @@ -1,54 +1,45 @@ -function Set-SPOListVersioning($EnableVersioning, $Urelek) -{ - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $Adminpassword) - $ctx.Load($ctx.Web.Lists) - $ctx.Load($ctx.Web) - $ctx.Load($ctx.Web.Webs) - $ctx.ExecuteQuery() - Write-Host - Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - foreach( $ll in $ctx.Web.Lists) - { - $ll.EnableVersioning = $EnableVersioning - $ll.Update() - $csvvalue= new-object PSObject +function Set-SPOListVersioning($EnableVersioning, $Urelek){ + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $Adminpassword) + $ctx.Load($ctx.Web.Lists) + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Web.Webs) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + + foreach( $ll in $ctx.Web.Lists){ + $ll.EnableVersioning = $EnableVersioning + $ll.Update() + $csvvalue= new-object PSObject $listurl=$null + if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url+$ll.Title} else {$listurl=$ctx.Url+"/"+$ll.Title} + $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) $csvvalue | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" - try - { - $ErrorActionPreference="Stop" - $ctx.ExecuteQuery() - Write-Host $listurl -ForegroundColor DarkGreen - $csvvalue.Status="Success" - $Global:csv+= $csvvalue + + try{ + $ErrorActionPreference="Stop" + $ctx.ExecuteQuery() + Write-Host $listurl -ForegroundColor DarkGreen + $csvvalue.Status="Success" + $Global:csv+= $csvvalue } - - catch - { + catch{ $Global:csv+= $csvvalue Write-Host $listurl -ForegroundColor Red } finally {$ErrorActionPreference="Continue"} - - } - if($ctx.Web.Webs.Count -gt 0) - { - for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++) - { + if($ctx.Web.Webs.Count -gt 0){ + for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++){ Set-SPOListVersioning -EnableVersioning $EnableVersioning -Urelek ($ctx.Web.Webs[$i].Url) } - } - - - } @@ -71,23 +62,19 @@ $users=get-SPOUser -Site $myhost $EnableVersioning=$true $Global:csv=@() -foreach($user in $users) -{ - - - if($user.LoginName.Contains('@')) - { - $persweb=$user.LoginName.Replace(".","_").Replace("@","_") - $persweb=$myhost+"/personal/"+$persweb - Write-Host $persweb +foreach($user in $users){ + if($user.LoginName.Contains('@')){ + $persweb=$user.LoginName.Replace(".","_").Replace("@","_") + $persweb=$myhost+"/personal/"+$persweb + Write-Host $persweb - $AdminUrl=$persweb + $AdminUrl=$persweb - #Add the following line if you want to assign yourself, administrator or another user access to other users' personal sites - #Set-SPOUser -Site $AdminUrl -IsSiteCollectionAdmin $true -LoginName t@trial765.onmicrosoft.com - Set-SPOListVersioning -EnableVersioning $EnableVersioning -Urelek $AdminUrl + #Add the following line if you want to assign yourself, administrator or another user access to other users' personal sites + #Set-SPOUser -Site $AdminUrl -IsSiteCollectionAdmin $true -LoginName t@trial765.onmicrosoft.com + Set-SPOListVersioning -EnableVersioning $EnableVersioning -Urelek $AdminUrl } } # Specify the path where the log file will be published -$Global:csv | Export-Csv -Path C:\Users\Public\Versioning.csv \ No newline at end of file +$Global:csv | Export-Csv -Path C:\Users\Public\Versioning.csv diff --git a/OneDrive for Business/Enable versioning for all lists in OneDrive sites/description.md b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/description.md index 59cc0a80..f2978e30 100644 --- a/OneDrive for Business/Enable versioning for all lists in OneDrive sites/description.md +++ b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/description.md @@ -1,6 +1,6 @@ Powershell script that enables versioning for all the libraries and lists in all personal sites (OneDrive for Business). -It requires SharePoint Online Management Shell and SharePoint SDK installed: +**It requires SharePoint Online Management Shell and SharePoint SDK installed:** http://technet.microsoft.com/en-us/library/fp161372(v=office.15).aspx diff --git a/OneDrive for Business/Update locale id for all personal sites/LocaleID.ps1 b/OneDrive for Business/Update locale id for all personal sites/LocaleID.ps1 index 6de5c803..12f20701 100644 --- a/OneDrive for Business/Update locale id for all personal sites/LocaleID.ps1 +++ b/OneDrive for Business/Update locale id for all personal sites/LocaleID.ps1 @@ -1,41 +1,41 @@  # Vadim Gremyachev's function - Function Invoke-LoadMethod() { -param( - [Microsoft.SharePoint.Client.ClientObject]$Object = $(throw "Please provide a Client Object"), - [string]$PropertyName -) - $ctx = $Object.Context - $load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load") - $type = $Object.GetType() - $clientLoad = $load.MakeGenericMethod($type) - - - $Parameter = [System.Linq.Expressions.Expression]::Parameter(($type), $type.Name) - $Expression = [System.Linq.Expressions.Expression]::Lambda( - [System.Linq.Expressions.Expression]::Convert( - [System.Linq.Expressions.Expression]::PropertyOrField($Parameter,$PropertyName), - [System.Object] - ), - $($Parameter) - ) +Function Invoke-LoadMethod() { + param( + [Microsoft.SharePoint.Client.ClientObject]$Object = $(throw "Please provide a Client Object"), + [string]$PropertyName + ) + + $ctx = $Object.Context + $load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load") + $type = $Object.GetType() + $clientLoad = $load.MakeGenericMethod($type) + + + $Parameter = [System.Linq.Expressions.Expression]::Parameter(($type), $type.Name) + $Expression = [System.Linq.Expressions.Expression]::Lambda( + [System.Linq.Expressions.Expression]::Convert( + [System.Linq.Expressions.Expression]::PropertyOrField($Parameter,$PropertyName), + [System.Object] + ), + $($Parameter) + ) + $ExpressionArray = [System.Array]::CreateInstance($Expression.GetType(), 1) $ExpressionArray.SetValue($Expression, 0) $clientLoad.Invoke($ctx,@($Object,$ExpressionArray)) } -function Set-SPOUserRegionalSettings -{ - +function Set-SPOUserRegionalSettings{ param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - $AdminPassword, + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + $AdminPassword, [Parameter(Mandatory=$true,Position=3)] - [string]$Url, + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$LocaleID - ) + [string]$LocaleID + ) $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) @@ -49,12 +49,10 @@ function Set-SPOUserRegionalSettings Write-Host "Old locale id: " $ctx.Web.RegionalSettings.LocaleId.ToString() - $ctx.Web.RegionalSettings.LocaleId=$LocaleID -$ctx.Web.Update() -$ctx.ExecuteQuery() - - - } + $ctx.Web.RegionalSettings.LocaleId=$LocaleID + $ctx.Web.Update() + $ctx.ExecuteQuery() +} @@ -72,19 +70,14 @@ $LocaleID=1033 $users=get-SPOUser -Site $myhost -foreach($user in $users) -{ - - - if($user.LoginName.Contains('@')) - { +foreach($user in $users){ + if($user.LoginName.Contains('@')){ $persweb=$user.LoginName.Replace(".","_").Replace("@","_") $persweb=$myhost+"/personal/"+$persweb Write-Host $persweb $AdminUrl=$persweb - Set-SPOUserRegionalSettings -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -LocaleID $LocaleID } } diff --git a/OneDrive for Business/Update locale id for all personal sites/description.md b/OneDrive for Business/Update locale id for all personal sites/description.md index 08bac44b..e4c321ed 100644 --- a/OneDrive for Business/Update locale id for all personal sites/description.md +++ b/OneDrive for Business/Update locale id for all personal sites/description.md @@ -1,11 +1,11 @@ -Acknowledegement -The script uses Vadim Gremyachev's Invoke-LoadMethod published here +## Acknowledegement +The script uses [Vadim Gremyachev's](https://sharepoint.stackexchange.com/users/10610/vadim-gremyachev) Invoke-LoadMethod published [here](https://sharepoint.stackexchange.com/questions/126221/spo-retrieve-hasuniqueroleassignements-property-using-powershell) -Description +## Description The script updates locale id in regional settings of all personal sites to which you have access. The locale id can later be verified by going to Site Settings>Regional Settings. @@ -50,7 +50,7 @@ Set-SPOUser -Site $urelek -LoginName $username -IsSiteCollectionAdmin $true ``` -In order to use the cmdlet, you can either modify the.ps1 file or write a separate script. +In order to use the cmdlet, you can either modify the ```.ps1``` file or write a separate script. diff --git a/Permissions/Powershell/Delete unique permissions in all items in a large list (5000+ items)/ResetPermissionInheritanceLargeLists.ps1 b/Permissions/Powershell/Delete unique permissions in all items in a large list (5000+ items)/ResetPermissionInheritanceLargeLists.ps1 new file mode 100644 index 00000000..da8f3d5b --- /dev/null +++ b/Permissions/Powershell/Delete unique permissions in all items in a large list (5000+ items)/ResetPermissionInheritanceLargeLists.ps1 @@ -0,0 +1,93 @@ +function Restore-SPOListAllItemsInheritance +{ + + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + [SecureString]$AdminPassword, + [Parameter(Mandatory=$true,Position=4)] + [string]$ListTitle + ) + + + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.Load($ctx.Web.Lists) + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Web.Webs) + $ctx.ExecuteQuery() + $ll=$ctx.Web.Lists.GetByTitle($ListTitle) + $ctx.Load($ll) + $ctx.ExecuteQuery() + + ## View XML +$qCommand = @" + + + + + 5000 + +"@ +## Page Position +$position = $null + +## All Items +$allItems = @() +Do{ + $camlQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + $camlQuery.ListItemCollectionPosition = $position + $camlQuery.ViewXml = $qCommand + ## Executing the query + $currentCollection = $ll.GetItems($camlQuery) + $ctx.Load($currentCollection) + $ctx.ExecuteQuery() + + ## Getting the position of the previous page + $position = $currentCollection.ListItemCollectionPosition + + # Adding current collection to the allItems collection + $allItems += $currentCollection + + Write-Host "Collecting items. Current number of items: " $allItems.Count + + +} + while($position -ne $null) + + + Write-Host "Total number of items: " $allItems.Count + + for($j=0;$j -lt $allItems.Count ;$j++) + { + + Write-Host "Resetting permissions for " $allItems[$j]["Title"] ".." $allItems[$j]["FileRef"] + $allItems[$j].ResetRoleInheritance() + $ctx.ExecuteQuery() + + } + + + + + + + } + + +# Paths to SDK. Please verify location on your computer. +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" + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="arleta@TENANT.onmicrosoft.com" +$Url="https://TENANT.sharepoint.com/sites/testID1de" +$ListTitle="testitems" + + +Restore-SPOListAllItemsInheritance -Username $username -Url $Url -AdminPassword $AdminPassword -ListTitle $ListTitle diff --git a/Permissions/Powershell/Delete unique permissions in all items in a large list (5000+ items)/description.md b/Permissions/Powershell/Delete unique permissions in all items in a large list (5000+ items)/description.md new file mode 100644 index 00000000..f301226c --- /dev/null +++ b/Permissions/Powershell/Delete unique permissions in all items in a large list (5000+ items)/description.md @@ -0,0 +1,59 @@ +Powershell script to restore inherited permissions for all items in a SharePoint Online list. + + + +The script works with large (5000+) lists. + +In order to make it possible script uses a solution published here: http://www.sptrenches.com/2016/06/get-all-items-in-5000-large-list-with.html and commented by Sharath Aluri here: https://gallery.technet.microsoft.com/office/Delete-unique-permissions-c6ea2b57/view/Discussions#content. + + + +The script is a variation of Delete unique permissions in all items in one single list using Powershell script available on the Technet Gallery. + + + +Before you run it, you have to modify the last lines of the script! + + + + + +PowerShell +# Paths to SDK. Please verify location on your computer. +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" + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="arleta@TENANT.onmicrosoft.com" +$Url="https://TENANT.sharepoint.com/sites/testID1de" +$ListTitle="testitems" + + +Enter your credentials and the site where you want to modify the inheritance. +Verify if the SharePoint Online SDK is installed in the same location on your computer + + + + + + + + + + +Related scripts: + +Delete unique permissions in all items in one single list using Powershell + +Delete unique permissions for all lists + +Break inheritance for all lists + +Modify inherited permissions for a SharePoint Online site (module) + +Modify list permissions with Powershell cmdlets (module) + +Delete unique permissions (C# program) + +Get lists with unique permissions (C# program) diff --git a/Power Automate/Disable Flows in all lists on SharePoint site/description.md b/Power Automate/Disable Flows in all lists on SharePoint site/description.md index 5ed30198..20c7017b 100644 --- a/Power Automate/Disable Flows in all lists on SharePoint site/description.md +++ b/Power Automate/Disable Flows in all lists on SharePoint site/description.md @@ -1,35 +1,25 @@ Short Powershell script that disables flows for all lists and libraries in SharePoint Online modern site. -It modifies DisableFlows property of a SharePoint Online site. The script is related to and more described in an article Verifying and modifying Flows Policy in SharePoint Online site using Powershell on the TechNet Wiki. +It modifies DisableFlows property of a SharePoint Online site. The script is related to and more described in an article [Verifying and modifying Flows Policy in SharePoint Online site using Powershell](https://social.technet.microsoft.com/wiki/contents/articles/39331.sharepoint-online-verifying-and-modifying-flows-policy-in-site-using-powershell.aspx) on the TechNet Wiki. If the setting is set to disabled, the flows button will be missing on all lists and libraries in the site: - - - - - - - - - - - - - + + ### How to use? -Download and open the .ps1 file. -Add correct libraries: -PowerShell +- Download and open the .ps1 file. +- Add correct libraries: + +```PowerShell #Paths to SDK 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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" - -Enter the correct url and admin login: +``` +- Enter the correct url and admin login: ```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -37,7 +27,7 @@ $username="admin@TENANT.onmicrosoft.com" $AdminUrl="https://TENANT-admin.sharepoint.com" $Url="https://TENANT.sharepoint.com" ``` - Run the script +- Run the script diff --git a/Power Automate/Disable Flows in all lists on SharePoint site/disableFlows.ps1 b/Power Automate/Disable Flows in all lists on SharePoint site/disableFlows.ps1 index 917f43ec..426e46ba 100644 --- a/Power Automate/Disable Flows in all lists on SharePoint site/disableFlows.ps1 +++ b/Power Automate/Disable Flows in all lists on SharePoint site/disableFlows.ps1 @@ -1,15 +1,14 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$AdminUrl, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $Password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] $Url - ) + ) $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Adminurl) @@ -47,4 +46,4 @@ $Url="https://TENANT.sharepoint.com" -Set-SiteColl -Username $username -AdminUrl $AdminUrl -password $AdminPassword -Url $Url \ No newline at end of file +Set-SiteColl -Username $username -AdminUrl $AdminUrl -password $AdminPassword -Url $Url diff --git a/Power Automate/Enable Microsoft Flow in all lists on SharePoint modern site/description.md b/Power Automate/Enable Microsoft Flow in all lists on SharePoint modern site/description.md index dd6d4147..7b991c5e 100644 --- a/Power Automate/Enable Microsoft Flow in all lists on SharePoint modern site/description.md +++ b/Power Automate/Enable Microsoft Flow in all lists on SharePoint modern site/description.md @@ -1,48 +1,33 @@ Short Powershell script that enables flows for all lists and libraries in SharePoint Online modern site. -It modifies DisableFlows property of a SharePoint Online site. The script is related to and more described in an article Verifying and modifying Flows Policy in SharePoint Online site using Powershell on the TechNet Wiki. +It modifies DisableFlows property of a SharePoint Online site. The script is related to and more described in an article [Verifying and modifying Flows Policy in SharePoint Online site using Powershell](https://social.technet.microsoft.com/wiki/contents/articles/39331.sharepoint-online-verifying-and-modifying-flows-policy-in-site-using-powershell.aspx) on the TechNet Wiki. If the setting is set to disabled, the flows button will be missing on all lists and libraries in the site: + + - - - - - +## How to use? +- Download and open the .ps1 file. +- Add correct libraries: - - - - - - -How to use? -Download and open the .ps1 file. -Add correct libraries: - - -PowerShell +```PowerShell #Paths to SDK 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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" + ``` +- Enter the correct url and admin login: - -Enter the correct url and admin login: - - -PowerShell +```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $AdminUrl="https://TENANT-admin.sharepoint.com" $Url="https://TENANT.sharepoint.com" - - - - Run the script + ``` + - Run the script diff --git a/Power Automate/Enable Microsoft Flow in all lists on SharePoint modern site/enableFlows.ps1 b/Power Automate/Enable Microsoft Flow in all lists on SharePoint modern site/enableFlows.ps1 index 20d0f830..e2055749 100644 --- a/Power Automate/Enable Microsoft Flow in all lists on SharePoint modern site/enableFlows.ps1 +++ b/Power Automate/Enable Microsoft Flow in all lists on SharePoint modern site/enableFlows.ps1 @@ -1,15 +1,14 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$AdminUrl, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $Password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] $Url - ) + ) $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Adminurl) @@ -47,4 +46,4 @@ $Url="https://TENANT.sharepoint.com" -Set-SiteColl -Username $username -AdminUrl $AdminUrl -password $AdminPassword -Url $Url \ No newline at end of file +Set-SiteColl -Username $username -AdminUrl $AdminUrl -password $AdminPassword -Url $Url diff --git a/Power Automate/Get FlowsPolicy using REST API/description.md b/Power Automate/Get FlowsPolicy using REST API/description.md index 0f0474e2..d8706e41 100644 --- a/Power Automate/Get FlowsPolicy using REST API/description.md +++ b/Power Automate/Get FlowsPolicy using REST API/description.md @@ -1,40 +1,24 @@ -Powershell script that verifies DisableFlows property of a SharePoint Online site. The script is related to and more described in an article Verifying and modifying Flows Policy in SharePoint Online site using Powershell on the TechNet Wiki. +Powershell script that verifies DisableFlows property of a SharePoint Online site. The script is related to and more described in an article [Verifying and modifying Flows Policy in SharePoint Online site using Powershell](https://social.technet.microsoft.com/wiki/contents/articles/39331.sharepoint-online-verifying-and-modifying-flows-policy-in-site-using-powershell.aspx) on the TechNet Wiki. If the setting is set to disabled, the flows button will be missing on all lists and libraries in the site: - - - - - - - + + The property can also be verified using REST API in the browser: + - - - - - - - - - - - - - -How to use? -Download and open the .ps1 file. -Enter the correct url and admin login: -PowerShell +## How to use? +- Download and open the .ps1 file. +- Enter the correct url and admin login: +```PowerShell $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT.sharepoint.com" - Run the script +``` +- Run the script diff --git a/Power Automate/Get FlowsPolicy using REST API/flowsWithRest.ps1 b/Power Automate/Get FlowsPolicy using REST API/flowsWithRest.ps1 index df21b879..ff7c5f8a 100644 --- a/Power Automate/Get FlowsPolicy using REST API/flowsWithRest.ps1 +++ b/Power Automate/Get FlowsPolicy using REST API/flowsWithRest.ps1 @@ -1,26 +1,21 @@ -function Get-SPOFlowSetting -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOFlowSetting{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$false,Position=2)] + [Parameter(Mandatory=$false,Position=2)] [SecureString] $password = (Read-Host -AsSecureString), - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string] $url, - [Parameter(Mandatory=$false,Position=4)] - [string] $object="" - ) - - + [Parameter(Mandatory=$false,Position=4)] + [string] $object="" + ) - $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $RestUrl=$url+"/_api/site/" - if($object -ne "") - { - $RestUrl+=$object - } - - + $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $RestUrl=$url+"/_api/site/" + + if($object -ne ""){ + $RestUrl+=$object + } $request = [System.Net.WebRequest]::Create($RESTUrl) $request.Credentials = $Credentials @@ -34,13 +29,7 @@ param ( $data=$read.ReadToEnd() $results = $data | ConvertFrom-Json Write-Output $results.d - - - - - - - } +} diff --git a/SiteMailboxes/mailb.ps1 b/SiteMailboxes/mailb.ps1 index b2dc6dac..fbbf65f3 100644 --- a/SiteMailboxes/mailb.ps1 +++ b/SiteMailboxes/mailb.ps1 @@ -69,15 +69,11 @@ import-pssession $sesja $sitecollections=Get-SPOSite Write-Host "Found site collections:" -foreach($sitecoll in $sitecollections) -{ +foreach($sitecoll in $sitecollections){ Write-Host $sitecoll.Url } - - -function Add-MailboxToSite($urelek) -{ +function Add-MailboxToSite($urelek){ $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($urelek) $ctx.Credentials= New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $rootWeb = $ctx.Web @@ -94,36 +90,30 @@ function Add-MailboxToSite($urelek) new-sitemailbox -displayName $rootWeb.Title -SharePointUrl $rootWeb.Url - foreach($site in $sites) - { + foreach($site in $sites){ $site.Features.Add($featureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None) | Out-Null $ctx.ExecuteQuery() Write-Host "Feature enabled for" $site.Url - } - Write-Host "Finished enabling site mailbox feature on" $rootWeb.Title " : " $rootWeb.Url - + } + + Write-Host "Finished enabling site mailbox feature on" $rootWeb.Title " : " $rootWeb.Url - foreach($site in $sites) - { - Write-Host "Trying to add mailbox for" $site.Url - new-sitemailbox -displayName $site.Title -SharePointUrl $site.Url -ErrorAction SilentlyContinue | Out-Null } + foreach($site in $sites){ + Write-Host "Trying to add mailbox for" $site.Url + new-sitemailbox -displayName $site.Title -SharePointUrl $site.Url -ErrorAction SilentlyContinue | Out-Null } Write-Host "Finished adding mailboxes on" $rootWeb.Title " : " $rootWeb.Url - - if($ctx.Web.Webs.Count -gt 0) - { - for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++) - { + if($ctx.Web.Webs.Count -gt 0){ + for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++){ Add-MailboxToSite($ctx.Web.Webs[$i].Url) } } } - foreach($sitecoll in $sitecollections) -{ - Add-MailboxToSite($sitecoll.Url) -} + foreach($sitecoll in $sitecollections){ + Add-MailboxToSite($sitecoll.Url) + } #Finishes by saving a transcript of the whole run to a local folder Stop-Transcript diff --git a/SiteMailboxes/mailbox1.ps1 b/SiteMailboxes/mailbox1.ps1 index 65730096..adb4809c 100644 --- a/SiteMailboxes/mailbox1.ps1 +++ b/SiteMailboxes/mailbox1.ps1 @@ -78,22 +78,20 @@ new-sitemailbox -displayName $rootWeb.Title -SharePointUrl $rootWeb.Url #adding the feature and the mailbox for all the subsites. It checks for first-level subsites. If your structure is more complex, you need to add more loops - foreach($site in $sites) - { +foreach($site in $sites){ $site.Features.Add($featureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None) $ctx.ExecuteQuery() Write-Host "Feature enabled for" $site.Url - } - Write-Host "Finished enabling site mailbox feature." +} + +Write-Host "Finished enabling site mailbox feature." - - foreach($site in $sites) - { +foreach($site in $sites){ new-sitemailbox -displayName $site.Title -SharePointUrl $site.Url - } +} - Write-Host "Finished adding mailboxes." +Write-Host "Finished adding mailboxes." #Finishes by saving a transcript of the whole run to a local folder - Stop-Transcript \ No newline at end of file + Stop-Transcript diff --git a/Tenant Settings/Add BCC to all sharing invitations in OneDrive for Business/BccExternalSharingInvitations.ps1 b/Tenant Settings/Add BCC to all sharing invitations in OneDrive for Business/BccExternalSharingInvitations.ps1 new file mode 100644 index 00000000..c143e6dd --- /dev/null +++ b/Tenant Settings/Add BCC to all sharing invitations in OneDrive for Business/BccExternalSharingInvitations.ps1 @@ -0,0 +1,35 @@ +function Set-SPOTenant{ + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + $password + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.BccExternalSharingInvitations=$true + $spoTenant.BccExternalSharingInvitationsList={arleta.wanat@SomeFakeAdresse.com} + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant +} + +#Paths to SDK +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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" + +Set-SPOTenant -Username $username -Url $Url -password $AdminPassword diff --git a/Tenant Settings/Add BCC to all sharing invitations in OneDrive for Business/Untitled099.png b/Tenant Settings/Add BCC to all sharing invitations in OneDrive for Business/Untitled099.png new file mode 100644 index 00000000..3df79a6f Binary files /dev/null and b/Tenant Settings/Add BCC to all sharing invitations in OneDrive for Business/Untitled099.png differ diff --git a/Tenant Settings/Add BCC to all sharing invitations in OneDrive for Business/description.md b/Tenant Settings/Add BCC to all sharing invitations in OneDrive for Business/description.md new file mode 100644 index 00000000..a4152221 --- /dev/null +++ b/Tenant Settings/Add BCC to all sharing invitations in OneDrive for Business/description.md @@ -0,0 +1,29 @@ +Short Powershell script to send bcc copies to all sharing invitations send from users' OneDrives for Business. The script uses CSOM with December 2015 update. + +## How to use? + +- Download and open the .ps1 file. +- Add correct SharePoint Online SDK libraries: + + +```PowerShell +#Paths to SDK +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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` +- Enter the correct url, and admin login. Under InvitationsList, enter the email addresses that you want to add in BCC to every sharing invitation in your users' OneDrive for Business. You will be additionally prompted for the password. Do not enter it in the file: +```PowerShell + $spoTenant.BccExternalSharingInvitationsList={arleta.wanat@SomeFakeAdresse.com} + + + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" + ``` +- Run the script + +After the setting takes place, the BCC emails will start receiving copies of the sharing invitations with Invited person's email in the "TO" field and inviter's in "CC": + + diff --git a/Tenant Settings/Allow external sharing only with specific domains/SharingAllowedDomainList.ps1 b/Tenant Settings/Allow external sharing only with specific domains/SharingAllowedDomainList.ps1 index 8a5388a3..6d2520cc 100644 --- a/Tenant Settings/Allow external sharing only with specific domains/SharingAllowedDomainList.ps1 +++ b/Tenant Settings/Allow external sharing only with specific domains/SharingAllowedDomainList.ps1 @@ -1,50 +1,38 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] $AllowDomainList - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - $spoTenant.SharingDomainRestrictionMode=[Microsoft.Online.SharePoint.TenantManagement.SharingDomainRestrictionModes]::AllowList - $spoTenant.SharingAllowedDomainList=$AllowDomainList - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - Write-Output $spoTenant - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.SharingDomainRestrictionMode=[Microsoft.Online.SharePoint.TenantManagement.SharingDomainRestrictionModes]::AllowList + $spoTenant.SharingAllowedDomainList=$AllowDomainList + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" - - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $AllowDomainList="test.com madeup.com" - - - - -Set-SiteColl -Username $username -Url $Url -password $AdminPassword -AllowDomainList $AllowDomainList \ No newline at end of file +Set-SiteColl -Username $username -Url $Url -password $AdminPassword -AllowDomainList $AllowDomainList diff --git a/Tenant Settings/Allow external sharing only with specific domains/description.md b/Tenant Settings/Allow external sharing only with specific domains/description.md index 707c197e..c0257d59 100644 --- a/Tenant Settings/Allow external sharing only with specific domains/description.md +++ b/Tenant Settings/Allow external sharing only with specific domains/description.md @@ -2,22 +2,23 @@ Short Powershell script that limits external sharing in SharePoint Online to onl -The script is related to and more described in a Wiki article SharePoint Online Sharing settings with CSOM. +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). -### How to use? -Download and open the .ps1 file. -Add correct libraries: +## How to use? + +- Download and open the .ps1 file. +- Add correct libraries: ``` PowerShell #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" ``` -Enter the correct url and admin login: +- Enter the correct url and admin login: ```PowerShell @@ -27,5 +28,5 @@ $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $AllowDomainList="test.com madeup.com" ``` -Run the script +- Run the script diff --git a/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/0882BlockDownload.png b/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/0882BlockDownload.png new file mode 100644 index 00000000..68c46b09 Binary files /dev/null and b/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/0882BlockDownload.png differ diff --git a/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/1462BlockDownload2.png b/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/1462BlockDownload2.png new file mode 100644 index 00000000..2be6bac5 Binary files /dev/null and b/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/1462BlockDownload2.png differ diff --git a/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/BlockDownloadOfAllFilesForGuests.ps1 b/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/BlockDownloadOfAllFilesForGuests.ps1 new file mode 100644 index 00000000..52dca44c --- /dev/null +++ b/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/BlockDownloadOfAllFilesForGuests.ps1 @@ -0,0 +1,48 @@ +function Set-SPOTenant +{ +param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + $password, + [Parameter(Mandatory=$true,Position=4)] + [Bool]$BlockDownloadOfAllFilesForGuests + ) + + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.BlockDownloadOfAllFilesForGuests=$BlockDownloadOfAllFilesForGuests + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant + +} + + + + +#Paths to SDK +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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" + + + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$BlockDownloadOfAllFilesForGuests=$false #Whether the download should be allowed + + + + +Set-SPOTenant -Username $username -Url $Url -password $AdminPassword -BlockDownloadOfAllFilesForGuests $BlockDownloadOfAllFilesForGuests \ No newline at end of file diff --git a/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/description.md b/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/description.md new file mode 100644 index 00000000..f7154227 --- /dev/null +++ b/Tenant Settings/Block download of all files for guests in SharePoint with Powershell and CSOM/description.md @@ -0,0 +1,49 @@ +Short Powershell script that prevents external users from downloading the files that have been shared with them using guest link. The script uses CSOM and requires SharePoint Online SDK. The script is described in and is part of Wiki Technet article OneDrive for Business sharing settings with PowerShell . + +Modifying these settings is currently not possible with SharePoint Online Management Shell. + + + + + + +From August 2016 and the CSOM version 16.1.5626.1200 there is an option to prevent external users from downloading the files that have been shared with them using guest link: + + + + + + + + + + + + + + +How to use? +Download and open the .ps1 file. +Add correct SharePoint Online SDK libraries: + + +```PowerShell +#Paths to SDK +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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` Enter the correct url, the setting for the sync button, and admin login. You will be additionally prompted for the password. Do not enter it in the file: + + +```PowerShell + #Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$BlockDownloadOfAllFilesForGuests=$false #Whether the download should be allowed +``` + Run the script + + + + + diff --git a/Tenant Settings/Force external users to accept sharing invitations with the same account/RequireAcceptingAccountMatchInvitedAccount.ps1 b/Tenant Settings/Force external users to accept sharing invitations with the same account/RequireAcceptingAccountMatchInvitedAccount.ps1 index 49b50751..1b8470c6 100644 --- a/Tenant Settings/Force external users to accept sharing invitations with the same account/RequireAcceptingAccountMatchInvitedAccount.ps1 +++ b/Tenant Settings/Force external users to accept sharing invitations with the same account/RequireAcceptingAccountMatchInvitedAccount.ps1 @@ -1,49 +1,37 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] - $RequireAcceptingAccountMatchInvitedAccount - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - $spoTenant.RequireAcceptingAccountMatchInvitedAccount=$RequireAcceptingAccountMatchInvitedAccount - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - Write-Output $spoTenant - + [Parameter(Mandatory=$true,Position=4)] + $RequireAcceptingAccountMatchInvitedAccount + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.RequireAcceptingAccountMatchInvitedAccount=$RequireAcceptingAccountMatchInvitedAccount + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" - - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $RequireAcceptingAccountMatchInvitedAccount=$true - - - - -Set-SiteColl -Username $username -Url $Url -password $AdminPassword -RequireAcceptingAccountMatchInvitedAccount $RequireAcceptingAccountMatchInvitedAccount \ No newline at end of file +Set-SiteColl -Username $username -Url $Url -password $AdminPassword -RequireAcceptingAccountMatchInvitedAccount $RequireAcceptingAccountMatchInvitedAccount diff --git a/Tenant Settings/Force external users to accept sharing invitations with the same account/description.md b/Tenant Settings/Force external users to accept sharing invitations with the same account/description.md index 18904912..b960b28e 100644 --- a/Tenant Settings/Force external users to accept sharing invitations with the same account/description.md +++ b/Tenant Settings/Force external users to accept sharing invitations with the same account/description.md @@ -2,28 +2,29 @@ Short PowerShell script to force external users to accept sharing invitations wi It is one of the 3 additional settings: -Limit external sharing using domains -Prevent external users from sharing files, folders, and sites that they don’t own -External users must accept sharing invitations using the same account that the invitations were sent to +- Limit external sharing using domains +- Prevent external users from sharing files, folders, and sites that they don’t own +- External users must accept sharing invitations using the same account that the invitations were sent to -The script is related to and more described in a Wiki article SharePoint Online Sharing settings with CSOM. +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). - + ### How to use? -Download and open the .ps1 file. -Add correct libraries: + +- Download and open the .ps1 file. +- Add correct libraries: ```PowerShell #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" -```Enter the correct url and admin login: - +``` +- Enter the correct url and admin login: ```PowerShell #Enter the data @@ -31,4 +32,5 @@ $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $RequireAcceptingAccountMatchInvitedAccount=$true -``` Run the script +``` +- Run the script diff --git a/Tenant Settings/Get SharePoint Online tenant properties using Powershell and CSOM/README.md b/Tenant Settings/Get SharePoint Online tenant properties using Powershell and CSOM/README.md index 2bc03c88..bd1e3b59 100644 --- a/Tenant Settings/Get SharePoint Online tenant properties using Powershell and CSOM/README.md +++ b/Tenant Settings/Get SharePoint Online tenant properties using Powershell and CSOM/README.md @@ -152,22 +152,15 @@ ServerObjectIsNull : False TypedObject - - - - - Expected results +## Expected results - - - + - +## How to use? -### How to use? -Download and open the .ps1 file. -Add correct libraries: +- Download and open the .ps1 file. +- Add correct libraries: ```PowerShell @@ -175,7 +168,7 @@ Add correct libraries: 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" ``` -Enter the correct url and admin login: +- Enter the correct url and admin login: ```PowerShell @@ -185,5 +178,5 @@ $Url="https://TENANT-admin.sharepoint.com" ``` - Run the script +- Run the script diff --git a/Tenant Settings/Get SharePoint Online tenant properties using Powershell and CSOM/tenantProps.ps1 b/Tenant Settings/Get SharePoint Online tenant properties using Powershell and CSOM/tenantProps.ps1 index 91bf582e..5288f776 100644 --- a/Tenant Settings/Get SharePoint Online tenant properties using Powershell and CSOM/tenantProps.ps1 +++ b/Tenant Settings/Get SharePoint Online tenant properties using Powershell and CSOM/tenantProps.ps1 @@ -1,43 +1,33 @@ -function Get-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password - ) + ) + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - - Write-Output $spoTenant + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" #Microsoft.Online.SharePoint.TenantAdministration.SiteProperties.AllowLimitedAccess - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" - - - -Get-SiteColl -Username $username -Url $Url -password $AdminPassword \ No newline at end of file +Get-SiteColl -Username $username -Url $Url -password $AdminPassword diff --git a/Tenant Settings/Globally set OneDrive for Business Access Requests and Members Can Share/ODBAccessRequests.PNG b/Tenant Settings/Globally set OneDrive for Business Access Requests and Members Can Share/ODBAccessRequests.PNG new file mode 100644 index 00000000..7f7ba526 Binary files /dev/null and b/Tenant Settings/Globally set OneDrive for Business Access Requests and Members Can Share/ODBAccessRequests.PNG differ diff --git a/Tenant Settings/Globally set OneDrive for Business Access Requests and Members Can Share/ODBAccessRequests.ps1 b/Tenant Settings/Globally set OneDrive for Business Access Requests and Members Can Share/ODBAccessRequests.ps1 new file mode 100644 index 00000000..70a663da --- /dev/null +++ b/Tenant Settings/Globally set OneDrive for Business Access Requests and Members Can Share/ODBAccessRequests.ps1 @@ -0,0 +1,54 @@ +function Set-SiteColl +{ +param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + $password, + [Parameter(Mandatory=$true)] + $ODBMembersCanShare, + [Parameter(Mandatory=$true)] + $ODBAccessRequests + ) + + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.ODBAccessRequests =[Microsoft.SharePoint.Client.SharingState]::$ODBAccessRequests + $spoTenant.ODBMembersCanShare=[Microsoft.SharePoint.Client.SharingState]::$ODBMembersCanShare + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant + +} + + + + +#Paths to SDK +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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" + + + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$ODBMembersCanShare="On" # On, Off, Unspecified +$ODBAccessRequests="Unspecified" #On, Off, Unspecified + + + + + + +Set-SiteColl -Username $username -Url $Url -password $AdminPassword -ODBMembersCanShare $ODBMembersCanShare -ODBAccessRequests $ODBAccessRequests \ No newline at end of file diff --git a/Tenant Settings/Globally set OneDrive for Business Access Requests and Members Can Share/description.md b/Tenant Settings/Globally set OneDrive for Business Access Requests and Members Can Share/description.md new file mode 100644 index 00000000..7a13599f --- /dev/null +++ b/Tenant Settings/Globally set OneDrive for Business Access Requests and Members Can Share/description.md @@ -0,0 +1,44 @@ +Short Powershell script that modifies the following settings on every user's OneDrive for Business: + + + + + +On- Users with edit permissions can re-share. + +Off- Only OneDrive for Business owner can share. The value of ODBAccessRequestsdefines whether a request to share gets sent to the owner. + +Unspecified- Let each OneDrive for Business owner enable or disable re-sharing behavior on their OneDrive. + + + + + +The script is part of Technet Wiki article OneDrive for Business sharing settings with Powershell. + +## How to use? +Download and open the .ps1 file. +Add correct SharePoint Online SDK libraries: + + +```PowerShell +#Paths to SDK +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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` Enter the correct url, the setting for the sync button, and admin login. You will be additionally prompted for the password. Do not enter it in the file: +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$ODBMembersCanShare="On" # On, Off, Unspecified +$ODBAccessRequests="Unspecified" #On, Off, Unspecified +``` + + + Run the script + + + + + diff --git a/Tenant Settings/Hide OneDrive for Business Sync button using PS and CSOM/HideSyncButtonOnODB.ps1 b/Tenant Settings/Hide OneDrive for Business Sync button using PS and CSOM/HideSyncButtonOnODB.ps1 new file mode 100644 index 00000000..6e40036d --- /dev/null +++ b/Tenant Settings/Hide OneDrive for Business Sync button using PS and CSOM/HideSyncButtonOnODB.ps1 @@ -0,0 +1,37 @@ +function Set-SPOTenant{ + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + $password, + [Parameter(Mandatory=$true,Position=4)] + [Bool]$HideSyncButtonOnODB + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.HideSyncButtonOnODB=$HideSyncButtonOnODB + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant +} + +#Paths to SDK +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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="arleta@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$HideSyncButtonOnODB=$true #Whether the sync button should be hidden + +Set-SPOTenant -Username $username -Url $Url -password $AdminPassword -HideSyncButtonOnODB $HideSyncButtonOnODB diff --git a/Tenant Settings/Hide OneDrive for Business Sync button using PS and CSOM/ODBAccessRequests.222ENG.PNG b/Tenant Settings/Hide OneDrive for Business Sync button using PS and CSOM/ODBAccessRequests.222ENG.PNG new file mode 100644 index 00000000..db2067de Binary files /dev/null and b/Tenant Settings/Hide OneDrive for Business Sync button using PS and CSOM/ODBAccessRequests.222ENG.PNG differ diff --git a/Tenant Settings/Hide OneDrive for Business Sync button using PS and CSOM/description.md b/Tenant Settings/Hide OneDrive for Business Sync button using PS and CSOM/description.md new file mode 100644 index 00000000..d2189e8a --- /dev/null +++ b/Tenant Settings/Hide OneDrive for Business Sync button using PS and CSOM/description.md @@ -0,0 +1,34 @@ +Short Powershell script that hides Sync button in OneDrive for Business for all users. + + + +The script uses CSOM and requires SharePoint Online SDK. + + + +This button will be removed with the script: + + + +### How to use? +- Download and open the ```.ps1``` file. +- Add correct SharePoint Online SDK libraries: + +```PowerShell +#Paths to SDK +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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` + +- Enter the correct url, the setting for the sync button, and admin login. You will be additionally prompted for the password. Do not enter it in the file: + +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="arleta@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$HideSyncButtonOnODB=$true #Whether the sync button should be hidden +``` + +- Run the script + diff --git a/Tenant Settings/Modify external sharing setting/SharingCapability.ps1 b/Tenant Settings/Modify external sharing setting/SharingCapability.ps1 index 51542efa..f59c6674 100644 --- a/Tenant Settings/Modify external sharing setting/SharingCapability.ps1 +++ b/Tenant Settings/Modify external sharing setting/SharingCapability.ps1 @@ -1,50 +1,38 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] - $SharingCapability - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - - $spoTenant.SharingCapability=[Microsoft.Online.SharePoint.TenantManagement.SharingCapabilities]::$SharingCapability - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - Write-Output $spoTenant - + [Parameter(Mandatory=$true,Position=4)] + $SharingCapability + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + + $spoTenant.SharingCapability=[Microsoft.Online.SharePoint.TenantManagement.SharingCapabilities]::$SharingCapability + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" - - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $SharingCapability="Disabled" # Disabled, ExternalUserSharingOnly, ExternalUserAndGuestSharing, ExistingExternalUserSharingOnly - - - - -Set-SiteColl -Username $username -Url $Url -password $AdminPassword -SharingCapability $SharingCapability \ No newline at end of file +Set-SiteColl -Username $username -Url $Url -password $AdminPassword -SharingCapability $SharingCapability diff --git a/Tenant Settings/Modify external sharing setting/description.md b/Tenant Settings/Modify external sharing setting/description.md index 03e80910..6c4018ca 100644 --- a/Tenant Settings/Modify external sharing setting/description.md +++ b/Tenant Settings/Modify external sharing setting/description.md @@ -5,27 +5,22 @@ It requires SharePoint Online SDK. The script is part of and more described in a TechNet Wiki [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom.aspx?Sort=MostRecent&PageIndex=1) article. +## How to use? +- Download and open the .ps1 file. +- Add correct libraries: - - - - - -###How to use? -Download and open the .ps1 file. -Add correct libraries: - - ```PowerShell #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" -```Enter the correct url and admin login: +``` +- Enter the correct url and admin login: ```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $SharingCapability="Disabled" # Disabled, ExternalUserSharingOnly, ExternalUserAndGuestSharing, ExistingExternalUserSharingOnly -```Run the script +``` +- Run the script diff --git a/Tenant Settings/Notify OneDrive for Business owner if anonymous link to their content is created/OwnerAnonymousNotification.ps1 b/Tenant Settings/Notify OneDrive for Business owner if anonymous link to their content is created/OwnerAnonymousNotification.ps1 index 6afcce9e..23282e52 100644 --- a/Tenant Settings/Notify OneDrive for Business owner if anonymous link to their content is created/OwnerAnonymousNotification.ps1 +++ b/Tenant Settings/Notify OneDrive for Business owner if anonymous link to their content is created/OwnerAnonymousNotification.ps1 @@ -1,41 +1,33 @@ -function Set-SPOTenant -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SPOTenant{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [Bool]$OwnerAnonymousNotification - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - $spoTenant.NotificationsInOneDriveForBusinessEnabled =$true - $spoTenant.OwnerAnonymousNotification=$OwnerAnonymousNotification - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - Write-Output $spoTenant - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.NotificationsInOneDriveForBusinessEnabled =$true + $spoTenant.OwnerAnonymousNotification=$OwnerAnonymousNotification + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" - - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -43,7 +35,4 @@ $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $OwnerAnonymousNotification=$true #Whether ODB owner should be notified when anonymous link is created or changed - - - -Set-SPOTenant -Username $username -Url $Url -password $AdminPassword -OwnerAnonymousNotification $OwnerAnonymousNotification \ No newline at end of file +Set-SPOTenant -Username $username -Url $Url -password $AdminPassword -OwnerAnonymousNotification $OwnerAnonymousNotification diff --git a/Tenant Settings/Notify OneDrive for Business owner if anonymous link to their content is created/description.md b/Tenant Settings/Notify OneDrive for Business owner if anonymous link to their content is created/description.md index 626a5826..09e4549a 100644 --- a/Tenant Settings/Notify OneDrive for Business owner if anonymous link to their content is created/description.md +++ b/Tenant Settings/Notify OneDrive for Business owner if anonymous link to their content is created/description.md @@ -1,22 +1,22 @@ Short Powershell script that enables or disables a setting to send emails to OneDrive for Business owners when someone creates an anonymous link to the ODB owner's content. It uses CSOm and requires SharePoint Online SDK. The script is part of and more explained in a Technet Wiki article: -OneDrive for Business notification settings with Powershell +[OneDrive for Business notification settings with Powershell](https://social.technet.microsoft.com/wiki/contents/articles/39385.onedrive-for-business-notifications-with-powershell.aspx) -###How to use? -Download and open the .ps1 file. -Add correct libraries: - +## How to use? +- Download and open the .ps1 file. +- Add correct libraries: + ```PowerShell #Paths to SDK 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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" ``` +- Enter the correct url and admin login: -Enter the correct url and admin login: ```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -25,5 +25,4 @@ $Url="https://TENANT-admin.sharepoint.com" $OwnerAnonymousNotification=$true #Whether ODB owner should be notified when anonymous link is created or changed ``` - - Run the script +- Run the script diff --git a/Tenant Settings/Notify OneDrive for Business owner if their content is reshared/NotifyOwnersWhenItemsReshared.ps1 b/Tenant Settings/Notify OneDrive for Business owner if their content is reshared/NotifyOwnersWhenItemsReshared.ps1 new file mode 100644 index 00000000..7bf757ae --- /dev/null +++ b/Tenant Settings/Notify OneDrive for Business owner if their content is reshared/NotifyOwnersWhenItemsReshared.ps1 @@ -0,0 +1,37 @@ +function Set-SPOTenant{ + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + $password, + [Parameter(Mandatory=$true,Position=4)] + [Bool]$NotifyOwnersWhenItemsReshared + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.NotifyOwnersWhenItemsReshared=$NotifyOwnersWhenItemsReshared + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant +} + +#Paths to SDK +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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$NotifyOwnersWhenItemsReshared=$true #Whether ODB owner should be notified the content is reshared with external users + +Set-SPOTenant -Username $username -Url $Url -password $AdminPassword -NotifyOwnersWhenItemsReshared $NotifyOwnersWhenItemsReshared diff --git a/Tenant Settings/Notify OneDrive for Business owner if their content is reshared/description.md b/Tenant Settings/Notify OneDrive for Business owner if their content is reshared/description.md new file mode 100644 index 00000000..a7c3e28e --- /dev/null +++ b/Tenant Settings/Notify OneDrive for Business owner if their content is reshared/description.md @@ -0,0 +1,28 @@ +Short Powershell script that enables or disables a setting to send emails to OneDrive for Business owners when someone further shares the ODB owner's content with external users. + +It uses CSOM and requires SharePoint Online SDK. The script is part of and more explained in a Technet Wiki article: + +[OneDrive for Business notification settings with Powershell](https://social.technet.microsoft.com/wiki/contents/articles/39385.onedrive-for-business-notifications-with-powershell.aspx) + +## How to use? + +- Download and open the .ps1 file. +- Add correct libraries: + +```PowerShell +#Paths to SDK +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\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` + +- ter the correct url and admin login: + +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$NotifyOwnersWhenItemsReshare=$true #Whether ODB owner should be notified the content is reshared with external users +``` + +- Run the script diff --git a/Tenant Settings/Prevent external users from resharing/PreventExternalUsersFromResharing.ps1 b/Tenant Settings/Prevent external users from resharing/PreventExternalUsersFromResharing.ps1 index 763cc092..13ea638e 100644 --- a/Tenant Settings/Prevent external users from resharing/PreventExternalUsersFromResharing.ps1 +++ b/Tenant Settings/Prevent external users from resharing/PreventExternalUsersFromResharing.ps1 @@ -1,40 +1,32 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] - $PreventExternalUsersFromResharing - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - $spoTenant.PreventExternalUsersFromResharing=$PreventExternalUsersFromResharing - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - Write-Output $spoTenant - + [Parameter(Mandatory=$true,Position=4)] + $PreventExternalUsersFromResharing + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.PreventExternalUsersFromResharing=$PreventExternalUsersFromResharing + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" - - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -42,8 +34,4 @@ $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $PreventExternalUsersFromResharing=$true - - - - -Set-SiteColl -Username $username -Url $Url -password $AdminPassword -PreventExternalUsersFromResharing $PreventExternalUsersFromResharing \ No newline at end of file +Set-SiteColl -Username $username -Url $Url -password $AdminPassword -PreventExternalUsersFromResharing $PreventExternalUsersFromResharing diff --git a/Tenant Settings/Prevent external users from resharing/description.md b/Tenant Settings/Prevent external users from resharing/description.md index ee55c795..abd5f1a8 100644 --- a/Tenant Settings/Prevent external users from resharing/description.md +++ b/Tenant Settings/Prevent external users from resharing/description.md @@ -2,31 +2,26 @@ Short PowerShell script to prevent external users from sharing files, folders, a It is one of the 3 additional settings: -Limit external sharing using domains -Prevent external users from sharing files, folders, and sites that they don’t own -External users must accept sharing invitations using the same account that the invitations were sent to +- Limit external sharing using domains +- Prevent external users from sharing files, folders, and sites that they don’t own +- External users must accept sharing invitations using the same account that the invitations were sent to + - - -The script is related to and more described in a Wiki article SharePoint Online Sharing settings with CSOM. +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). - +## How to use? -How to use? -Download and open the .ps1 file. -Add correct libraries: +- Download and open the .ps1 file. +- Add correct libraries: - ```PowerShell #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" ``` - -Enter the correct url and admin login: - +- Enter the correct url and admin login: ```PowerShell #Enter the data @@ -35,8 +30,7 @@ $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $PreventExternalUsersFromResharing=$true ``` - - Run the script +- Run the script diff --git a/Tenant Settings/Set Anonymous access for SPO tenant using PS and CSOM/SetAnonymousAccess.ps1 b/Tenant Settings/Set Anonymous access for SPO tenant using PS and CSOM/SetAnonymousAccess.ps1 index 7e563b89..c296d84d 100644 --- a/Tenant Settings/Set Anonymous access for SPO tenant using PS and CSOM/SetAnonymousAccess.ps1 +++ b/Tenant Settings/Set Anonymous access for SPO tenant using PS and CSOM/SetAnonymousAccess.ps1 @@ -1,45 +1,37 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string]$LinkType, - [Parameter(Mandatory=$true,Position=5)] + [Parameter(Mandatory=$true,Position=5)] [string]$FolderLinkType - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - $spoTenant.SharingCapability=[Microsoft.Online.SharePoint.TenantManagement.SharingCapabilities]::ExternalUserAndGuestSharing - $spoTenant.FileAnonymousLinkType=[Microsoft.SharePoint.Client.AnonymousLinkType]::$LinkType - $spoTenant.FolderAnonymousLinkType=$FolderLinkType - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - Write-Output $spoTenant - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.SharingCapability=[Microsoft.Online.SharePoint.TenantManagement.SharingCapabilities]::ExternalUserAndGuestSharing + $spoTenant.FileAnonymousLinkType=[Microsoft.SharePoint.Client.AnonymousLinkType]::$LinkType + $spoTenant.FolderAnonymousLinkType=$FolderLinkType + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" - - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" @@ -47,6 +39,4 @@ $Url="https://TENANT-admin.sharepoint.com" $LinkType="View" #Edit, View or None $FolderLinkType="Edit" # View or Edit - - -Set-SiteColl -Username $username -Url $Url -password $AdminPassword -LinkType $LinkType -FolderLinkType $FolderLinkType \ No newline at end of file +Set-SiteColl -Username $username -Url $Url -password $AdminPassword -LinkType $LinkType -FolderLinkType $FolderLinkType diff --git a/Tenant Settings/Set Anonymous access for SPO tenant using PS and CSOM/description.md b/Tenant Settings/Set Anonymous access for SPO tenant using PS and CSOM/description.md index 98555208..b7536e6e 100644 --- a/Tenant Settings/Set Anonymous access for SPO tenant using PS and CSOM/description.md +++ b/Tenant Settings/Set Anonymous access for SPO tenant using PS and CSOM/description.md @@ -6,39 +6,33 @@ For folders you can choose between View and Edit. For files you can choose between -Edit - anonymous links will allow to edit documents +**Edit** - anonymous links will allow to edit documents -View - anonymous links will allow only to view documents +**View** - anonymous links will allow only to view documents -None - users can decide about the access level on per-document basis (no global setting) +**None** - users can decide about the access level on per-document basis (no global setting) -The script is related to and more described in a Wiki article SharePoint Online Sharing settings with CSOM. +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). It requires SharePoint Online SDK. - - - +## How to use? -### How to use? -Download and open the .ps1 file. -Add correct libraries: +- Download and open the .ps1 file. +- Add correct libraries: - ```PowerShell #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" ``` - -Enter the correct url and admin login: +- Enter the correct url and admin login: - ```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -47,5 +41,5 @@ $Url="https://TENANT-admin.sharepoint.com" $LinkType="View" #Edit, View or None $FolderLinkType="Edit" # View or Edit ``` -Run the script +- Run the script diff --git a/Tenant Settings/Set anonymous link access level for SPO tenant/AnonymousLinkType.ps1 b/Tenant Settings/Set anonymous link access level for SPO tenant/AnonymousLinkType.ps1 index 1f8d950a..27bfbc11 100644 --- a/Tenant Settings/Set anonymous link access level for SPO tenant/AnonymousLinkType.ps1 +++ b/Tenant Settings/Set anonymous link access level for SPO tenant/AnonymousLinkType.ps1 @@ -1,48 +1,37 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string]$LinkType - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - $spoTenant.FileAnonymousLinkType=[Microsoft.SharePoint.Client.AnonymousLinkType]::$LinkType - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - Write-Output $spoTenant - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.FileAnonymousLinkType=[Microsoft.SharePoint.Client.AnonymousLinkType]::$LinkType + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" - - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $LinkType="View" #Edit, View or None - - - -Set-SiteColl -Username $username -Url $Url -password $AdminPassword -LinkType $LinkType \ No newline at end of file +Set-SiteColl -Username $username -Url $Url -password $AdminPassword -LinkType $LinkType diff --git a/Tenant Settings/Set anonymous link access level for SPO tenant/description.md b/Tenant Settings/Set anonymous link access level for SPO tenant/description.md index f7779f59..05a6237f 100644 --- a/Tenant Settings/Set anonymous link access level for SPO tenant/description.md +++ b/Tenant Settings/Set anonymous link access level for SPO tenant/description.md @@ -1,36 +1,27 @@ After you have enabled anonymous links for SharePoint Online tenant, you can set what access level the links can give: edit or only view. The setting is global for the entire tenant. You can choose between -Edit - anonymous links will allow to edit documents +**Edit** - anonymous links will allow to edit documents -View - anonymous links will allow only to view documents +**View** - anonymous links will allow only to view documents -None - users can decide about the access level on per-document basis (no global setting) +**None** - users can decide about the access level on per-document basis (no global setting) - - - - -The script is related to and more described in a Wiki article SharePoint Online Sharing settings with CSOM. +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). It requires SharePoint Online SDK. +## How to use? +- Download and open the ```.ps1``` file. +- Add correct libraries: - - - -### How to use? -Download and open the .ps1 file. -Add correct libraries: - - ```PowerShell #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" ``` +- Enter the correct url and admin login: -Enter the correct url and admin login: ```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -38,4 +29,4 @@ $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $LinkType="View" #Edit, View or None ``` -Run the script +- Run the script diff --git a/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/SharingLinkType.ps1 b/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/SharingLinkType.ps1 index 1647645a..52d54c73 100644 --- a/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/SharingLinkType.ps1 +++ b/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/SharingLinkType.ps1 @@ -1,49 +1,37 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] $SharingLinkType - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - $spoTenant.DefaultSharingLinkType= [Microsoft.Online.SharePoint.TenantManagement.SharingLinkType]::$SharingLinkType - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - Write-Output $spoTenant - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.DefaultSharingLinkType= [Microsoft.Online.SharePoint.TenantManagement.SharingLinkType]::$SharingLinkType + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" - - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $SharingLinkType="None" #None, Direct, Internal, AnonymousAccess - - - - -Set-SiteColl -Username $username -Url $Url -password $AdminPassword -SharingLinkType $SharingLinkType \ No newline at end of file +Set-SiteColl -Username $username -Url $Url -password $AdminPassword -SharingLinkType $SharingLinkType diff --git a/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/description.md b/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/description.md index bb6c5269..3b09c653 100644 --- a/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/description.md +++ b/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/description.md @@ -1,37 +1,24 @@ Short Powershell script to modify the Sharing Link Type setting in SharePoint Admin Center via DefaultSharingLinkType property of Tenant object - - The setting can be changed also via SharePoint Admin Center: + +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). - - -The script is related to and more described in a Wiki article SharePoint Online Sharing settings with CSOM. - - - - +## How to use? -How to use? -Download and open the .ps1 file. -Add correct libraries: +- Download and open the ```.ps1``` file. +- Add correct libraries: - ```PowerShell #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" ``` +- Enter the correct url and admin login: - - - -Enter the correct url and admin login: - - ```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -39,6 +26,5 @@ $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $SharingLinkType="None" #None, Direct, Internal, AnonymousAccess ``` - - Run the script +- Run the script diff --git a/Tenant Settings/Set expiration for anonymous links in SPO/SetExpirationForAnonymousLinks (1).ps1 b/Tenant Settings/Set expiration for anonymous links in SPO/SetExpirationForAnonymousLinks (1).ps1 index fc87dbfd..8213264c 100644 --- a/Tenant Settings/Set expiration for anonymous links in SPO/SetExpirationForAnonymousLinks (1).ps1 +++ b/Tenant Settings/Set expiration for anonymous links in SPO/SetExpirationForAnonymousLinks (1).ps1 @@ -1,48 +1,37 @@ -function Set-SiteColl -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SiteColl{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [int]$HowManyDaysToExpire - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - - $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - $spoTenant.RequireAnonymousLinksExpireInDays=$HowManyDaysToExpire - $ctx.Load($spoTenant) - $ctx.ExecuteQuery() - Write-Output $spoTenant - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $spoTenant= New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx) + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + $spoTenant.RequireAnonymousLinksExpireInDays=$HowManyDaysToExpire + $ctx.Load($spoTenant) + $ctx.ExecuteQuery() + Write-Output $spoTenant } - - - #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" - - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $HowManyDaysToExpire=17 #Choose 0 if the links should not expire - - - -Set-SiteColl -Username $username -Url $Url -password $AdminPassword -HowManyDaysToExpire $HowManyDaysToExpire \ No newline at end of file +Set-SiteColl -Username $username -Url $Url -password $AdminPassword -HowManyDaysToExpire $HowManyDaysToExpire diff --git a/Tenant Settings/Set expiration for anonymous links in SPO/description.md b/Tenant Settings/Set expiration for anonymous links in SPO/description.md index 45ac040e..563e99b8 100644 --- a/Tenant Settings/Set expiration for anonymous links in SPO/description.md +++ b/Tenant Settings/Set expiration for anonymous links in SPO/description.md @@ -2,27 +2,21 @@ After you have enabled anonymous links for SharePoint Online tenant, you can set It requires SharePoint Online SDK. - - -The script is related to and more described in a Wiki article SharePoint Online Sharing settings with CSOM. +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). - +## How to use? -How to use? -Download and open the .ps1 file. -Add correct libraries: +- Download and open the .ps1 file. +- Add correct libraries: - ```PowerShell #Paths to SDK 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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" ``` - -Enter the correct url and admin login: +- Enter the correct url and admin login: - ```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -30,7 +24,6 @@ $username="admin@TENANT.onmicrosoft.com" $Url="https://TENANT-admin.sharepoint.com" $HowManyDaysToExpire=17 #Choose 0 if the links should not expire ``` - -Run the script +- Run the script diff --git a/User Profiles/Export all user profiles using Powershell/ExportSPOUserAllPropertiesWithREST.ps1 b/User Profiles/Export all user profiles using Powershell/ExportSPOUserAllPropertiesWithREST.ps1 index 17b1c888..374e29b6 100644 --- a/User Profiles/Export all user profiles using Powershell/ExportSPOUserAllPropertiesWithREST.ps1 +++ b/User Profiles/Export all user profiles using Powershell/ExportSPOUserAllPropertiesWithREST.ps1 @@ -1,58 +1,36 @@ -function Get-SPOUserProperty -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOUserProperty{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] $password, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string] $url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string] $userLogin - ) - - - - $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $RestUrl=$url+"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+$userLogin+"'" - - $request = [System.Net.WebRequest]::Create($RESTUrl) - $request.Credentials = $Credentials - $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") - $request.Accept = "application/json;odata=verbose" - [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get - $request.Method=$Method - $response = $request.GetResponse() - $requestStream = $response.GetResponseStream() - $read = New-Object System.IO.StreamReader $requestStream - $data=$read.ReadToEnd() - $results = $data | ConvertFrom-Json - - - - return ($results.d.userprofileproperties.results) - - - - - - - - - } - - - - - - - - + ) + + $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $RestUrl=$url+"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+$userLogin+"'" + + $request = [System.Net.WebRequest]::Create($RESTUrl) + $request.Credentials = $Credentials + $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") + $request.Accept = "application/json;odata=verbose" + [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get + $request.Method=$Method + $response = $request.GetResponse() + $requestStream = $response.GetResponseStream() + $read = New-Object System.IO.StreamReader $requestStream + $data=$read.ReadToEnd() + $results = $data | ConvertFrom-Json + + return ($results.d.userprofileproperties.results) +} #Paths to SDK Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.dll" Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.Runtime.dll" - #Enter the data @@ -65,16 +43,13 @@ $cred=Get-Credential Connect-SPOService $AdminCenter -Credential $cred $users=Get-SPOUser -Site $SiteUrl - -foreach($user in $users) -{ +foreach($user in $users){ Write-Verbose $user.LoginName $props=Get-SPOUserProperty -Username $cred.UserName -Url $SiteUrl -password $cred.Password -userLogin $user.LoginName $uss=New-Object PSObject - foreach($prop in $props) - { + + foreach($prop in $props){ $uss | Add-Member -MemberType NoteProperty -Name $prop.Key -Value $prop.Value - } $uss | Export-Csv -Path $ExportTo -Append -Force diff --git a/User Profiles/Export all user profiles using Powershell/description.md b/User Profiles/Export all user profiles using Powershell/description.md index 06ca6781..34f308f6 100644 --- a/User Profiles/Export all user profiles using Powershell/description.md +++ b/User Profiles/Export all user profiles using Powershell/description.md @@ -1,43 +1,24 @@ The script retrieves all user profile properties for SharePoint Online users within one site. - - The script uses the following endpoint to retrieve a user property: -/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='' +```/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v=''``` - For more details, please consult: -User profiles REST API reference +[User profiles REST API reference](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn790354(v=office.15)?redirectedfrom=MSDN) - - - - -How to use? - +## How to use? Download, open the script and enter correct values in the following lines: -PowerShell +```PowerShell $SiteUrl="https://t321.sharepoint.com" $AdminCenter="https://t321-admin.sharepoint.com" $ExportTo="C:\Users\Arletka\Documents\SpUsers3.csv" + ``` - -Expected results +## Expected results - - - - - - - - - - - - + diff --git a/User Profiles/Get MUI Languages for multiple users using REST/GetSPOUserLanguagesWithREST.ps1 b/User Profiles/Get MUI Languages for multiple users using REST/GetSPOUserLanguagesWithREST.ps1 index 1bd38dae..0c10a640 100644 --- a/User Profiles/Get MUI Languages for multiple users using REST/GetSPOUserLanguagesWithREST.ps1 +++ b/User Profiles/Get MUI Languages for multiple users using REST/GetSPOUserLanguagesWithREST.ps1 @@ -1,71 +1,45 @@ -function Get-SPOUserProperty -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOUserProperty{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] $password, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string] $url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string] $userLogin - ) + ) + $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $RestUrl=$url+"/_api/sp.userprofiles.peoplemanager/getuserprofilepropertyfor(accountname=@v, propertyname='SPS-MUILanguages')?@v='i%3A0%23.f%7Cmembership%7C"+$userLogin+"'" - - $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $RestUrl=$url+"/_api/sp.userprofiles.peoplemanager/getuserprofilepropertyfor(accountname=@v, propertyname='SPS-MUILanguages')?@v='i%3A0%23.f%7Cmembership%7C"+$userLogin+"'" - - $request = [System.Net.WebRequest]::Create($RESTUrl) - $request.Credentials = $Credentials - $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") - $request.Accept = "application/json;odata=verbose" - [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get - $request.Method=$Method - $response = $request.GetResponse() - $requestStream = $response.GetResponseStream() - $read = New-Object System.IO.StreamReader $requestStream - $data=$read.ReadToEnd() - - $results = $data | ConvertFrom-Json - - - - return (New-Object PSObject -Prop @{'Languages'=$results.d.GetUserProfilePropertyFor; 'User'=$userLogin}) - - - - - - - - - } - - - - - - + $request = [System.Net.WebRequest]::Create($RESTUrl) + $request.Credentials = $Credentials + $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") + $request.Accept = "application/json;odata=verbose" + [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get + $request.Method=$Method + $response = $request.GetResponse() + $requestStream = $response.GetResponseStream() + $read = New-Object System.IO.StreamReader $requestStream + $data=$read.ReadToEnd() + $results = $data | ConvertFrom-Json + return (New-Object PSObject -Prop @{'Languages'=$results.d.GetUserProfilePropertyFor; 'User'=$userLogin}) +} #Paths to SDK Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.dll" Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.Runtime.dll" - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="t@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com" - $userLogins=("t@t321.onmicrosoft.com","user1@t321.onmicrosoft.com","user2@t321.onmicrosoft.com","user5@t321.onmicrosoft.com","yasen@t321.onmicrosoft.com") - - -foreach($userLogin in $userLogins) -{ -Get-SPOUserProperty -Username $username -Url $Url -password $AdminPassword -userLogin $userLogin -} \ No newline at end of file +foreach($userLogin in $userLogins){ + Get-SPOUserProperty -Username $username -Url $Url -password $AdminPassword -userLogin $userLogin +} diff --git a/User Profiles/Get MUI Languages for multiple users using REST/description.md b/User Profiles/Get MUI Languages for multiple users using REST/description.md index 150e60d4..8cf1df11 100644 --- a/User Profiles/Get MUI Languages for multiple users using REST/description.md +++ b/User Profiles/Get MUI Languages for multiple users using REST/description.md @@ -1,27 +1,18 @@ The script retrieves a SPS-MUILanguages property for specified SharePoint Online users. - - The script uses the following endpoint to retrieve a user property: -/getuserprofilepropertyfor(accountname=@v, propertyname='')?@v='' - - +```/getuserprofilepropertyfor(accountname=@v, propertyname='')?@v=''``` For more details, please consult: -User profiles REST API reference - - - - +[User profiles REST API reference](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn790354(v=office.15)?redirectedfrom=MSDN) -### How to use? +## How to use? - Download, open the script and enter correct values in the following lines: -PowerShell +```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="t@t321.onmicrosoft.com" @@ -29,10 +20,7 @@ $Url="https://t321.sharepoint.com" $userLogins=("t@t321.onmicrosoft.com","user1@t321.onmicrosoft.com","user2@t321.onmicrosoft.com","user5@t321.onmicrosoft.com","yasen@t321.onmicrosoft.com") + ``` +## Expected results -Expected results - - - - - + diff --git a/User Profiles/Get all user profile properties using Powershell and REST/GetSPOUserAllPropertiesWithREST.ps1 b/User Profiles/Get all user profile properties using Powershell and REST/GetSPOUserAllPropertiesWithREST.ps1 index 4f0beaed..ebb4c2ee 100644 --- a/User Profiles/Get all user profile properties using Powershell and REST/GetSPOUserAllPropertiesWithREST.ps1 +++ b/User Profiles/Get all user profile properties using Powershell and REST/GetSPOUserAllPropertiesWithREST.ps1 @@ -1,66 +1,41 @@ -function Get-SPOUserProperty -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOUserProperty{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] $password, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string] $url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string] $userLogin - ) - - - - $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $RestUrl=$url+"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+$userLogin+"'" - - $request = [System.Net.WebRequest]::Create($RESTUrl) - $request.Credentials = $Credentials - $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") - $request.Accept = "application/json;odata=verbose" - [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get - $request.Method=$Method - $response = $request.GetResponse() - $requestStream = $response.GetResponseStream() - $read = New-Object System.IO.StreamReader $requestStream - $data=$read.ReadToEnd() - $results = $data | ConvertFrom-Json - - - - return ($results.d.userprofileproperties.results) - - - - - - - - - } - - - - - - - - + ) + + $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $RestUrl=$url+"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+$userLogin+"'" + + $request = [System.Net.WebRequest]::Create($RESTUrl) + $request.Credentials = $Credentials + $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") + $request.Accept = "application/json;odata=verbose" + [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get + $request.Method=$Method + $response = $request.GetResponse() + $requestStream = $response.GetResponseStream() + $read = New-Object System.IO.StreamReader $requestStream + $data=$read.ReadToEnd() + $results = $data | ConvertFrom-Json + + return ($results.d.userprofileproperties.results) +} #Paths to SDK Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.dll" Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.Runtime.dll" - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="Admin@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com" $userLogin="user2@t321.onmicrosoft.com" - - - Get-SPOUserProperty -Username $username -Url $Url -password $AdminPassword -userLogin $userLogin | select key, value diff --git a/User Profiles/Get all user profile properties using Powershell and REST/description.md b/User Profiles/Get all user profile properties using Powershell and REST/description.md index d4fc507d..e3a6bd1a 100644 --- a/User Profiles/Get all user profile properties using Powershell and REST/description.md +++ b/User Profiles/Get all user profile properties using Powershell and REST/description.md @@ -1,24 +1,15 @@ -The script retrieves all user profile properties for the specified SharePoint Online user. - - +The script retrieves all user profile properties for the specified SharePoint Online user. The script uses the following endpoint to retrieve a user property: -/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='' - - +```/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v=''``` For more details, please consult: -User profiles REST API reference - - - - +[User profiles REST API reference](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn790354(v=office.15)?redirectedfrom=MSDN) -### How to use? +## How to use? - Download, open the script and enter correct values in the following lines: ```PowerShell @@ -28,17 +19,7 @@ $username="Admin@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com" $userLogin="user2@t321.onmicrosoft.com" ``` -Expected result - - - - - - - - - - - +## Expected result + diff --git a/User Profiles/Get user work email using Powershell and REST/GetSPOUserEmailWithREST.ps1 b/User Profiles/Get user work email using Powershell and REST/GetSPOUserEmailWithREST.ps1 index 2ea7506d..ae023415 100644 --- a/User Profiles/Get user work email using Powershell and REST/GetSPOUserEmailWithREST.ps1 +++ b/User Profiles/Get user work email using Powershell and REST/GetSPOUserEmailWithREST.ps1 @@ -1,67 +1,42 @@ -function Get-SPOUserProperty -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOUserProperty{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] $password, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string] $url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string] $userLogin - ) - - - - $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $RestUrl=$url+"/_api/sp.userprofiles.peoplemanager/getuserprofilepropertyfor(accountname=@v, propertyname='WorkEmail')?@v='i%3A0%23.f%7Cmembership%7C"+$userLogin+"'" - - $request = [System.Net.WebRequest]::Create($RESTUrl) - $request.Credentials = $Credentials - $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") - $request.Accept = "application/json;odata=verbose" - [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get - $request.Method=$Method - $response = $request.GetResponse() - $requestStream = $response.GetResponseStream() - $read = New-Object System.IO.StreamReader $requestStream - $data=$read.ReadToEnd() - # Because the string contains duplicate 'ID' keys. - $results = $data | ConvertFrom-Json - - - - return ($results.d) - - - - - - - - - } - - - - - - - - + ) + + $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $RestUrl=$url+"/_api/sp.userprofiles.peoplemanager/getuserprofilepropertyfor(accountname=@v, propertyname='WorkEmail')?@v='i%3A0%23.f%7Cmembership%7C"+$userLogin+"'" + + $request = [System.Net.WebRequest]::Create($RESTUrl) + $request.Credentials = $Credentials + $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") + $request.Accept = "application/json;odata=verbose" + [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get + $request.Method=$Method + $response = $request.GetResponse() + $requestStream = $response.GetResponseStream() + $read = New-Object System.IO.StreamReader $requestStream + $data=$read.ReadToEnd() + # Because the string contains duplicate 'ID' keys. + $results = $data | ConvertFrom-Json + + return ($results.d) +} #Paths to SDK Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.dll" Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.Runtime.dll" - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="t@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com/polski" $userLogin="t@t321.onmicrosoft.com" - - - Get-SPOUserProperty -Username $username -Url $Url -password $AdminPassword -userLogin $userLogin diff --git a/User Profiles/Get user work email using Powershell and REST/description.md b/User Profiles/Get user work email using Powershell and REST/description.md index e3f5f0a9..5f4c1d34 100644 --- a/User Profiles/Get user work email using Powershell and REST/description.md +++ b/User Profiles/Get user work email using Powershell and REST/description.md @@ -1,24 +1,15 @@ The script retrieves a WorkEmail property for a single SharePoint Online user. - - The script uses the following endpoint to retrieve a user property: -/getuserprofilepropertyfor(accountname=@v, propertyname='')?@v='' - - +```/getuserprofilepropertyfor(accountname=@v, propertyname='')?@v=''``` For more details, please consult: -User profiles REST API reference - - +[User profiles REST API reference](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn790354(v=office.15)?redirectedfrom=MSDN) +## How to use? - -### How to use? - - Download, open the script and enter correct values in the following lines: ```PowerShell @@ -28,8 +19,7 @@ $username="t@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com/polski" $userLogin="t@t321.onmicrosoft.com" ``` -Expected result +## Expected result - - + diff --git a/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md b/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md index 221ec711..4a2b7fe9 100644 --- a/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md +++ b/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md @@ -6,9 +6,9 @@ That means that users having access to more than one site will appear more than -The .zip contains: +The ```.zip``` contains: -.exe file with a console application. Install to run. Enter global administrator credentials, the the admin Center url, and the report's path. +```.exe``` file with a console application. Install to run. Enter global administrator credentials, the the admin Center url, and the report's path. sample report @@ -25,354 +25,97 @@ The following properties are retrieved: - +``` "SPS-UserPrincipalName","UserProfile_GUID","SID","ADGuid","AccountName","FirstName","SPS-PhoneticFirstName", "LastName", - - - "SPS-PhoneticLastName", - - - "PreferredName", - - - "SPS-PhoneticDisplayName", - - - "WorkPhone", - - - "Department", - - - "Title", - - - "SPS-JobTitle", - - - "SPS-Department", - - - "Manager", - - - "AboutMe", - - - "PersonalSpace", - - - "PictureURL", - - - "UserName", - - - "QuickLinks", - - - "WebSite", - - - "SPS-DataSource", - - - "SPS-MemberOf", - - - "SPS-Dotted-line", - - - "SPS-Peers", - - - "SPS-Responsibility", - - - "SPS-SipAddress", - - - "SPS-MySiteUpgrade", - - - "SPS-DontSuggestList", - - - "SPS-ProxyAddresses", - - - "SPS-HireDate", - - - "SPS-DisplayOrder", - - - "SPS-ClaimID", - - - "SPS-ClaimProviderID", - - - "SPS-ClaimProviderType", - - - "SPS-LastColleagueAdded", - - - "SPS-OWAUrl", - - - "SPS-SavedAccountName", - - - "SPS-SavedSID", - - - "SPS-ResourceSID", - - - "SPS-ResourceAccountName", - - - "SPS-ObjectExists", - - - "SPS-MasterAccountName", - - - "SPS-UserPrincipalName", - - - "SPS-PersonalSiteCapabilities", - - - "SPS-O15FirstRunExperience", - - - "SPS-PersonalSiteFirstCreationTime", - - - "SPS-PersonalSiteLastCreationTime", - - - "SPS-PersonalSiteNumberOfRetries", - - - "SPS-PersonalSiteFirstCreationError", - - - "SPS-LastKeywordAdded", - - - "SPS-FeedIdentifier", - - - "SPS-PersonalSiteInstantiationState", - - - "WorkEmail", - - - "CellPhone", - - - "Fax", - - - "HomePhone", - - - "Office", - - - "SPS-Location", - - - "Assistant", - - - "SPS-PastProjects", - - - "SPS-Skills", - - - "SPS-School", - - - "SPS-Birthday", - - - "SPS-StatusNotes", - - - "SPS-Interests", - - - "SPS-HashTags", - - - "SPS-PictureTimestamp", - - - "SPS-EmailOptin", - - - "SPS-PicturePlaceholderState", - - - "SPS-PrivacyPeople", - - - "SPS-PrivacyActivity", - - - "SPS-PictureExchangeSyncState", - - - "SPS-MUILanguages", - - - "SPS-ContentLanguages", - - - "SPS-TimeZone", - - - "SPS-RegionalSettings-FollowWeb", - - - "SPS-Locale", - - - "SPS-CalendarType", - - - "SPS-AltCalendarType", - - - "SPS-AdjustHijriDays", - - - "SPS-ShowWeeks", - - - "SPS-WorkDays", - - - "SPS-WorkDayStartHour", - - - "SPS-WorkDayEndHour", - - - "SPS-Time24", - - - "SPS-FirstDayOfWeek", - - - "SPS-FirstWeekOfYear", - - - "SPS-RegionalSettings-Initialized", - - - "OfficeGraphEnabled" - - - - - - +``` ```C# static void Main(string[] args) @@ -395,7 +138,7 @@ static void Main(string[] args) Console.ReadKey(); } ``` -It would not exist without Geetanjali's inspiring article: http://social.technet.microsoft.com/wiki/contents/articles/24627.sharepoint-online-export-user-profile-properties-using-csom.aspx +It would not exist without Geetanjali's inspiring [article](http://social.technet.microsoft.com/wiki/contents/articles/24627.sharepoint-online-export-user-profile-properties-using-csom.aspx).

diff --git a/Versioning/Enable minor versions for all lists/MinorVersioning.ps1 b/Versioning/Enable minor versions for all lists/MinorVersioning.ps1 index 08424c8f..19e1d9c6 100644 --- a/Versioning/Enable minor versions for all lists/MinorVersioning.ps1 +++ b/Versioning/Enable minor versions for all lists/MinorVersioning.ps1 @@ -1,5 +1,4 @@ -function getall($urelek) -{ +function getall($urelek){ $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $ctx.Load($ctx.Web.Lists) @@ -8,52 +7,40 @@ $ctx.ExecuteQuery() Write-Host Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - - foreach( $ll in $ctx.Web.Lists) - { - $ctx.Load($ll.RootFolder) - $ctx.ExecuteQuery() - $ll.EnableMinorVersions = $versioning - $ll.Update() - $csvvalue= new-object PSObject - $listurl=$null - if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url.Remove(($ctx.Url.Length-1),1)+$ll.RootFolder.ServerRelativeUrl} - else { + + foreach( $ll in $ctx.Web.Lists){ + $ctx.Load($ll.RootFolder) + $ctx.ExecuteQuery() + $ll.EnableMinorVersions = $versioning + $ll.Update() + $csvvalue= new-object PSObject + $listurl=$null + + if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url.Remove(($ctx.Url.Length-1),1)+$ll.RootFolder.ServerRelativeUrl} + else { $index=$ctx.Url.LastIndexOf(".com") $listurl=$ctx.Url.Remove($index+4)+$ll.RootFolder.ServerRelativeUrl} $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) $csvvalue | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" - try - { + try{ $ErrorActionPreference="Stop" $ctx.ExecuteQuery() Write-Host $listurl -ForegroundColor DarkGreen $csvvalue.Status="Success" $Global:csv+= $csvvalue - } - - catch - { - $Global:csv+= $csvvalue - Write-Host $listurl -ForegroundColor Red - } - finally - {$ErrorActionPreference="Continue"} - - - } + } + catch{ + $Global:csv+= $csvvalue + Write-Host $listurl -ForegroundColor Red + } + finally{$ErrorActionPreference="Continue"} + } - if($ctx.Web.Webs.Count -gt 0) - { - for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++) - { + if($ctx.Web.Webs.Count -gt 0){ + for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++){ getall($ctx.Web.Webs[$i].Url) + } } - - } - - - } # Paths to SDK. Please verify location on your computer. @@ -73,8 +60,7 @@ Connect-SPOService -Credential $credy -Url $siteUrl $sitecollections=get-SPOSite $Global:csv=@() -foreach($sitecoll in $sitecollections) -{ +foreach($sitecoll in $sitecollections){ getall($sitecoll.Url) } diff --git a/Versioning/Enable minor versions for all lists/description.md b/Versioning/Enable minor versions for all lists/description.md index e6a01b6e..f502d868 100644 --- a/Versioning/Enable minor versions for all lists/description.md +++ b/Versioning/Enable minor versions for all lists/description.md @@ -6,15 +6,7 @@ http://technet.microsoft.com/en-us/library/fp161372(v=office.15).aspx http://www.microsoft.com/en-us/download/details.aspx?id=30722 - - - - - - - - - + It uses recurrence to find all sites in all site collections and then goes through all the lists. @@ -28,29 +20,11 @@ As the script runs you will see green lists' titles for which the enabling succe Versioning will always fail for public site. - - - - - - - - - - - - - - - + If you need to enable versioning in general and minor versioning for those lists that support it, first run this script for enabling versioning in general and then the one here for minor versions. - - - - -PowerShell +```PowerShell function getall($urelek) { $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) @@ -132,7 +106,7 @@ foreach($sitecoll in $sitecollections) # Specify the path where the log file will be published $Global:csv | Export-Csv -Path C:\Users\Public\Versioning.csv - + ``` -If you think, I could have improved on anything, please let me know in the Q&A section! +### If you think, I could have improved on anything, please let me know in the Q&A section! diff --git a/Versioning/Enable versioning for all SharePoint Online lists/Versioning.ps1 b/Versioning/Enable versioning for all SharePoint Online lists/Versioning.ps1 index d2b4fcf1..68f646e4 100644 --- a/Versioning/Enable versioning for all SharePoint Online lists/Versioning.ps1 +++ b/Versioning/Enable versioning for all SharePoint Online lists/Versioning.ps1 @@ -1,54 +1,44 @@ -function getall($urelek) -{ - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) - $ctx.Load($ctx.Web.Lists) - $ctx.Load($ctx.Web) - $ctx.Load($ctx.Web.Webs) - $ctx.ExecuteQuery() - Write-Host - Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - foreach( $ll in $ctx.Web.Lists) - { - $ll.EnableVersioning = $versioning - $ll.Update() - $csvvalue= new-object PSObject - $listurl=$null - if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url+$ll.Title} - else {$listurl=$ctx.Url+"/"+$ll.Title} - $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) - $csvvalue | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" - try - { +function getall($urelek){ + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) + $ctx.Load($ctx.Web.Lists) + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Web.Webs) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + + foreach( $ll in $ctx.Web.Lists){ + $ll.EnableVersioning = $versioning + $ll.Update() + $csvvalue= new-object PSObject + $listurl=$null + + if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url+$ll.Title} + else {$listurl=$ctx.Url+"/"+$ll.Title} + + $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) + $csvvalue | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" + + try{ $ErrorActionPreference="Stop" $ctx.ExecuteQuery() Write-Host $listurl -ForegroundColor DarkGreen $csvvalue.Status="Success" $Global:csv+= $csvvalue - } - - catch - { - $Global:csv+= $csvvalue - Write-Host $listurl -ForegroundColor Red - } - finally - {$ErrorActionPreference="Continue"} - - - } + } + catch{ + $Global:csv+= $csvvalue + Write-Host $listurl -ForegroundColor Red + } + finally{$ErrorActionPreference="Continue"} + } - if($ctx.Web.Webs.Count -gt 0) - { - for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++) - { + if($ctx.Web.Webs.Count -gt 0){ + for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++){ getall($ctx.Web.Webs[$i].Url) + } } - - } - - - } # Paths to SDK. Please verify location on your computer. @@ -68,9 +58,8 @@ Connect-SPOService -Credential $credy -Url $siteUrl $sitecollections=get-SPOSite $Global:csv=@() -foreach($sitecoll in $sitecollections) -{ - getall($sitecoll.Url) +foreach($sitecoll in $sitecollections){ + getall($sitecoll.Url) } # Specify the path where the log file will be published diff --git a/Versioning/Enable versioning for all SharePoint Online lists/description.md b/Versioning/Enable versioning for all SharePoint Online lists/description.md index 72534dac..f57a20af 100644 --- a/Versioning/Enable versioning for all SharePoint Online lists/description.md +++ b/Versioning/Enable versioning for all SharePoint Online lists/description.md @@ -19,11 +19,11 @@ At the end, a csv file is generated with the lists' urls and the status whether As the script runs you will see green lists' titles for which the enabling succeeded and red for those which failed (not all lists support versioning). - + - + - + You can customize the script by using the commented out tips. diff --git a/Versioning/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 b/Versioning/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 index eb9532c5..74a111e8 100644 --- a/Versioning/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 +++ b/Versioning/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 @@ -1,5 +1,4 @@ -function Set-SPOListVersioning($EnableVersioning, $Urelek) -{ +function Set-SPOListVersioning($EnableVersioning, $Urelek){ $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $Adminpassword) $ctx.Load($ctx.Web.Lists) @@ -8,54 +7,40 @@ $ctx.ExecuteQuery() Write-Host Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - foreach( $ll in $ctx.Web.Lists) - { + + foreach( $ll in $ctx.Web.Lists){ $ll.EnableVersioning = $EnableVersioning $ll.Update() $csvvalue= new-object PSObject - $listurl=$null - if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url+$ll.Title} - else {$listurl=$ctx.Url+"/"+$ll.Title} - $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) - $csvvalue | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" - try - { + $listurl=$null + + if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url+$ll.Title} + else {$listurl=$ctx.Url+"/"+$ll.Title} + + $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) + $csvvalue | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" + + try{ $ErrorActionPreference="Stop" $ctx.ExecuteQuery() Write-Host $listurl -ForegroundColor DarkGreen $csvvalue.Status="Success" $Global:csv+= $csvvalue - } - - catch - { - $Global:csv+= $csvvalue - Write-Host $listurl -ForegroundColor Red - } - finally - {$ErrorActionPreference="Continue"} - - + } + catch{ + $Global:csv+= $csvvalue + Write-Host $listurl -ForegroundColor Red + } + finally{$ErrorActionPreference="Continue"} } - if($ctx.Web.Webs.Count -gt 0) - { - for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++) - { + if($ctx.Web.Webs.Count -gt 0){ + for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++){ Set-SPOListVersioning -EnableVersioning $EnableVersioning -Urelek ($ctx.Web.Webs[$i].Url) } - } - - - } - - - - - # Paths to SDK. Please verify location on your computer. Add-Type -Path "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client.Runtime\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.Runtime.dll" @@ -71,12 +56,8 @@ $users=get-SPOUser -Site $myhost $EnableVersioning=$true $Global:csv=@() -foreach($user in $users) -{ - - - if($user.LoginName.Contains('@')) - { +foreach($user in $users){ + if($user.LoginName.Contains('@')){ $persweb=$user.LoginName.Replace(".","_").Replace("@","_") $persweb=$myhost+"/personal/"+$persweb Write-Host $persweb @@ -90,4 +71,4 @@ foreach($user in $users) } # Specify the path where the log file will be published -$Global:csv | Export-Csv -Path C:\Users\Public\Versioning.csv \ No newline at end of file +$Global:csv | Export-Csv -Path C:\Users\Public\Versioning.csv diff --git a/Versioning/Restore previous versions in selected files the entire library/RestorePreviousVersionsInSelectedFiles.ps1 b/Versioning/Restore previous versions in selected files the entire library/RestorePreviousVersionsInSelectedFiles.ps1 index 67a8430b..7742d5ba 100644 --- a/Versioning/Restore previous versions in selected files the entire library/RestorePreviousVersionsInSelectedFiles.ps1 +++ b/Versioning/Restore previous versions in selected files the entire library/RestorePreviousVersionsInSelectedFiles.ps1 @@ -1,104 +1,83 @@ -function Get-SPOFolderFiles -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOFolderFiles{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string]$ListTitle - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - $ll=$ctx.Web.Lists.GetByTitle($ListTitle) - $ctx.Load($ll) - $ctx.ExecuteQuery() - $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery - $spqQuery.ViewXml ="/VersionTest/Folder2/FolderWithinFolder"; - $itemki=$ll.GetItems($spqQuery) - $ctx.Load($itemki) - $ctx.ExecuteQuery() - - foreach($item in $itemki) - { - - - # Write-Host $item["FileRef"] -ForegroundColor DarkGreen - $file = - $ctx.Web.GetFileByServerRelativeUrl($item["FileRef"]); - $ctx.Load($file) - $ctx.Load($file.Versions) - try{ - $ctx.ExecuteQuery() } - catch - { - continue; - } - - #$file.TimeLastModified - $date=Get-Date ("2/12/2017") - - if($file.TimeLastModified -gt $date) - { - - Write-host $file.Name -ForegroundColor Green - if ($file.Versions.Count -eq 0) - { - $obj=New-Object PSObject - $obj | Add-Member NoteProperty ServerRelativeUrl($file.ServerRelativeUrl) - $obj | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) - $obj | Add-Member NoteProperty Versions("No Versions Available") - - #$obj | export-csv -Path $CSVPath -Append - - Write-Output $obj - } - elseif($file.TypedObject.ToString() -eq "Microsoft.SharePoint.Client.File") - { - - foreach ($vv in $file.Versions){ - Write-Host $vv.Created $vv.Size $vv.VersionLabel $vv.IsCurrentVersion $file.Versions.Count - - # Write-Output $vv - - } - if($file.Versions[($file.Versions.Count-1)].IsCurrentVersion) - { - $vLabel=$file.Versions[($file.Versions.Count-2)].VersionLabel - Write-Host "Version to be restored: " $vLabel - } - else{ $vLabel=$file.Versions[($file.Versions.Count-1)].VersionLabel - Write-Host "Version to be restored: " $vLabel } - $file.Versions.RestoreByLabel($vLabel) - $ctx.ExecuteQuery() - } - - else - { -$obj = New-Object PSObject -$obj| Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) - $obj | Add-Member NoteProperty Versions("No Versions Available") - Write-Output $obj - } - - - } - - - } - - - - - - - + ) + + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + $ll=$ctx.Web.Lists.GetByTitle($ListTitle) + $ctx.Load($ll) + $ctx.ExecuteQuery() + $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + $spqQuery.ViewXml ="/VersionTest/Folder2/FolderWithinFolder"; + $itemki=$ll.GetItems($spqQuery) + $ctx.Load($itemki) + $ctx.ExecuteQuery() + + foreach($item in $itemki){ + # Write-Host $item["FileRef"] -ForegroundColor DarkGreen + $file = + $ctx.Web.GetFileByServerRelativeUrl($item["FileRef"]); + $ctx.Load($file) + $ctx.Load($file.Versions) + + try{ + $ctx.ExecuteQuery() + } + catch{ + continue; + } + + #$file.TimeLastModified + $date=Get-Date ("2/12/2017") + + if($file.TimeLastModified -gt $date){ + Write-host $file.Name -ForegroundColor Green + if ($file.Versions.Count -eq 0){ + $obj=New-Object PSObject + $obj | Add-Member NoteProperty ServerRelativeUrl($file.ServerRelativeUrl) + $obj | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) + $obj | Add-Member NoteProperty Versions("No Versions Available") + + #$obj | export-csv -Path $CSVPath -Append + + Write-Output $obj + } + elseif($file.TypedObject.ToString() -eq "Microsoft.SharePoint.Client.File"){ + foreach ($vv in $file.Versions){ + Write-Host $vv.Created $vv.Size $vv.VersionLabel $vv.IsCurrentVersion $file.Versions.Count + + # Write-Output $vv + } + + if($file.Versions[($file.Versions.Count-1)].IsCurrentVersion){ + $vLabel=$file.Versions[($file.Versions.Count-2)].VersionLabel + Write-Host "Version to be restored: " $vLabel + } + else{ $vLabel=$file.Versions[($file.Versions.Count-1)].VersionLabel + Write-Host "Version to be restored: " $vLabel + } + $file.Versions.RestoreByLabel($vLabel) + $ctx.ExecuteQuery() + } + else{ + $obj = New-Object PSObject + $obj| Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) + $obj | Add-Member NoteProperty Versions("No Versions Available") + Write-Output $obj + } + } + } } #Paths to SDK @@ -111,6 +90,4 @@ $username="t@testova365.onmicrosoft.com" $Url="https://testova365.sharepoint.com/sites/STS" $ListTitle="VersionTest" - - -Get-sPOFolderFiles -Username $username -Url $Url -password $AdminPassword -ListTitle $ListTitle \ No newline at end of file +Get-sPOFolderFiles -Username $username -Url $Url -password $AdminPassword -ListTitle $ListTitle diff --git a/Versioning/Restore previous versions in selected files the entire library/description.md b/Versioning/Restore previous versions in selected files the entire library/description.md index b3d3567b..b9d7d1e2 100644 --- a/Versioning/Restore previous versions in selected files the entire library/description.md +++ b/Versioning/Restore previous versions in selected files the entire library/description.md @@ -4,7 +4,7 @@ Please test the script in test environment before using it in production. -The script is a modification of the existing Restore Previous Versions script created to show 2 ways on filtering the file results. The filters are only examples that need to be adjusted to your specific needs. +The script is a modification of the existing [Restore Previous Versions](https://gallery.technet.microsoft.com/Restore-previous-versions-bbcb0796) script created to show 2 ways on filtering the file results. The filters are only examples that need to be adjusted to your specific needs. The first filter uses CamlQuery to retrieve only files coming from a specific folder. @@ -20,21 +20,14 @@ When dealing with large number of files CamlQuery is the preferred and more effi -PowerShell +```PowerShell #Paths to SDK Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" + ``` - - - - - - The script needs to be edited before running. Enter the necessary data: - - ```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -43,13 +36,14 @@ $Url="https://testova365.sharepoint.com/sites/STS" $ListTitle="VersionTest" ``` The CamlQuery below chooses only files whose ServerRelativeUrl includes a certain path. In this way you can restore versions only from a specific folder. -PowerShell + +```PowerShell $spqQuery.ViewXml ="/VersionTest/Folder2/FolderWithinFolder"; - + ``` The following lines allow us to narrow the files only to those modified after 12/2/2017. -PowerShell +```PowerShell $date=Get-Date ("2/12/2017") if($file.TimeLastModified -gt $date) { - + ``` diff --git a/Versioning/Restore previous versions in the entire library/Restore previous versions.ps1 b/Versioning/Restore previous versions in the entire library/Restore previous versions.ps1 index b4efa5b5..376d8c6f 100644 --- a/Versioning/Restore previous versions in the entire library/Restore previous versions.ps1 +++ b/Versioning/Restore previous versions in the entire library/Restore previous versions.ps1 @@ -1,115 +1,96 @@ -function Get-SPOFolderFiles -{ -param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] +function Get-SPOFolderFiles{ + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] [string]$Url, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] $password, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string]$ListTitle - ) - - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.Load($ctx.Web) - $ctx.ExecuteQuery() - $ll=$ctx.Web.Lists.GetByTitle($ListTitle) - $ctx.Load($ll) - $ctx.ExecuteQuery() - $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery - $spqQuery.ViewXml =""; - $itemki=$ll.GetItems($spqQuery) - $ctx.Load($itemki) - $ctx.ExecuteQuery() - - foreach($item in $itemki) - { - - Write-Host $item["FileRef"] -ForegroundColor DarkGreen - $file = - $ctx.Web.GetFileByServerRelativeUrl($item["FileRef"]); - $ctx.Load($file) - $ctx.Load($file.Versions) - try{ - $ctx.ExecuteQuery() } - catch - { - continue; - } - if ($file.Versions.Count -eq 0) - { - $obj=New-Object PSObject - $obj | Add-Member NoteProperty ServerRelativeUrl($file.ServerRelativeUrl) - $obj | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) - $obj | Add-Member NoteProperty Versions("No Versions Available") - - #$obj | export-csv -Path $CSVPath -Append - - Write-Output $obj - } - elseif($file.TypedObject.ToString() -eq "Microsoft.SharePoint.Client.File") - { - - foreach ($vv in $file.Versions){ - Write-Host $vv.Created $vv.Size $vv.VersionLabel $vv.IsCurrentVersion $file.Versions.Count - - # Write-Output $vv - - } - if($file.Versions[($file.Versions.Count-1)].IsCurrentVersion) - { - $vLabel=$file.Versions[($file.Versions.Count-2)].VersionLabel - Write-Host "Version to be restored: " $vLabel - } - else{ - $vLabel=$file.Versions[($file.Versions.Count-1)].VersionLabel - Write-Host "Version to be restored: " $vLabel } - $file.Versions.RestoreByLabel($vLabel) - $ctx.ExecuteQuery() - } - -else -{ -$obj = New-Object PSObject -$obj| Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) - $obj | Add-Member NoteProperty Versions("No Versions Available") - Write-Output $obj - } - <# - try { $ctx.ExecuteQuery() - $obj=New-Object PSObject - $obj | Add-Member NoteProperty ServerRelativeUrl($file.ServerRelativeUrl) - $obj | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) - $obj | Add-Member NoteProperty Versions($file.Versions.Count + " versions were deleted") - - $obj | export-csv -Path $CSVPath -Append - } - catch { - $obj=New-Object PSObject - $obj | Add-Member NoteProperty ServerRelativeUrl($file.ServerRelativeUrl) - $obj | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) - $obj | Add-Member NoteProperty Versions($file.Versions.Count + " versions. Failed to delete") - - $obj | export-csv -Path $CSVPath -Append - - }#> - - - - - } - - - - - - - + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + $ll=$ctx.Web.Lists.GetByTitle($ListTitle) + $ctx.Load($ll) + $ctx.ExecuteQuery() + $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + $spqQuery.ViewXml =""; + $itemki=$ll.GetItems($spqQuery) + $ctx.Load($itemki) + $ctx.ExecuteQuery() + + foreach($item in $itemki){ + Write-Host $item["FileRef"] -ForegroundColor DarkGreen + $file = + $ctx.Web.GetFileByServerRelativeUrl($item["FileRef"]); + $ctx.Load($file) + $ctx.Load($file.Versions) + + try{ + $ctx.ExecuteQuery() + } + catch{ + continue; + } + + if ($file.Versions.Count -eq 0){ + $obj=New-Object PSObject + $obj | Add-Member NoteProperty ServerRelativeUrl($file.ServerRelativeUrl) + $obj | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) + $obj | Add-Member NoteProperty Versions("No Versions Available") + + #$obj | export-csv -Path $CSVPath -Append + + Write-Output $obj + } + elseif($file.TypedObject.ToString() -eq "Microsoft.SharePoint.Client.File"){ + foreach ($vv in $file.Versions){ + Write-Host $vv.Created $vv.Size $vv.VersionLabel $vv.IsCurrentVersion $file.Versions.Count + + # Write-Output $vv + } + + if($file.Versions[($file.Versions.Count-1)].IsCurrentVersion){ + $vLabel=$file.Versions[($file.Versions.Count-2)].VersionLabel + Write-Host "Version to be restored: " $vLabel + } + else{ + $vLabel=$file.Versions[($file.Versions.Count-1)].VersionLabel + Write-Host "Version to be restored: " $vLabel } + $file.Versions.RestoreByLabel($vLabel) + $ctx.ExecuteQuery() + } + else{ + $obj = New-Object PSObject + $obj| Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) + $obj | Add-Member NoteProperty Versions("No Versions Available") + Write-Output $obj + } + <# + try { $ctx.ExecuteQuery() + $obj=New-Object PSObject + $obj | Add-Member NoteProperty ServerRelativeUrl($file.ServerRelativeUrl) + $obj | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) + $obj | Add-Member NoteProperty Versions($file.Versions.Count + " versions were deleted") + + $obj | export-csv -Path $CSVPath -Append + } + catch { + $obj=New-Object PSObject + $obj | Add-Member NoteProperty ServerRelativeUrl($file.ServerRelativeUrl) + $obj | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) + $obj | Add-Member NoteProperty Versions($file.Versions.Count + " versions. Failed to delete") + + $obj | export-csv -Path $CSVPath -Append + + }#> + } + } } - #Paths to SDK Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" @@ -122,4 +103,4 @@ $ListTitle="uyyu" -Get-sPOFolderFiles -Username $username -Url $Url -password $AdminPassword -ListTitle $ListTitle \ No newline at end of file +Get-sPOFolderFiles -Username $username -Url $Url -password $AdminPassword -ListTitle $ListTitle diff --git a/Versioning/Restore previous versions in the entire library/description.md b/Versioning/Restore previous versions in the entire library/description.md index d177fd80..602e5d33 100644 --- a/Versioning/Restore previous versions in the entire library/description.md +++ b/Versioning/Restore previous versions in the entire library/description.md @@ -1,22 +1,17 @@ The script retrieves all files and restores the LAST NOT CURRENT version of the file. Please test the script in test environment before using it in production. - - The script requires SharePoint Online SDK. Make sure that the paths below point to locations on your computer: + ```PowerShell #Paths to SDK Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" ``` - - The script needs to be edited before running. Enter the necessary data: - - ```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString @@ -26,7 +21,7 @@ $ListTitle="uyyu" ``` - +

Enjoy and please share feedback!