diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/README.md b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/README.md new file mode 100644 index 00000000..fdc22124 --- /dev/null +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/README.md @@ -0,0 +1,37 @@ +A short Powershell script to allow management of content types for all lists and libraries in a site. + +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%20a%20site/contentTypeManagement.png)) + + +Applies to lists and libraries. + + +*It requires installed* [SharePoint Online SDK](http://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. +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" + +# Insert the credentials and the name of the site and the desired setting: $true for the content types management to be allowed or $false to disable it +$Username="trial@trialtrial123.onmicrosoft.com" +$AdminPassword="Pass" +$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" +$ContentTypesEnabled=$true +``` + +### Please share your thoughts in the Q&A section! + +#### 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) + +[Disable or enable attachments to list items using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48) + +[Change search setting for all lists in a site using CSOM and Powershell](https://gallery.technet.microsoft.com/scriptcenter/Allow-content-type-5bca5157) + +

+Enjoy and please share feedback! diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ReadMe.md b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ReadMe.md new file mode 100644 index 00000000..eec2be23 --- /dev/null +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ReadMe.md @@ -0,0 +1,50 @@ +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](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](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. +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" + +# Insert the credentials and the name of the site and the desired setting: $true for the content types management to be allowed or $false to disable it +$Username="trial@trialtrial123.onmicrosoft.com" +$AdminPassword="Pass" +$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" +$ContentTypesEnabled=$true +``` + +### Please share your thoughts in the Q&A section! + +#### 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)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) + +[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](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48) + +[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](https://gallery.technet.microsoft.com/scriptcenter/Set-content-type-39ae4bce) + + +

+Enjoy and please share feedback! diff --git a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md new file mode 100644 index 00000000..8ae3f756 --- /dev/null +++ b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md @@ -0,0 +1,47 @@ +Short Powershell script to allow management of content types for a SharePoint Online list or library. It is an equivalent of **List**>>**List Settings**>>**Advanced**>>**Content types in User Interface Applies to lists and libraries**. + +A short Powershell script to allow management of content types for a SharePoint Online list or library. + +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/Set%20content%20type%20management%20setting%20for%20a%20single%20list/contentTypeManagement.png)) + +Applies to lists and libraries. + +*It requires installed* [SharePoint Online SDK](http://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. +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" + +# Insert the credentials and the name of the site and list +$Username="trial@trialtrial123.onmicrosoft.com" +$AdminPassword="Pass" +$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" +$ListName="Tasks list" +$ContentTypesEnabled =$false +``` + + +### Please share your thoughts in the Q&A section! + +#### Wiki article with detailed code description: + +[SharePoint Online: Turn on support for multiple content types in a list or library using Powershell](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 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)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) + +[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](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48) + + + +

+Enjoy and please share feedback! diff --git a/Content Types/Create/Add Content Type to Lists with Workflows/ReadMe.md b/Content Types/Create/Add Content Type to Lists with Workflows/ReadMe.md new file mode 100644 index 00000000..b97da707 --- /dev/null +++ b/Content Types/Create/Add Content Type to Lists with Workflows/ReadMe.md @@ -0,0 +1,44 @@ +A short script to create a content type, and add it directly to all SharePoint Online lists with workflows within one site. The content type does not appear among site content types. + + + +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](https://www.microsoft.com/en-us/download/details.aspx?id=42038). + +2. Download the *.ps1* file. + +3. Open the file (you can do it also in NotePad) + +4. Insert your data in these lines: + +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" +$Description="desc" +$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.
+ +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*. + +

+Enjoy and please share feedback! diff --git a/Content Types/Create/Add Content Type to Task Lists/ReadMe.md b/Content Types/Create/Add Content Type to Task Lists/ReadMe.md new file mode 100644 index 00000000..23db2c0a --- /dev/null +++ b/Content Types/Create/Add Content Type to Task Lists/ReadMe.md @@ -0,0 +1,49 @@ +A short script to create a content type, and add it directly to all SharePoint Online task lists within one site. The content type does not appear among site content types. + +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](https://www.microsoft.com/en-us/download/details.aspx?id=42038). + +2. Download the *.ps1* file. + +3. Open the file (you can do it also in NotePad) + +4. Insert your data in these lines: + +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" +$Description="desc" +$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.
+ +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*. + + + + +

+Enjoy and please share feedback! diff --git a/Content Types/Create/Add existing content type directly to SPO list/AddExistingContentTypetoOneList.ps1 b/Content Types/Create/Add existing content type directly to SPO list/AddExistingContentTypetoOneList.ps1 index 43825fba..b03c128d 100644 --- a/Content Types/Create/Add existing content type directly to SPO list/AddExistingContentTypetoOneList.ps1 +++ b/Content Types/Create/Add existing content type directly to SPO list/AddExistingContentTypetoOneList.ps1 @@ -1,47 +1,40 @@ -function Add-SPOContentType -{ -param( -[Parameter(Mandatory=$true,Position=1)] +function Add-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, - [Parameter(Mandatory=$true,Position=7)] + [Parameter(Mandatory=$true,Position=7)] [string]$ContentTypeID - ) - - $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() - - $contentType=$ctx.Web.ContentTypes.GetById($ContentTypeID) - $ctx.Load($contentType) - - $ll=$ctx.Web.Lists.GetByTitle($ListTitle) - $ctx.load($ll) - $ctx.load($ll.ContentTypes) - $ctx.ExecuteQuery() - $ll.ContentTypesEnabled=$true - $AddedContentType=$ll.ContentTypes.AddExistingContentType($contentType) - $ll.Update() - - try - { - - $ctx.ExecuteQuery() - Write-Host "Adding content type " $AddedContentType.Name " to " $ll.Title - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - - - + ) + + $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() + + $contentType=$ctx.Web.ContentTypes.GetById($ContentTypeID) + $ctx.Load($contentType) + + $ll=$ctx.Web.Lists.GetByTitle($ListTitle) + $ctx.load($ll) + $ctx.load($ll.ContentTypes) + $ctx.ExecuteQuery() + $ll.ContentTypesEnabled=$true + $AddedContentType=$ll.ContentTypes.AddExistingContentType($contentType) + $ll.Update() + + try{ + $ctx.ExecuteQuery() + Write-Host "Adding content type " $AddedContentType.Name " to " $ll.Title + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } } diff --git a/Content Types/Create/Add existing content type directly to SPO list/ReadMe.md b/Content Types/Create/Add existing content type directly to SPO list/ReadMe.md new file mode 100644 index 00000000..86ced017 --- /dev/null +++ b/Content Types/Create/Add existing content type directly to SPO list/ReadMe.md @@ -0,0 +1,55 @@ +A short script to add an existing site content type directly to a SharePoint Online list. + + + +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](https://www.microsoft.com/en-us/download/details.aspx?id=42038). + +2. Download the *.ps1* file. + +3. Open the file (you can do it also in NotePad) + +4. Insert your data in these lines: + +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlists" +$ListTitle="tas1207" +$ContentTypeID="0x01200200C44754774BD8D4449F4B7E3FE70A7E0E" +``` +
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) Enter the title of the list. +
e) Enter the content type id +
+##### *How to find the content type id?* +* via browser
+Go to **Site**>**Gear Icon**>**Site Settings**>**Content Types**>**Click on the content type**. The url at this point should look like **[this](https://tenant.sharepoint.com/sites/TeamsitewithLists/_layouts/15/ManageContentType.aspx?ctype=0x0100A02B0ABDDEDC5A45AC64F100F30899CF&Source=https%3A%2F%2Ftenant%2Esharepoint%2Ecom%2Fsites%2FTeamsitewithLists%2F%5Flayouts%2F15%2Fmngctype%2Easpx)**. +```diff +https://tenant.sharepoint.com/sites/TeamsitewithLists/_layouts/15/ManageContentType.aspx?ctype= +- 0x0100A02B0ABDDEDC5A45AC64F100F30899CF +&Source=https%3A%2F%2Ftenant%2Esharepoint%2Ecom%2Fsites%2FTeamsitewithLists%2F%5Flayouts%2F15%2Fmngctype%2Easpx +``` +Marked in red is the content type id. + +* via another script
+[Get all properties of all content types in a SharePoint site](https://gallery.technet.microsoft.com/Get-all-properties-of-all-3a9c5c4b) + +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*. + + +

+Enjoy and please share feedback! diff --git a/Content Types/Create/Add existing content type directly to SPO list/description.md b/Content Types/Create/Add existing content type directly to SPO list/description.md index f318e934..86ced017 100644 --- a/Content Types/Create/Add existing content type directly to SPO list/description.md +++ b/Content Types/Create/Add existing content type directly to SPO list/description.md @@ -2,16 +2,14 @@ A short script to add an existing site content type directly to a SharePoint Onl -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) @@ -35,21 +33,23 @@ $ContentTypeID="0x01200200C44754774BD8D4449F4B7E3FE70A7E0E"
d) Enter the title of the list.
e) Enter the content type id
-###### How to find the content type id? -* via browser -Go to Site>Gear Icon>Site Settings>Content Types>Click on the content type. The url at this point should look like this: -https://tenant.sharepoint.com/sites/TeamsitewithLists/_layouts/15/ManageContentType.aspx?ctype=0x0100A02B0ABDDEDC5A45AC64F100F30899CF&Source=https%3A%2F%2Ftenant%2Esharepoint%2Ecom%2Fsites%2FTeamsitewithLists%2F%5Flayouts%2F15%2Fmngctype%2Easpx +##### *How to find the content type id?* +* via browser
+Go to **Site**>**Gear Icon**>**Site Settings**>**Content Types**>**Click on the content type**. The url at this point should look like **[this](https://tenant.sharepoint.com/sites/TeamsitewithLists/_layouts/15/ManageContentType.aspx?ctype=0x0100A02B0ABDDEDC5A45AC64F100F30899CF&Source=https%3A%2F%2Ftenant%2Esharepoint%2Ecom%2Fsites%2FTeamsitewithLists%2F%5Flayouts%2F15%2Fmngctype%2Easpx)**. +```diff +https://tenant.sharepoint.com/sites/TeamsitewithLists/_layouts/15/ManageContentType.aspx?ctype= +- 0x0100A02B0ABDDEDC5A45AC64F100F30899CF +&Source=https%3A%2F%2Ftenant%2Esharepoint%2Ecom%2Fsites%2FTeamsitewithLists%2F%5Flayouts%2F15%2Fmngctype%2Easpx +``` Marked in red is the content type id. -* via another script -Get all properties of all content types in a SharePoint site - +* via another script
+[Get all properties of all content types in a SharePoint site](https://gallery.technet.microsoft.com/Get-all-properties-of-all-3a9c5c4b) 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*. -

Enjoy and please share feedback! diff --git a/Content Types/Create/Create a content type/ReadMe.md b/Content Types/Create/Create a content type/ReadMe.md new file mode 100644 index 00000000..d07b7ff8 --- /dev/null +++ b/Content Types/Create/Create a content type/ReadMe.md @@ -0,0 +1,45 @@ +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). + +### How to use? + + + +1. Download and install [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038). + +2. Download the *.ps1* file. + +3. Open the file (you can do it also in NotePad) + +4. Insert your data in these lines: +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" +$Description="desc" +$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.
+ +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*. + + + + + +

+Enjoy and please share feedback! diff --git a/Content Types/Create/Create and add content type to a content type hub/ReadMe.md b/Content Types/Create/Create and add content type to a content type hub/ReadMe.md new file mode 100644 index 00000000..37df3632 --- /dev/null +++ b/Content Types/Create/Create and add content type to a content type hub/ReadMe.md @@ -0,0 +1,41 @@ +A short script to create a content type and add it to a content type hub. + +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](https://www.microsoft.com/en-us/download/details.aspx?id=42038). + +2. Download the *.ps1* file. + +3. Open the file (you can do it also in NotePad) + +4. Insert your data in these lines: + +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/contenttypehub" +$Description="desc" +$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 TENANT in "https://tenant.sharepoint.com/sites/contenttypehub" enter the name of your tenant
+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*. + + +

+Enjoy and please share feedback! diff --git a/Content Types/Create/Create content type and add directly to SPO list/ReadMe.md b/Content Types/Create/Create content type and add directly to SPO list/ReadMe.md new file mode 100644 index 00000000..ca9aca82 --- /dev/null +++ b/Content Types/Create/Create content type and add directly to SPO list/ReadMe.md @@ -0,0 +1,44 @@ +A short script to create a content type, and add it directly to a SharePoint Online list. The content type does not appear among site content types. + + + +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](https://www.microsoft.com/en-us/download/details.aspx?id=42038). + +2. Download the *.ps1* file. + +3. Open the file (you can do it also in NotePad) + +4. Insert your data in these lines: + + +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" +$Description="desc" +$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.
+ +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*. + + +

+Enjoy and please share feedback! diff --git a/Content Types/Create/Create content type and add it to all lists in one site/ReadMe.md b/Content Types/Create/Create content type and add it to all lists in one site/ReadMe.md new file mode 100644 index 00000000..9b387e4a --- /dev/null +++ b/Content Types/Create/Create content type and add it to all lists in one site/ReadMe.md @@ -0,0 +1,43 @@ +A short script to create a content type, and add it directly to all SharePoint Online lists within one site. The content type does not appear among site content types. + + + +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](https://www.microsoft.com/en-us/download/details.aspx?id=42038). + +2. Download the *.ps1* file. + +3. Open the file (you can do it also in NotePad) + +4. Insert your data in these lines: + + +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" +$Description="desc" +$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.
+ +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*. + +

+Enjoy and please share feedback! diff --git a/Content Types/Display Forms/Find Custom Display Forms Deployed/ReadMe.md b/Content Types/Display Forms/Find Custom Display Forms Deployed/ReadMe.md new file mode 100644 index 00000000..0affd595 --- /dev/null +++ b/Content Types/Display Forms/Find Custom Display Forms Deployed/ReadMe.md @@ -0,0 +1,29 @@ +The script is part of the explanation on editing the content types available in the article here: + +[SharePoint Online content types in Powershell: Edit.](https://social.technet.microsoft.com/wiki/contents/articles/31444.sharepoint-online-content-types-in-powershell-edit.aspx) + +This example gets the list of all content types in all lists from a single site, which have custom display forms deployed. + + + +The *~list/Item/displayifs.aspx* is the url of the custom form that the list is using for adding new items. (**[screenshot](https://github.com/PowershellScripts/AllGalleryScriptsSamples/blob/develop/Content%20Types/Display%20Forms/Find%20Custom%20Display%20Forms%20Deployed/DisplayFormUrl3.png)**) + + +In order to use the script you need [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038) installed. Before running the script modify the following lines to refer to the SDK libraries installed on your computer and the content type data: + + + +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/powie1" +``` + + +

+Enjoy and please share feedback! diff --git a/Content Types/Display Forms/Modify the Display Form Template Name/Readme.md b/Content Types/Display Forms/Modify the Display Form Template Name/Readme.md new file mode 100644 index 00000000..17807251 --- /dev/null +++ b/Content Types/Display Forms/Modify the Display Form Template Name/Readme.md @@ -0,0 +1,25 @@ +The script is part of the explanation on editing the content types available in the article here: + +[SharePoint Online content types in Powershell: Edit.](https://social.technet.microsoft.com/wiki/contents/articles/31444.sharepoint-online-content-types-in-powershell-edit.aspx) + +This example gets all content types in a single list from a single site, and changes their display form names, using: + +```PowerShell +$cc.DisplayFormTemplateName="DocumentLibraryForm" +``` +The script requires [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038) installed. Before running the script, enter the information: + +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/powie1" +$ListTitle="notf--ked" +``` + +

+Enjoy and please share feedback! diff --git a/Content Types/Display Forms/Unable to view items- modify the DisplayFormUrl back to default one/ReadMe.md b/Content Types/Display Forms/Unable to view items- modify the DisplayFormUrl back to default one/ReadMe.md new file mode 100644 index 00000000..5b475523 --- /dev/null +++ b/Content Types/Display Forms/Unable to view items- modify the DisplayFormUrl back to default one/ReadMe.md @@ -0,0 +1,28 @@ +The script is part of the explanation on editing the content types available in the article here: + +[SharePoint Online content types in Powershell: Edit.](https://social.technet.microsoft.com/wiki/contents/articles/31444.sharepoint-online-content-types-in-powershell-edit.aspx) + +This example changes the display form url of all content types called ITEM (so basically all items in a list) in all lists in one site to the default one. + + It allows us also to retract our changes and turn to the default form in case something went wrong with the Custom form and items are no longer viewable. (**[screenshot](https://github.com/PowershellScripts/AllGalleryScriptsSamples/blob/develop/Content%20Types/Display%20Forms/Unable%20to%20view%20items-%20modify%20the%20DisplayFormUrl%20back%20to%20default%20one/DisplayFormUrl4.png)**) + + +In order to use the script you need [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038) installed. Before running the script modify the following lines to refer to the SDK libraries installed on your computer and the content type data: + + + +```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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/powie1" +``` + + + +

+Please share your questions and comments! diff --git a/Content Types/Get/All Content Types from a Content Type Hub and their DisplayFormTemplate/ModifyDisplayFormTemplateName-ContentTypeHub.ps1 b/Content Types/Get/All Content Types from a Content Type Hub and their DisplayFormTemplate/ModifyDisplayFormTemplateName-ContentTypeHub.ps1 index 91519a06..c16944a8 100644 --- a/Content Types/Get/All Content Types from a Content Type Hub and their DisplayFormTemplate/ModifyDisplayFormTemplateName-ContentTypeHub.ps1 +++ b/Content Types/Get/All Content Types from a Content Type Hub and their DisplayFormTemplate/ModifyDisplayFormTemplateName-ContentTypeHub.ps1 @@ -1,16 +1,14 @@  -function Set-SPOContentType -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] - [string]$Url - ) +function Set-SPOContentType{ +param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + $AdminPassword, + [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) @@ -18,21 +16,12 @@ function Set-SPOContentType $ctx.ExecuteQuery() - foreach($cc in $ctx.Web.ContentTypes) - { - - Write-Host $cc.Name " " $cc.DisplayFormTemplateName - - - +foreach($cc in $ctx.Web.ContentTypes){ + Write-Host $cc.Name " " $cc.DisplayFormTemplateName } - - - $ctx.Dispose() - - - } + $ctx.Dispose() +} diff --git a/Content Types/Get/Compare Web.AvailableContentTypes vs Web.ContentTypes/CompareAvVSCT.ps1 b/Content Types/Get/Compare Web.AvailableContentTypes vs Web.ContentTypes/CompareAvVSCT.ps1 index e516ffa6..17c036f1 100644 --- a/Content Types/Get/Compare Web.AvailableContentTypes vs Web.ContentTypes/CompareAvVSCT.ps1 +++ b/Content Types/Get/Compare Web.AvailableContentTypes vs Web.ContentTypes/CompareAvVSCT.ps1 @@ -1,64 +1,44 @@  -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.AvailableContentTypes) - $ctx.ExecuteQuery() - Write-Host -# Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - $i=0 - foreach( $cc in $ctx.Web.AvailableContentTypes) - { - - $i++ - - } - Write-Host "Available content types " $i - - $ctx.Load($ctx.Web.ContentTypes) - $ctx.ExecuteQuery() - Write-Host - # Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - $i=0 - foreach( $cc in $ctx.Web.ContentTypes) - { - - $i++ - - } - Write-Host "Content types in this site " $i - - - - } - - - - - - - - - - - - - + ) + + $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.AvailableContentTypes) + $ctx.ExecuteQuery() + Write-Host + # Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + $i=0 + + foreach( $cc in $ctx.Web.AvailableContentTypes){ + $i++ + } + + Write-Host "Available content types " $i + + $ctx.Load($ctx.Web.ContentTypes) + $ctx.ExecuteQuery() + Write-Host + # Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + $i=0 + + foreach( $cc in $ctx.Web.ContentTypes){ + $i++ + } + + Write-Host "Content types in this site " $i +} @@ -73,4 +53,4 @@ $AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries/subsite" -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 Hidden Content Types added to the site/GetSingleContentTypeLoop.ps1 b/Content Types/Get/Get All Hidden Content Types added to the site/GetSingleContentTypeLoop.ps1 index 91865e71..e9a3e086 100644 --- a/Content Types/Get/Get All Hidden Content Types added to the site/GetSingleContentTypeLoop.ps1 +++ b/Content Types/Get/Get All Hidden Content Types added to the site/GetSingleContentTypeLoop.ps1 @@ -1,48 +1,32 @@  -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() - - - foreach($cc in $ctx.Web.ContentTypes) - { - if($cc.Hidden -eq $true) - { - 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) + $ctx.Load($ctx.Web.ContentTypes) + $ctx.ExecuteQuery() + + + foreach($cc in $ctx.Web.ContentTypes){ + if($cc.Hidden -eq $true){ + Write-Host $cc.Name + } + } +} + # 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" @@ -56,4 +40,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/README.md b/Content Types/README.md index 8b137891..bf776345 100644 --- a/Content Types/README.md +++ b/Content Types/README.md @@ -1 +1,17 @@ +* Content Type Management Setting + * Allow content type management for all lists in a site + * Allow content type management for all lists in site collection + * Set content type management setting for a single list +* Create + * Add Content Type to Lists with Workflows + * Add Content Type to Task Lists + * Add existing content type directly to SPO list + * Create a content type + * Create and add content type to a content type hub + * Create content type and add directly to SPO list + * Create content type and add it to all lists in one site +* Display Forms + * Find Custom Display Forms Deployed + * Modify the Display Form Template Name + * Unable to view items- modify the DisplayFormUrl back to default diff --git a/Items Management/Bulk update all items in a list/BulkUpdate.ps1 b/Items Management/Bulk update all items in a list/BulkUpdate.ps1 index 03c51214..4e963d1c 100644 --- a/Items Management/Bulk update all items in a list/BulkUpdate.ps1 +++ b/Items Management/Bulk update all items in a list/BulkUpdate.ps1 @@ -1,20 +1,18 @@ - function Update-SPOListItem -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, - [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, -[Parameter(Mandatory=$true,Position=6)] - [string]$FieldToUpdate, -[Parameter(Mandatory=$true,Position=7)] - [string]$ValueToUpdate - ) +function Update-SPOListItem{ + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + [string]$AdminPassword, + [Parameter(Mandatory=$true,Position=4)] + [string]$ListTitle, + [Parameter(Mandatory=$true,Position=6)] + [string]$FieldToUpdate, + [Parameter(Mandatory=$true,Position=7)] + [string]$ValueToUpdate + ) @@ -39,30 +37,24 @@ $count=$itemki.Count Write-Host $count - foreach($item in $itemki) - { - $item[$FieldToUpdate]=$ValueToUpdate + + foreach($item in $itemki){ + $item[$FieldToUpdate]=$ValueToUpdate $item.Update() - } - - try - { - $ctx.ExecuteQuery() - write-host " Success" + try{ + $ctx.ExecuteQuery() + write-host " Success" } - catch [Net.WebException] - { + catch [Net.WebException]{ Write-Host $_.Exception.ToString() -ForegroundColor Red - } - - } +} # 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" -Update-SPOListItem -Username user@domain.onmicrosoft.com -Url https://tenant.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "contacts list" -FieldToUpdate MyColumnName -ValueToUpdate SomeRandomValue \ No newline at end of file +Update-SPOListItem -Username user@domain.onmicrosoft.com -Url https://tenant.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "contacts list" -FieldToUpdate MyColumnName -ValueToUpdate SomeRandomValue diff --git a/Items Management/Bulk update all items in a list/description.md b/Items Management/Bulk update all items in a list/description.md index 0396d756..2671eab5 100644 --- a/Items Management/Bulk update all items in a list/description.md +++ b/Items Management/Bulk update all items in a list/description.md @@ -1,41 +1,16 @@ Short Powershell script to bulk update all items in a list - - - +### **Example** - - -Example - - - - - - Result: + - - - - - +## **Requirements** - - - -Requirements - - - Before running the script, you have to modify the last lines! - - - - ```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" @@ -45,18 +20,18 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens Update-SPOListItem -Username user@tenant.onmicrosoft.com -Url https://tenant.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "contacts list" -FieldToUpdate elp -ValueToUpdate bio ``` -Enter your credentials -FieldToUpdate specifies the name of the list column which you want to update -ValueToUpdate means the value that you want to enter in that column for each item -Verify if the SharePoint Online SDK is installed in the same location on your computer ++ Enter your credentials
++ FieldToUpdate specifies the name of the list column which you want to update
++ ValueToUpdate means the value that you want to enter in that column for each item
++ Verify if the [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038) is installed in the same location on your computer
Related Scripts -Powershell Module with Update-SPOListItem cmdlet +[Powershell Module with Update-SPOListItem cmdlet](https://gallery.technet.microsoft.com/scriptcenter/Powershell-Module-for-easy-5d590623)

-Enjoy and please share feedback! \ No newline at end of file +Enjoy and please share feedback! diff --git a/Items Management/Create new list item using Powershell/NewSPOListItem.psm1 b/Items Management/Create new list item using Powershell/NewSPOListItem.psm1 index 8cf76cc3..fc64496c 100644 --- a/Items Management/Create new list item using Powershell/NewSPOListItem.psm1 +++ b/Items Management/Create new list item using Powershell/NewSPOListItem.psm1 @@ -1,23 +1,22 @@ -function New-SPOListItem -{ -param ( +function New-SPOListItem{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [string]$ItemTitle, -[Parameter(Mandatory=$false,Position=6)] - [string]$AdditionalField="", -[Parameter(Mandatory=$false,Position=7)] - [string]$AdditionalValue="" - ) - -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + [string]$ItemTitle, + [Parameter(Mandatory=$false,Position=6)] + [string]$AdditionalField="", + [Parameter(Mandatory=$false,Position=7)] + [string]$AdditionalValue="" + ) + + $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.Load($ctx.Web) @@ -32,25 +31,21 @@ $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force $listItem = $ll.AddItem($lici) $listItem["Title"]=$ItemTitle - if($AdditionalField -ne "") - { + + if($AdditionalField -ne ""){ $listItem[$AdditionalField]=$AdditionalValue } + $listItem.Update() $ll.Update() - try - { - - $ctx.ExecuteQuery() - Write-Host "Item " $ItemTitle " has been added to list " $ListTitle - } - catch [Net.WebException] - { + try{ + $ctx.ExecuteQuery() + Write-Host "Item " $ItemTitle " has been added to list " $ListTitle + } + catch [Net.WebException]{ Write-Host $_.Exception.ToString() - } - - + } } diff --git a/Items Management/Create new list item using Powershell/description.md b/Items Management/Create new list item using Powershell/description.md index 7c09a3b6..f1a9692b 100644 --- a/Items Management/Create new list item using Powershell/description.md +++ b/Items Management/Create new list item using Powershell/description.md @@ -2,58 +2,47 @@ Powershell Module with one new cmdlet -New-SPOListItem +## **New-SPOListItem** - - -Parameters +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of a site where you have the list - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's password - +```powershell [string]$ListTitle +``` Specifies the title of the list where you want to change the settings. - +```powershell [string]$ItemTitle +``` Specifies the title of the list item. In case of a contact list it will be the LastName, task list -> task name, etc. - +```powershell [string]$AdditionalField="" +``` Optional. If you want to add some additional attribute to the item at the moment of creation. For more attributes use Update-SPOListItem. This parameter defines the internal name of the column - +```powershell [string]$AdditionalValue="" +``` Optional. If you want to add some additional attribute to the item at the moment of creation. For more attributes use Update-SPOListItem. This parameter defines the value that you want to input. - - - - -Examples - - - - - - - - - - - - +### *Examples* -Requirements + -The following libraries (SharePoint Online SDK) are required. If those libraries are in different location on your computer, please edit the .psm1 file! +### *Requirements* - +The following libraries (SharePoint Online SDK) are required. If those libraries are in different location on your computer, please edit the ```.psm1``` file! ```PowerShell # Paths to SDK. Please verify location on your computer. @@ -61,12 +50,6 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" ``` - - - - - -

Enjoy and please share feedback! diff --git a/Items Management/Get the number of items in a list/GetSPOListItemCount.psm1 b/Items Management/Get the number of items in a list/GetSPOListItemCount.psm1 index 92ecf1ec..befd6e22 100644 --- a/Items Management/Get the number of items in a list/GetSPOListItemCount.psm1 +++ b/Items Management/Get the number of items in a list/GetSPOListItemCount.psm1 @@ -1,18 +1,14 @@ -function Get-SPOListItemCount -{ - - param ( +function Get-SPOListItemCount{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=3)] - [string]$ListTitle - ) - - + [string]$ListTitle + ) $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) @@ -25,8 +21,6 @@ $ctx.Load($ll) $ctx.ExecuteQuery() - - $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery $itemki=$ll.GetItems($spqQuery) @@ -34,12 +28,9 @@ $ctx.ExecuteQuery() $count=$itemki.Count - - + return $count - - - } +} # Paths to SDK. Please verify location on your computer. @@ -50,4 +41,4 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens -Export-ModuleMember -Function "Get-SPOListItemCount" \ No newline at end of file +Export-ModuleMember -Function "Get-SPOListItemCount" diff --git a/Items Management/Get the number of items in a list/description.md b/Items Management/Get the number of items in a list/description.md index b54e0377..c647cb03 100644 --- a/Items Management/Get the number of items in a list/description.md +++ b/Items Management/Get the number of items in a list/description.md @@ -1,29 +1,29 @@ New SharePoint Online Powershell cmdlet Get-SPOListItemCount which allows you to view the number of items in a list. -

Parameters

+## *Parameters* The cmdlet is using the following parameters: - - ```[string]$Username``` +```powershell + [string]$Username + ``` The string specifies admin of the site - -```[string]$Url``` +```powershell +[string]$Url +``` Specifies the url of a site where you have the list - -```[string]$AdminPassword``` +```powershell +[string]$AdminPassword +``` Admin's password - -```PowerShell[string]$ListTitle``` +```powershell +PowerShell[string]$ListTitle +``` Specifies the title of a list - - - - -

Requirements

+## *Requirements* @@ -37,13 +37,9 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens -

Examples

+## *Examples* - - - -

Enjoy and please share feedback! diff --git a/Items Management/GetSpoListItems and GetSPOListFields/GetSPOListItems9.psm1 b/Items Management/GetSpoListItems and GetSPOListFields/GetSPOListItems9.psm1 index fe28d475..3af3c212 100644 --- a/Items Management/GetSpoListItems and GetSPOListFields/GetSPOListItems9.psm1 +++ b/Items Management/GetSpoListItems and GetSPOListFields/GetSPOListItems9.psm1 @@ -1,19 +1,18 @@ -function Get-SPOListFields -{ - param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, - [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=3)] - [string]$ListTitle, - [Parameter(Mandatory=$false,Position=4)] - [bool]$IncludeSubsites=$false - ) - -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force +function Get-SPOListFields{ + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + [string]$AdminPassword, + [Parameter(Mandatory=$true,Position=3)] + [string]$ListTitle, + [Parameter(Mandatory=$false,Position=4)] + [bool]$IncludeSubsites=$false + ) + + $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.Load($ctx.Web.Lists) @@ -26,53 +25,50 @@ $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force $ctx.ExecuteQuery() - $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 - - $array=@() - $array+="InternalName" - $array+="StaticName" - $array+="Tag" - $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.Tag) - $obj | Add-Member NoteProperty $array[3]($fiel.Title) - - $fieldsArray+=$obj - $fieldslist+=$fiel.InternalName - Write-Output $obj - } + $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 + + $array=@() + $array+="InternalName" + $array+="StaticName" + $array+="Tag" + $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.Tag) + $obj | Add-Member NoteProperty $array[3]($fiel.Title) + + $fieldsArray+=$obj + $fieldslist+=$fiel.InternalName + Write-Output $obj + } $ctx.Dispose() return $fieldsArray - } -function Get-SPOListItems -{ - +function Get-SPOListItems{ param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, - [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, - [Parameter(Mandatory=$false,Position=5)] - [bool]$IncludeAllProperties=$false, - [switch]$Recursive - ) + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + [string]$AdminPassword, + [Parameter(Mandatory=$true,Position=4)] + [string]$ListTitle, + [Parameter(Mandatory=$false,Position=5)] + [bool]$IncludeAllProperties=$false, + [switch]$Recursive + ) @@ -91,62 +87,43 @@ function Get-SPOListItems - $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -# $spqQuery.ViewAttributes = "Scope='Recursive'" + $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + # $spqQuery.ViewAttributes = "Scope='Recursive'" -if($Recursive) -{ -$spqQuery.ViewXml =""; -} + if($Recursive){ + $spqQuery.ViewXml =""; + } + $bobo=Get-SPOListFields -Username $Username -Url $Url -AdminPassword $AdminPassword -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++){ $obj = New-Object PSObject - if($IncludeAllProperties) - { - - for($k=0;$k -lt $bobo.Count ; $k++) - { - + if($IncludeAllProperties){ + for($k=0;$k -lt $bobo.Count ; $k++){ # Write-Host $k $name=$bobo[$k].InternalName $value=$itemki[$j][$name] $obj | Add-Member NoteProperty $name($value) -Force - } - } - else - { + } + else{ $obj | Add-Member NoteProperty ID($itemki[$j]["ID"]) $obj | Add-Member NoteProperty Title($itemki[$j]["Title"]) - - } - + } # Write-Host $obj.ID `t $obj.Title $objArray+=$obj - - } - - return $objArray - - - } +} # Paths to SDK. Please verify location on your computer. @@ -157,4 +134,4 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens -Export-ModuleMember -Function "Get-SPOListItems", "Get-SPOListFields" \ No newline at end of file +Export-ModuleMember -Function "Get-SPOListItems", "Get-SPOListFields" diff --git a/Items Management/GetSpoListItems and GetSPOListFields/description.md b/Items Management/GetSpoListItems and GetSPOListFields/description.md index 945327f9..18bec11b 100644 --- a/Items Management/GetSpoListItems and GetSPOListFields/description.md +++ b/Items Management/GetSpoListItems and GetSPOListFields/description.md @@ -1,176 +1,125 @@ 2 new SharePoint Online Powershell cmdlets to help you view items in a SharePoint Online list: - - - - - -

Get-SPOListItems

+

Get-SPOListItems

Retrieves all items in a given list

Parameters

- - The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of a site where you have the list - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's password - -[string]$ListName -ListName. To retrieve a table of list names, you can use Get-SPOList - +```powershell +[string]$ListName +``` +ListName. To retrieve a table of list names, you can use [Get-SPOList](https://gallery.technet.microsoft.com/scriptcenter/GetSPOList-Module-to-view-cc4d3e9e) +```powershell [bool]$IncludeAllProperties=$false +``` Specifies whether you should view all the available properties or just the Id and Title. By the default it is set to $false. - - - - - - The equivalent in Graphic User Interface (GUI) of this cmdlet would be a list view. - - -

Examples

+

Examples

-Get all items in an announcements list ++ Get all items in an announcements list ```powershell Get-SPOListItems -Username -Url -AdminPassword -ListName ``` + - - - -Get all items in a contacts list and their properties ++ Get all items in a contacts list and their properties ```powershell Get-SPOListItems -Username -Url -AdminPassword -ListName -IncludeAllProperties $true (example shows only one of multiple retrieved items) ``` - + Get all items in a list and their properties and export to CSV ```powershell Get-SPOListItems -Username -Url -AdminPassword -ListName -IncludeAllProperties $true | Export-CSV ``` - -Get all contacts from a contact list that belong to a specific company ++ Get all contacts from a contact list that belong to a specific company ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Contacts list" -IncludeAllProperties $true | where {$_.Company -eq "Uogiavv"} | select Title, Company ``` - + ++ Get all properties of a document as a list item* - - -Get all properties of a document as a list item* - - - - - - - + Get a list of all documents in a document library ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Documents" -IncludeAllProperties $true | select FileLeafRef ``` + - - - - - -Get a list of all documents in a document library, including folders and subfolders ++ Get a list of all documents in a document library, including folders and subfolders ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Documents" -IncludeAllProperties $true -Recursive | select FileLeafRef ``` - -Get a list of all Excel documents in a document library ++ Get a list of all Excel documents in a document library ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Documents" -IncludeAllProperties $true | where {$_.File_x0020_Type -eq "xlsx"} |select FileLeafRef ``` - - - + - - -Get a list of all Excel documents in a document library and export to CSV ++ Get a list of all Excel documents in a document library and export to CSV ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Documents" -IncludeAllProperties $true | where {$_.File_x0020_Type -eq "xlsx"} |select FileLeafRef | export-csv ``` - - - - - - - +
- - -

Get-SPOListFields

+## **Get-SPOListFields** Retrieves all columns in a given list. This includes hidden columns and excluded from views. - - - - - - -

Parameters

+

Parameters

The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of a site where you have the list - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's password +```powershell +[string]$ListName +``` -[string]$ListName - - - - -

Examples

+

Examples

-Get all fields of a links list ++ Get all fields of a links list ```powershell Get-SPOListFields -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Links list" ``` + +

Requirements

- - - - - - -

Requirements

- - - -The following libraries (SharePoint Online SDK) are required. If those libraries are in different location on your computer, please edit the .psm1 file! +The following libraries (SharePoint Online SDK) are required. If those libraries are in different location on your computer, please edit the ```.psm1``` file! ```powershell # Paths to SDK. Please verify location on your computer. @@ -180,6 +129,6 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens -Technicalities -Get-SPOListItems is using InternalName for item properties +### **Technicalities** +Get-SPOListItems is using InternalName for item properties
18.01.15 Added recursion and -Recursive switch parameter diff --git a/Items Management/Module for item management/SPOListItemFunctions.psm1 b/Items Management/Module for item management/SPOListItemFunctions.psm1 index 715d157e..8e8d9ed6 100644 --- a/Items Management/Module for item management/SPOListItemFunctions.psm1 +++ b/Items Management/Module for item management/SPOListItemFunctions.psm1 @@ -1,18 +1,16 @@ -function Remove-SPOListItemInheritance -{ - - param ( +function Remove-SPOListItemInheritance{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID - ) + [Int]$ItemID + ) @@ -29,42 +27,37 @@ $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -$spqQuery.ViewXml =""; + $spqQuery.ViewXml =""; $itemek=$ll.GetItemByID($ItemID) $ctx.Load($itemek) $ctx.ExecuteQuery() $itemek.BreakRoleInheritance($true, $false) - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - - } + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } +} - function Remove-SPOListItemPermissions -{ - - param ( +function Remove-SPOListItemPermissions{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID - ) + [Int]$ItemID + ) @@ -81,42 +74,37 @@ $spqQuery.ViewXml =""; $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -$spqQuery.ViewXml =""; + $spqQuery.ViewXml =""; $itemek=$ll.GetItemByID($ItemID) $ctx.Load($itemek) $ctx.ExecuteQuery() $itemek.BreakRoleInheritance($false, $false) - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } -catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - - } + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } +} - function Restore-SPOListItemInheritance -{ - - param ( +function Restore-SPOListItemInheritance{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID - ) + [Int]$ItemID + ) @@ -133,41 +121,35 @@ catch [Net.WebException] $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -$spqQuery.ViewXml =""; + $spqQuery.ViewXml =""; $itemek=$ll.GetItemByID($ItemID) $ctx.Load($itemek) $ctx.ExecuteQuery() $itemek.ResetRoleInheritance() - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } - catch [Net.WebException] - { + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ Write-Host $_.Exception.ToString() - } - - - } + } +} - function Remove-SPOListItem -{ - - param ( +function Remove-SPOListItem{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID - ) + [Int]$ItemID + ) @@ -184,48 +166,43 @@ $spqQuery.ViewXml =""; $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -$spqQuery.ViewXml =""; + $spqQuery.ViewXml =""; $itemek=$ll.GetItemByID($ItemID) $ctx.Load($itemek) $ctx.ExecuteQuery() $itemek.DeleteObject() - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } -catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - - } + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } +} - function Update-SPOListItem -{ - - param ( +function Update-SPOListItem{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID, -[Parameter(Mandatory=$true,Position=6)] - [string]$FieldToUpdate, -[Parameter(Mandatory=$true,Position=7)] - [string]$ValueToUpdate - ) + [Int]$ItemID, + [Parameter(Mandatory=$true,Position=6)] + [string]$FieldToUpdate, + [Parameter(Mandatory=$true,Position=7)] + [string]$ValueToUpdate + ) @@ -250,18 +227,15 @@ catch [Net.WebException] $ctx.ExecuteQuery() $itemek[$FieldToUpdate] = $ValueToUpdate $itemek.Update() - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - - } + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } +} # 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" diff --git a/Items Management/Module for item management/description.md b/Items Management/Module for item management/description.md index 2c3d9a30..62713602 100644 --- a/Items Management/Module for item management/description.md +++ b/Items Management/Module for item management/description.md @@ -1,5 +1,5 @@ 5 cmdlets for item management: - +
Update-SPOListItem Remove-SPOListItem @@ -9,254 +9,207 @@ Remove-SPOListItemPermissions Remove-SPOListItemInheritance Restore-SPOListItemInheritance - + -Update-SPOListItem +## **Update-SPOListItem** Updates a property of an item -Parameters - - +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username +``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID - +```powershell [string]$FieldToUpdate -Mandatory. Specifies the name of the field to update. In order to get the internal names of the fields (more often than not they are different from column titles), you can use Get-SPOListFields - +``` +Mandatory. Specifies the name of the field to update. In order to get the internal names of the fields (more often than not they are different from column titles), you can use [Get-SPOListFields](https://gallery.technet.microsoft.com/scriptcenter/GetSpoListItems-and-a8ecd5fa) +```powershell [string]$ValueToUpdate +``` Mandatory. Specifies the value of the field for this item - +
-Example: +## *Example:* -Change the name of an item (file in this example) - ++ Change the name of an item (file in this example) + -Update a column for all items using Get-SPOListItems cmdlet -(Here we will be updating Title column to be called "Title" + the item ID number ++ Update a column for all items using [Get-SPOListItems cmdlet](https://gallery.technet.microsoft.com/scriptcenter/GetSpoListItems-and-a8ecd5fa) +(Here we will be updating Title column to be called "Title" + the item ID number + And the result: + +
- - - - - - - - - - - - - - - - - - -Remove-SPOListItem +## **Remove-SPOListItem** Removes an item - - -Parameters - - +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID - - -Example: - - - -Remove the item no 16 located in one of the subfolders - - - - - +## *Example:* - - - - - - - - ++ Remove the item no 16 located in one of the subfolders - + -Remove-SPOListItemPermissions +## **Remove-SPOListItemPermissions** Removes all permissions for an item. Only the user running the cmdlet will have access - - -Parameters - - +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID -Example: +## *Example:* -Remove the permissions -Remove-SPOListItemPermissions -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ListTitle chc1 -ItemID 4 ++ Remove the permissions - - - - - - - +Remove-SPOListItemPermissions -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ListTitle chc1 -ItemID 4 - + - +
-Remove-SPOListItemInheritance +## **Remove-SPOListItemInheritance** Stops inheriting permissions for an item - - -Parameters - - +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID - +
- - - - -Restore-SPOListItemInheritance +## **Restore-SPOListItemInheritance** Deletes unique permissions for an item - - -Parameters +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - +```powershell [string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID - - - - - - - - - - - - - - -Requirements +## *Requirements* diff --git a/Items Management/Remove permissions from SharePoint Online items/RemovePermissionsFromItems.ps1 b/Items Management/Remove permissions from SharePoint Online items/RemovePermissionsFromItems.ps1 index 459fc801..c2b6cb0e 100644 --- a/Items Management/Remove permissions from SharePoint Online items/RemovePermissionsFromItems.ps1 +++ b/Items Management/Remove permissions from SharePoint Online items/RemovePermissionsFromItems.ps1 @@ -1,17 +1,15 @@ <#Powershell script to remove permissions for all items in a SharePoint Online list. As a result, only the user running this script will have access to the files. Before you run it, you have to modify the last line of the script! #> -function Remove-SPOListAllItemsInheritance -{ - - param ( +function Remove-SPOListAllItemsInheritance{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle - ) + [string]$ListTitle + ) @@ -36,15 +34,13 @@ function Remove-SPOListAllItemsInheritance $ctx.ExecuteQuery() - for($j=0;$j -lt $itemki.Count ;$j++) - { + for($j=0;$j -lt $itemki.Count ;$j++){ $itemki[$j].BreakRoleInheritance($false, $false) } - $ctx.ExecuteQuery() - } +} # Paths to SDK. Please verify location on your computer. diff --git a/Items Management/Remove permissions from SharePoint Online items/description.md b/Items Management/Remove permissions from SharePoint Online items/description.md index 3a7cd73c..42166af2 100644 --- a/Items Management/Remove permissions from SharePoint Online items/description.md +++ b/Items Management/Remove permissions from SharePoint Online items/description.md @@ -2,31 +2,15 @@ Powershell script to remove permissions for all items in a SharePoint Online lis As a result, only the user running this script will have access to the files. - - - - -Result - - - - - - +### *Result* - + - - - +
-Requirements +### *Requirements* -Before you run it, you have to modify the last line of the script! - - - - +**Before you run it, you have to modify the last line of the script!** ```PowerShell # Paths to SDK. Please verify location on your computer. @@ -36,11 +20,11 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens Remove-SPOListAllItemsInheritance -Username "trial@trialtrial123.onmicrosoft.com" -Url "https://trialtrial123.sharepoint.com" -AdminPassword "Pass" -ListTitle "chc1" ``` -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 ++ Enter your credentials and the site where you want to modify the inheritance. ++ Verify if the [SharePoint Online SDK](http://www.microsoft.com/en-us/download/details.aspx?id=30722) is installed in the same location on your computer

-Enjoy and please share feedback!s \ No newline at end of file +Enjoy and please share feedback!s diff --git a/Licensing/Check User Licenses using plan type/CheckingLicensesWithPlanType.ps1 b/Licensing/Check User Licenses using plan type/CheckingLicensesWithPlanType.ps1 index e2cc800b..04e46cab 100644 --- a/Licensing/Check User Licenses using plan type/CheckingLicensesWithPlanType.ps1 +++ b/Licensing/Check User Licenses using plan type/CheckingLicensesWithPlanType.ps1 @@ -1,4 +1,4 @@ -<# +<# This script works only in limited number of scenarios. If you have more than one subscription, use another script 'CheckLicensesWithServiceName' also published on Technet Gallery ((Get-Msoluser -UserPrincipalName test2@trial765.onmicrosoft.com).licenses.servicestatus | where {$_.ServicePlan.ServiceType -eq "Exchange"}) @@ -31,31 +31,25 @@ Connect-MsolService #Gets the users $Users = Get-MSolUser -All -if($Users -ne $null) -{ -Write-Host "Loaded all users." +if($Users -ne $null){ + Write-Host "Loaded all users." } -else -{ -Write-Host "Couldn't get the users." +else{ + Write-Host "Couldn't get the users." } -if($CSVPath) -{ - Write-Host "Users will be saved to" $CSVPath +if($CSVPath){ + Write-Host "Users will be saved to" $CSVPath } -foreach($user in $users) -{ +foreach($user in $users){ #returns ServicePlan and ProvisioningStatus $serviceStatus=((Get-Msoluser -UserPrincipalName $user.userPrincipalName).licenses.servicestatus | where {$_.ServicePlan.ServiceType -eq $PlanToCheck}) - if($serviceStatus.ProvisioningStatus -eq "Disabled") - { - Write-Host $user.UserPrincipalName - if($CSVPath) - { - Export-Csv -InputObject $user -LiteralPath $CSVPath -Append + if($serviceStatus.ProvisioningStatus -eq "Disabled"){ + Write-Host $user.UserPrincipalName + if($CSVPath){ + Export-Csv -InputObject $user -LiteralPath $CSVPath -Append } } } diff --git a/Licensing/Check User Licenses using plan type/readme.md b/Licensing/Check User Licenses using plan type/readme.md index e63ae021..122e9903 100644 --- a/Licensing/Check User Licenses using plan type/readme.md +++ b/Licensing/Check User Licenses using plan type/readme.md @@ -8,15 +8,13 @@ EXCHANGE_S_STANDARD available in Office 365 Business and EXCHANGE_S_ENTERPRISE -If you have multiple subscriptions in your tenant and would like to check a particular service, e.g. only Exchange_S_Enterprise, use the Check user licenses using Service Name script here: +If you have multiple subscriptions in your tenant and would like to check a particular service, e.g. only Exchange_S_Enterprise, use the Check user licenses using Service Name script [here](https://gallery.technet.microsoft.com/Check-user-licenses-using-461b317c). -https://gallery.technet.microsoft.com/Check-user-licenses-using-461b317c +
- - -### How to use? +## **How to use?** -1. Make sure you have installed Azure AD module available here: https://msdn.microsoft.com/en-us/library/azure/jj151815(v=azure.98).aspx +1. Make sure you have installed Azure AD module available [here](https://msdn.microsoft.com/en-us/library/azure/jj151815(v=azure.98).aspx) 2. Download the script and open it (in Notepad, ISE, whatever you prefer). @@ -40,40 +38,24 @@ Plans to choose from. Please enter only one value above * MicrosoftCommunicationsOnline * Exchange - - In $PlanToCheck="Enter the name of the plan you want to check" In $CSVPath leave as it is if you don't want a csv report, or if you do, enter path in inverted commas like in the example below: - ```PowerShell $CSVPath="E:\technet\UsersWithDisabledEXO.csv" ``` - ```$ChecksWhetherThePlanIs ``` if set to "Disable" (as it is) will check for all disabled plans. If you want to check successfully provisioned or pending activation, enter "Success" or "PendingActivation". Important! Disabled are only the services where you assigned the license but not all services are active (e.g. E3 is assigned, but Exchange Online is unmarked). See example below: - - Here the license is disabled: - - - - - + Here it is NOT: - - - - - - - + 4. Save the script and drag&drop it to Powershell. It will ask you for credentials and display a list of users on the screen. diff --git a/Licensing/Check user licenses using Service Name/CheckLicensesWithServiceName.ps1 b/Licensing/Check user licenses using Service Name/CheckLicensesWithServiceName.ps1 index 74594b95..f4a0ced0 100644 --- a/Licensing/Check user licenses using Service Name/CheckLicensesWithServiceName.ps1 +++ b/Licensing/Check user licenses using Service Name/CheckLicensesWithServiceName.ps1 @@ -1,4 +1,4 @@ - + <# Possible serviceNames: PROJECTWORKMANAGEMENT @@ -36,31 +36,27 @@ Connect-MsolService #Gets the users $Users = Get-MSolUser -All -if($Users -ne $null) -{ -Write-Host "Loaded all users." +if($Users -ne $null){ + Write-Host "Loaded all users." } -else -{ -Write-Host "Couldn't get the users." +else{ + Write-Host "Couldn't get the users." } -if($CSVPath) -{ - Write-Host "Users will be saved to" $CSVPath +if($CSVPath){ + Write-Host "Users will be saved to" $CSVPath } -foreach($user in $users) -{ +foreach($user in $users){ #returns ServicePlan and ProvisioningStatus $serviceStatus=((Get-Msoluser -UserPrincipalName $user.userPrincipalName).licenses.servicestatus | where {$_.ServicePlan.ServiceName -eq $PlanToCheck}) - if($serviceStatus.ProvisioningStatus -eq "Disabled") - { - Write-Host $user.UserPrincipalName - if($CSVPath) - { - Export-Csv -InputObject $user -LiteralPath $CSVPath -Append + + if($serviceStatus.ProvisioningStatus -eq "Disabled"){ + Write-Host $user.UserPrincipalName + + if($CSVPath){ + Export-Csv -InputObject $user -LiteralPath $CSVPath -Append } } } diff --git a/Licensing/Check user licenses using Service Name/description.md b/Licensing/Check user licenses using Service Name/description.md index f4b3b1d4..62d50337 100644 --- a/Licensing/Check user licenses using Service Name/description.md +++ b/Licensing/Check user licenses using Service Name/description.md @@ -1,9 +1,7 @@ Powershell script to check user licenses by the service name. - - Possible service names: - +``` PROJECTWORKMANAGEMENT SWAY @@ -29,16 +27,16 @@ SHAREPOINTENTERPRISE EXCHANGE_S_STANDARD EXCHANGE_S_ENTERPRISE - +``` - +
-### How to use? +## **How to use?** -1. Make sure you have installed Azure AD module available here: https://msdn.microsoft.com/en-us/library/azure/jj151815(v=azure.98).aspx +1. Make sure you have installed Azure AD module available [here](https://msdn.microsoft.com/en-us/library/azure/jj151815(v=azure.98).aspx). 2. Download the script and open it (in Notepad, ISE, whatever you prefer). @@ -83,29 +81,15 @@ $CSVPath="E:\technet\UsersWithDisabledEXO.csv" Important! Disabled are only the services where you assigned the license but not all services are active (e.g. E3 is assigned, but Exchange Online is unmarked). See example below: - - Here the license is disabled: - - - - - + Here it is NOT: - - - - - - - + 4. Save the script and drag&drop it to Powershell. It will ask you for credentials and display a list of users on the screen. - -

-Enjoy and please share feedback! \ No newline at end of file +Enjoy and please share feedback! diff --git a/Licensing/Export all assigned licenses and services provisioning statuses/GetLicensesProvisioningStatusDoubleLicenses.ps1 b/Licensing/Export all assigned licenses and services provisioning statuses/GetLicensesProvisioningStatusDoubleLicenses.ps1 index ed2aabd4..da3345b1 100644 --- a/Licensing/Export all assigned licenses and services provisioning statuses/GetLicensesProvisioningStatusDoubleLicenses.ps1 +++ b/Licensing/Export all assigned licenses and services provisioning statuses/GetLicensesProvisioningStatusDoubleLicenses.ps1 @@ -17,28 +17,24 @@ Connect-MsolService #Gets the users $Users = Get-MSolUser -All -if($Users -ne $null) -{ -Write-Host "Loaded all users." +if($Users -ne $null){ + Write-Host "Loaded all users." } -else -{ +else{ return "Couldn't get the users." } -if($CSVPath) -{ +if($CSVPath){ Write-Host "Users will be saved to" $CSVPath } # Check each user for licenses -foreach($user in $users) -{ +foreach($user in $users){ # If user has more than 1 license assigned, he will appear twice in the report - foreach($license in (Get-Msoluser -UserPrincipalName $user.userPrincipalName).licenses) - { + + foreach($license in (Get-Msoluser -UserPrincipalName $user.userPrincipalName).licenses){ $ss=$license.ServiceStatus $count=$ss.Count $uss=New-Object PSObject @@ -47,18 +43,17 @@ foreach($user in $users) $uss | Add-Member -MemberType NoteProperty -Name "Office" -Value (Get-Msoluser -UserPrincipalName $user.userPrincipalName).Office # Looping through all the services, like TEAMS1, SharePointWAC, etc. and their statuses - for($i=0;$i -lt $count; $i++) - { - $uss | Add-Member -MemberType NoteProperty -Name $ss[$i].ServicePlan.ServiceName -Value $ss[$i].ProvisioningStatus + + for($i=0;$i -lt $count; $i++){ + $uss | Add-Member -MemberType NoteProperty -Name $ss[$i].ServicePlan.ServiceName -Value $ss[$i].ProvisioningStatus } #Printing out the user info $uss # If the path to CSV is specified, all info will be exported - if($CSVPath) - { - $uss | export-csv $CSVPath -Append -Force + if($CSVPath){ + $uss | export-csv $CSVPath -Append -Force } } } diff --git a/Licensing/Export all assigned licenses and services provisioning statuses/description.md b/Licensing/Export all assigned licenses and services provisioning statuses/description.md index 2158b271..fe902cff 100644 --- a/Licensing/Export all assigned licenses and services provisioning statuses/description.md +++ b/Licensing/Export all assigned licenses and services provisioning statuses/description.md @@ -2,22 +2,13 @@ Short Powershell script to export user licenses and services' provisioning statu -The script is a variation on Get user licenses and services' provisioning statuses . It accounts for the fact that one user may have more than one license assigned and creates records per given user's license. +The script is a variation on [Get user licenses and services' provisioning statuses](https://gallery.technet.microsoft.com/scriptcenter/Get-user-licenses-and-f20e5e42) . It accounts for the fact that one user may have more than one license assigned and creates records per given user's license. That means that in the exported csv file, a user with 2 licenses will appear twice, like this: - - - + - - - - - - -How to use? - +## How to use? 1. Download and run the script. @@ -27,28 +18,20 @@ How to use? - - -PowerShell +```PowerShell $CSVPath="C:\Users\Arletka\Documents\usss34.csv" - + ``` -Expected results +## Expected results During script execution: - - - - - + In a csv file: - - - + diff --git a/Licensing/Get user licenses and services provisioning statuses/GetLicensesProvisioningStatus.ps1 b/Licensing/Get user licenses and services provisioning statuses/GetLicensesProvisioningStatus.ps1 index 625add09..467bf5ee 100644 --- a/Licensing/Get user licenses and services provisioning statuses/GetLicensesProvisioningStatus.ps1 +++ b/Licensing/Get user licenses and services provisioning statuses/GetLicensesProvisioningStatus.ps1 @@ -17,42 +17,36 @@ Connect-MsolService #Gets the users $Users = Get-MSolUser -All -if($Users -ne $null) -{ -Write-Host "Loaded all users." +if($Users -ne $null){ + Write-Host "Loaded all users." } -else -{ +else{ return "Couldn't get the users." } -if($CSVPath) -{ +if($CSVPath){ Write-Host "Users will be saved to" $CSVPath } -foreach($user in $users) -{ - +foreach($user in $users){ $ss=(Get-Msoluser -UserPrincipalName $user.userPrincipalName).licenses.servicestatus $count=$ss.Count $uss=New-Object PSObject $uss | Add-Member -MemberType NoteProperty -Name "UPN" -Value $user.UserPrincipalName $uss | Add-Member -MemberType NoteProperty -Name "License" -Value (Get-Msoluser -UserPrincipalName $user.userPrincipalName).licenses.accountskuid $uss | Add-Member -MemberType NoteProperty -Name "Office" -Value (Get-Msoluser -UserPrincipalName $user.userPrincipalName).Office - for($i=0;$i -lt $count; $i++) - { - $uss | Add-Member -MemberType NoteProperty -Name $ss[$i].ServicePlan.ServiceName -Value $ss[$i].ProvisioningStatus + + for($i=0;$i -lt $count; $i++){ + $uss | Add-Member -MemberType NoteProperty -Name $ss[$i].ServicePlan.ServiceName -Value $ss[$i].ProvisioningStatus } $uss - if($CSVPath) - { - $uss | export-csv $CSVPath -Append -Force + + if($CSVPath){ + $uss | export-csv $CSVPath -Append -Force } #(Get-Msoluser -UserPrincipalName $user.userPrincipalName) | select UserPrincipalName, licenses | export-csv C:\Users\Arleta.Wanat\Documents\userrr4.csv -Append -Force #.servicestatus - } diff --git a/Licensing/Get user licenses and services provisioning statuses/description.md b/Licensing/Get user licenses and services provisioning statuses/description.md index e53d98f5..c27e86e1 100644 --- a/Licensing/Get user licenses and services provisioning statuses/description.md +++ b/Licensing/Get user licenses and services provisioning statuses/description.md @@ -1,11 +1,6 @@ Short Powershell script to export user licenses and services' provisioning status. - - - - -How to use? - +## How to use? 1. Download and run the script. @@ -15,26 +10,15 @@ How to use? -PowerShell +```PowerShell $CSVPath="C:\Users\Arletka\Documents\usss34.csv" +``` +## Expected results -Expected results - - During script execution: - - - - - + In a csv file: - - - - - - - + diff --git a/Licensing/Remove SharePoint Online licenses for all users/NoSpoLicense.ps1 b/Licensing/Remove SharePoint Online licenses for all users/NoSpoLicense.ps1 index 64d22504..94770e1f 100644 --- a/Licensing/Remove SharePoint Online licenses for all users/NoSpoLicense.ps1 +++ b/Licensing/Remove SharePoint Online licenses for all users/NoSpoLicense.ps1 @@ -1,4 +1,4 @@ -Connect-MsolService +Connect-MsolService # Disabled Plans $disabledPlans= @() $disabledPlans +="SHAREPOINTENTERPRISE" @@ -14,8 +14,7 @@ $Users = Get-MsolUser -All Write-Host $Plan - foreach($user in $Users) - { + foreach($user in $Users){ Set-MsolUser -UserPrincipalName $user.UserPrincipalName -UsageLocation "US" Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -RemoveLicenses $Plan Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -AddLicenses $Plan -LicenseOptions $noSPO diff --git a/Licensing/Remove SharePoint Online licenses for all users/description.md b/Licensing/Remove SharePoint Online licenses for all users/description.md index 47cf1ab0..fd1c9252 100644 --- a/Licensing/Remove SharePoint Online licenses for all users/description.md +++ b/Licensing/Remove SharePoint Online licenses for all users/description.md @@ -4,15 +4,7 @@ A short script to remove SharePoint Online license from all the users. The result for all users should be similar to: - - - - - - - - - + The script will ask you for admin credentials. @@ -51,11 +43,11 @@ foreach($user in $Users) -Though a different scenario and on a different occassions, I have been using this article http://blogs.technet.com/b/treycarlee/archive/2013/11/01/list-of-powershell-licensing-sku-s-for-office-365.aspx by Trey Carlee for a long time and the script above would not exist without Trey's initial help. I do recommend his insights for all who struggle with user licensing. +Though a different scenario and on a different occassions, I have been using this [article](http://blogs.technet.com/b/treycarlee/archive/2013/11/01/list-of-powershell-licensing-sku-s-for-office-365.aspx) by [Trey Carlee](https://social.technet.microsoft.com/profile/Trey%20Carlee) for a long time and the script above would not exist without Trey's initial help. I do recommend his insights for all who struggle with user licensing.

-Enjoy and please share your comments and questions! \ No newline at end of file +Enjoy and please share your comments and questions! diff --git a/Lists and Libraries Management/Column Management/Add a geolocation column/AddGeolocationField.ps1 b/Lists and Libraries Management/Column Management/Add a geolocation column/AddGeolocationField.ps1 new file mode 100644 index 00000000..f534f390 --- /dev/null +++ b/Lists and Libraries Management/Column Management/Add a geolocation column/AddGeolocationField.ps1 @@ -0,0 +1,70 @@ +function Add-GeoLocationField +{ +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)] + [string]$ListTitle + + ) + + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $web=$ctx.Web + $ctx.Load($web) + $ctx.ExecuteQuery() + + $list = $web.Lists.GetByTitle($ListTitle) + $ctx.Load($list) + $ctx.ExecuteQuery() + + $geolocationfield=$list.Fields.AddFieldAsXml("", $true, [Microsoft.SharePoint.Client.AddFieldOptions]::AddToAllContentTypes) + $list.Update() + $ctx.ExecuteQuery() + + <# + $ViewCreationInfo = New-Object Microsoft.SharePoint.Client.ViewCreationInformation + $ViewCreationInfo.Title="MapView" + $ViewCreationInfo.ViewFields=("Title","Location2") + $ViewCreationInfo.ViewTypeKind=[Microsoft.SharePoint.Client.ViewType]::Html + $View = $list.Views.Add($ViewCreationInfo) + $View.JSLink="mapviewtemplate.js" + #$View.DefaultView=$true + $View.Update() + $ctx.ExecuteQuery() + $View.JSLink + + + $ctx.Web.AllProperties["BING_MAPS_KEY"]="AjtUzWJBHlI3Ma_Ke6Qv2fGRXEs0ua5hUQi54ECwfXTiWsitll4AkETZDihjcfeI" + $ctx.Web.Update() + $ctx.ExecuteQuery() + + #> + + + +} + + + + +#Paths to SDK +Add-Type -Path "C:\Program Files (x86)\Common Files\microsoft shared\Web Server Extensions\16\Microsoft.SharePoint.Client.dll" +Add-Type -Path "C:\Program Files (x86)\Common Files\microsoft shared\Web Server Extensions\16\Microsoft.SharePoint.Client.Runtime.dll" + + + +#Enter the data +$Password=Read-Host -Prompt "Enter password" -AsSecureString +$Username="me@testtenant.onmicrosoft.com" +$Url="https://tenant.sharepoint.com" +$ListTitle="test2" + + + +Add-GeoLocationField -Username $username -Password $Password -Url $Url -ListTitle $ListTitle \ No newline at end of file diff --git a/Lists and Libraries Management/Column Management/Add a geolocation column/description.md b/Lists and Libraries Management/Column Management/Add a geolocation column/description.md new file mode 100644 index 00000000..b78bc892 --- /dev/null +++ b/Lists and Libraries Management/Column Management/Add a geolocation column/description.md @@ -0,0 +1,43 @@ +Short Powershell script to create a geolocation field in SharePoint Online list. + + + +The script uses the following resources: + +https://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-add-a-geolocation-column-to-a-list-programmatically-in-sharepoint + +https://docs.microsoft.com/en-us/sharepoint/dev/general-development/create-a-map-view-for-the-geolocation-field-in-sharepoint + +https://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-set-the-bing-maps-key-at-the-web-and-farm-level-in-sharepoint + +https://docs.microsoft.com/en-us/sharepoint/dev/general-development/create-a-map-view-for-the-geolocation-field-in-sharepoint + + + + + +PowerShell + $list = $web.Lists.GetByTitle($ListTitle) + $ctx.Load($list) + $ctx.ExecuteQuery() + + $geolocationfield=$list.Fields.AddFieldAsXml("", $true, [Microsoft.SharePoint.Client.AddFieldOptions]::AddToAllContentTypes) + $list.Update() + $ctx.ExecuteQuery() + + + +In order to use it, open the file and enter correct values: + +PowerShell +#Paths to SDK +Add-Type -Path "C:\Program Files (x86)\Common Files\microsoft shared\Web Server Extensions\16\Microsoft.SharePoint.Client.dll" +Add-Type -Path "C:\Program Files (x86)\Common Files\microsoft shared\Web Server Extensions\16\Microsoft.SharePoint.Client.Runtime.dll" + + + +#Enter the data +$Password=Read-Host -Prompt "Enter password" -AsSecureString +$Username="me@testtenant.onmicrosoft.com" +$Url="https://tenant.sharepoint.com" +$ListTitle="test2" diff --git a/Lists and Libraries Management/Get the number of files and folders in library/Capture30.PNG b/Lists and Libraries Management/Get the number of files and folders in library/Capture30.PNG new file mode 100644 index 00000000..8c0fcb93 Binary files /dev/null and b/Lists and Libraries Management/Get the number of files and folders in library/Capture30.PNG differ diff --git a/Lists and Libraries Management/Get the number of files and folders in library/TotalNoOfItems.ps1 b/Lists and Libraries Management/Get the number of files and folders in library/TotalNoOfItems.ps1 new file mode 100644 index 00000000..38add1ae --- /dev/null +++ b/Lists and Libraries Management/Get the number of files and folders in library/TotalNoOfItems.ps1 @@ -0,0 +1,67 @@ +function Get-SPOListItemCount +{ +param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + [string]$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, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + $list=$ctx.Web.Lists.GetByTitle($ListTitle) + $ctx.Load($list) + $ctx.ExecuteQuery() + + $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + $spqQuery.ViewXml =""; + $listItems=$list.GetItems($spqQuery) + $ctx.Load($listItems) + $ctx.ExecuteQuery() + +<# Uncomment if you want to see the split between files and folders + + $NoOfFiles=0 + $NoOfFolders=0 + + foreach($item in $listItems) + { + if($item.FileSystemObjectType -eq "File") + { + $NoOfFiles++; + } + if($item.FileSystemObjectType -eq "Folder") + { + $NoOfFolders++; + } + } + + Write-Host "Total number of items: " $list.ItemCount + Write-Host "Number of files:" $NoOfFiles + Write-Host "Number of folders:" $NoOfFolders + + #> + + return $list.ItemCount + + +} + +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" + + + + $Username="test@tenant.onmicrosoft.com" + $Url = "https://tenant.sharepoint.com/sites/test" + $ListTitle = "noci" + $Password = Read-Host -Prompt "Enter password" -AsSecureString + + Get-SPOListItemCount -Username $Username -AdminPassword $Password -Url $Url -ListTitle $ListTitle diff --git a/Lists and Libraries Management/Get the number of files and folders in library/description.md b/Lists and Libraries Management/Get the number of files and folders in library/description.md new file mode 100644 index 00000000..38846a59 --- /dev/null +++ b/Lists and Libraries Management/Get the number of files and folders in library/description.md @@ -0,0 +1,57 @@ +Powershell script for getting the number of items, folders and files in a given SharePoint Online library. + + + +The script requires SharePoint Online SDK. + + + +In order to use it, download, open and edit the file: + + + +PowerShell +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" + + + + $Username="test@tenant.onmicrosoft.com" + $Url = "https://tenant.sharepoint.com/sites/test" + $ListTitle = "noci" + $Password = Read-Host -Prompt "Enter password" -AsSecureString + + + +If you want to see a division between files and folders, uncomment the following part of the code: + + + +PowerShell + +<# Uncomment if you want to see the split between files and folders + + $NoOfFiles=0 + $NoOfFolders=0 + + foreach($item in $listItems) + { + if($item.FileSystemObjectType -eq "File") + { + $NoOfFiles++; + } + if($item.FileSystemObjectType -eq "Folder") + { + $NoOfFolders++; + } + } + + Write-Host "Total number of items: " $list.ItemCount + Write-Host "Number of files:" $NoOfFiles + Write-Host "Number of folders:" $NoOfFolders + + #> + +Expected results will display the total number of items, number of files, and number of folders: + + diff --git a/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/Capture21.PNG b/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/Capture21.PNG new file mode 100644 index 00000000..39acc9da Binary files /dev/null and b/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/Capture21.PNG differ diff --git a/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/Set-VersionLimit.ps1 b/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/Set-VersionLimit.ps1 new file mode 100644 index 00000000..60bab7c4 --- /dev/null +++ b/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/Set-VersionLimit.ps1 @@ -0,0 +1,113 @@ +function Set-VersionLimit +{ +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)] + [int]$VersionLimit, + [Parameter(Mandatory=$false,Position=5)] + [bool]$Versioning + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $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 $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + + foreach($list in $ctx.Web.Lists) + { + $csvvalue= New-Object PSObject + $csvvalue | Add-Member -MemberType NoteProperty -Name "Previous Versioning Status" -Value $list.EnableVersioning + +# $list.EnableVersioning = $Versioning + $list.MajorVersionLimit = $VersionLimit + $list.Update() + $listurl=$null + + if($ctx.Url.EndsWith("/")) + { + $listurl= $ctx.Url+$list.Title + } + else + { + $listurl=$ctx.Url+"/"+$list.Title + } + + + $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) + $csvvalue | Add-Member -MemberType NoteProperty -Name "Title" -Value $list.Title + $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 $_.Exception.Message -ForegroundColor Red + } + finally + { + $ErrorActionPreference="Continue" + } + + + } + + if($ctx.Web.Webs.Count -gt 0) + { + for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++) + { + Set-VersionLimit -Username $Username -Url $ctx.Web.Webs[$i].Url -Password $Password -VersionLimit $VersionLimit -Versioning $Versioning + } + } + + + +} + +# 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" + + + +# Versioning will be enabled. If you prefer to disable it for the whole tenant, change to $false +$Versioning = $true + +#Number of major versions to keep +$VersionLimit = 14 + +# You can also enter credentials directly: $siteUrl="https://tenant-admin.sharepoint.com" +$AdminUrl = "https://tenant-admin.sharepoint.com” +$Username = "test@tenant.onmicrosoft.com" +$Password = Read-Host -Prompt "Enter password" -AsSecureString +$Creds= New-Object System.Management.Automation.PSCredential($username,$password) +Connect-SPOService -Credential $Creds -Url $AdminUrl + +$sitecollections=Get-SPOSite +$Global:csv=@() + +#Uncomment the foreach loop if you want to change the settings in all site collections +#foreach($sitecoll in $sitecollections) +#{ + Set-VersionLimit -Url ("https://test.sharepoint.com/sites/test") -Username $Username -Password $Password -Versioning $Versioning -VersionLimit $VersionLimit +#} + + + +# Specify the path where the log file will be published +$Global:csv | Export-Csv -Path C:\Users\Public\Versioninglimitversion.csv diff --git a/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/description.md b/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/description.md new file mode 100644 index 00000000..c95d7eea --- /dev/null +++ b/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/description.md @@ -0,0 +1,70 @@ +A short script that sets the major version limit for all the libraries and lists in the whole site collection or in the whole tenant. + +It requires SharePoint Online Management Shell and SharePoint SDK installed: + +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. + +If the list doesn't have versioning enabled, modifying the major version limit is not possible and you will receive the following error message: + +Exception calling "ExecuteQuery" with "0" argument(s): "Specified method is not supported."For some lists, enabling version may not be possible and you will receive a notification of that. + +At the end, a csv file is generated with the lists' urls and the status whether the setting was successful or not. + + + +As the script runs you will see green lists' titles for which the setting succeeded and red for those which failed: + + + + + + + + + + + + + +In order to use the script, adjust the data inside: + +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" + + + +# Versioning will be enabled. If you prefer to disable it for the whole tenant, change to $false +$Versioning = $true + +#Number of major versions to keep +$VersionLimit = 14 + +# You can also enter credentials directly: $siteUrl="https://tenant-admin.sharepoint.com" +$AdminUrl = "https://tenant-admin.sharepoint.com” +$Username = "test@tenant.onmicrosoft.com" +$Password = Read-Host -Prompt "Enter password" -AsSecureString +$Creds= New-Object System.Management.Automation.PSCredential($username,$password) +Connect-SPOService -Credential $Creds -Url $AdminUrl + +$sitecollections=Get-SPOSite +$Global:csv=@() + +#Uncomment the foreach loop if you want to change the settings in all site collections +#foreach($sitecoll in $sitecollections) +#{ + Set-VersionLimit -Url ("https://test.sharepoint.com/sites/test") -Username $Username -Password $Password -Versioning $Versioning -VersionLimit $VersionLimit +#} + + + +# Specify the path where the log file will be published +$Global:csv | Export-Csv -Path C:\Users\Public\Versioninglimitversion.csv + diff --git a/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/versioningPS2 (1).png b/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/versioningPS2 (1).png new file mode 100644 index 00000000..7ba64ceb Binary files /dev/null and b/Lists and Libraries Management/Set the major version limit for all the lists and libraries (data loss involved)/versioningPS2 (1).png differ diff --git a/OneDrive for Business/Create a report on all file versions in OneDrive for Business/Capture1511.PNG b/OneDrive for Business/Create a report on all file versions in OneDrive for Business/Capture1511.PNG new file mode 100644 index 00000000..e6d65113 Binary files /dev/null and b/OneDrive for Business/Create a report on all file versions in OneDrive for Business/Capture1511.PNG differ diff --git a/OneDrive for Business/Create a report on all file versions in OneDrive for Business/GetVersionsinOneDrive.ps1 b/OneDrive for Business/Create a report on all file versions in OneDrive for Business/GetVersionsinOneDrive.ps1 new file mode 100644 index 00000000..10140465 --- /dev/null +++ b/OneDrive for Business/Create a report on all file versions in OneDrive for Business/GetVersionsinOneDrive.ps1 @@ -0,0 +1,102 @@ +function Get-SPOFolderFiles +{ +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=5)] + [string]$CSVPath, + [Parameter(Mandatory=$true,Position=6)] + [string]$CSVPath2 + ) + + + $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("Documents") + $ctx.Load($ll) + $ctx.ExecuteQuery() + + $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + $spqQuery.ViewXml =""; + $ODBitems=$ll.GetItems($spqQuery) + $ctx.Load($ODBitems) + $ctx.ExecuteQuery() + Write-Host "Found " $ODBitems.Count " folders and files" + + foreach($item in $ODBitems) + { + + Write-Host $item["FileRef"] "... " -NoNewline + $file = $ctx.Web.GetFileByServerRelativeUrl($item["FileRef"]); + $ctx.Load($file) + $ctx.Load($file.Versions) + + try + { + $ctx.ExecuteQuery() + } + catch + { + Write-Host "File not found" -ForegroundColor Red + } + + + 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 $CSVPath2 -Append + Write-Host "No versions available" -ForegroundColor DarkYellow + } + + if($file.Versions.Count -gt 0) + { + Write-Host $file.Versions.Count " version(s) found" -ForegroundColor Green + + foreach ($version in $file.Versions) + { + $user=$version.CreatedBy + $ctx.Load($version) + $ctx.Load($user) + $ctx.ExecuteQuery() + $version | Add-Member NoteProperty CreatedByUser($user.LoginName) + $version | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) + $version |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" + + +#Enter the data +#User with sufficient access to read the files +$username="german@test.onmicrosoft.com" +#Url of the site with the files (e.g. OneDrive site) +$Url="https://test-my.sharepoint.com/personal/german_test_onmicrosoft_com" + +#Path for a csv where file versions will be recorded +$csvPath="C:\MyFiles\Versions.csv" +#Path for a csv where files with no version will be recorded +$csvPath2="C:\MyFiles\FileThatShowsNoVersionsAvailable4.csv" + + +# Do not enter password in the file. You will be prompted for it during the script execution +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +Get-SPOFolderFiles -Username $username -Url $Url -password $AdminPassword -CSVPath $csvPath -CSVPath2 $csvPath2 \ No newline at end of file diff --git a/OneDrive for Business/Create a report on all file versions in OneDrive for Business/desscription.md b/OneDrive for Business/Create a report on all file versions in OneDrive for Business/desscription.md new file mode 100644 index 00000000..58278007 --- /dev/null +++ b/OneDrive for Business/Create a report on all file versions in OneDrive for Business/desscription.md @@ -0,0 +1,31 @@ +Powershell script that generates a report on available file versions in one OneDrive for Business account. It iterates through folders and subfolders in order to retrieve all items. + + + + + + + +It requires installed SharePoint Online SDK + +You have to enter the library data before running the script: + +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" + + +#Enter the data +#User with sufficient access to read the files +$username="german@test.onmicrosoft.com" +#Url of the site with the files (e.g. OneDrive site) +$Url="https://test-my.sharepoint.com/personal/german_test_onmicrosoft_com" + +#Path for a csv where file versions will be recorded +$csvPath="C:\MyFiles\Versions.csv" +#Path for a csv where files with no version will be recorded +$csvPath2="C:\MyFiles\FileThatShowsNoVersionsAvailable4.csv" + +You will see the following output during the script execution and 2 csv files will be generated: + diff --git a/Site Management/Recycle Bin/Restore deleted items from a single subsite/Capture8.PNG b/Site Management/Recycle Bin/Restore deleted items from a single subsite/Capture8.PNG new file mode 100644 index 00000000..32f3d492 Binary files /dev/null and b/Site Management/Recycle Bin/Restore deleted items from a single subsite/Capture8.PNG differ diff --git a/Site Management/Recycle Bin/Restore deleted items from a single subsite/Capture9.PNG b/Site Management/Recycle Bin/Restore deleted items from a single subsite/Capture9.PNG new file mode 100644 index 00000000..d5de689e Binary files /dev/null and b/Site Management/Recycle Bin/Restore deleted items from a single subsite/Capture9.PNG differ diff --git a/Site Management/Recycle Bin/Restore deleted items from a single subsite/description.md b/Site Management/Recycle Bin/Restore deleted items from a single subsite/description.md new file mode 100644 index 00000000..3c5dc5e1 --- /dev/null +++ b/Site Management/Recycle Bin/Restore deleted items from a single subsite/description.md @@ -0,0 +1,41 @@ +The script retrieves deleted items from a single site, displays them and restores. + + + +The script first displays the items to be restored. You can then decide whether to restore them all or not: + + + + + + + + + +The script requires SharePoint Online SDK. + + + + + +How to use? +1. Download and open the file. + +2. Verify the paths to SDK are correct: + +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" + +3. Enter the data. DO NOT enter your password. You will be asked for it during the script execution. + +PowerShell +# Insert the credentials and the name of the admin site +$Username="arleta@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$Site="https://tenant.sharepoint.com/sub1" + + + + diff --git a/Site Management/Recycle Bin/Restore deleted items from a single subsite/restoreDeletedFromOneSite.ps1 b/Site Management/Recycle Bin/Restore deleted items from a single subsite/restoreDeletedFromOneSite.ps1 new file mode 100644 index 00000000..ed04fbb9 --- /dev/null +++ b/Site Management/Recycle Bin/Restore deleted items from a single subsite/restoreDeletedFromOneSite.ps1 @@ -0,0 +1,120 @@ +function Get-DeletedItems +{ +param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + $AdminPassword, + [Parameter(Mandatory=$true,Position=3)] + [string]$Url +) + + +#Create the context and test the connection + $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 + } + + + +# Retrieve recycle bin items from a single subsite + $ctx.Load($ctx.Site) + $rb=$ctx.Web.RecycleBin + $ctx.Load($rb) + + try + { + $ctx.ExecuteQuery() + Write-Host $ctx.Site.Url " Items in the recycle bin: " $rb.Count.ToString() + } + catch [Net.WebException] + { + Write-Host $ctx.Site.Url " failed" $_.Exception.Message.ToString() -ForegroundColor Red + + } + +$myarray=@() + +#Add the items to an array and display them for a user + for($i=0;$i -lt $rb.Count ;$i++) + { + + $ctx.Load($rb[$i].Author) + $ctx.Load($rb[$i].DeletedBy) + $ctx.ExecuteQuery() + $obj = $rb[$i] + $obj | Add-Member NoteProperty AuthorLoginName($rb[$i].Author.LoginName) + $obj | Add-Member NoteProperty DeletedByLoginName($rb[$i].DeletedBy.LoginName) + $myarray+=$obj + Write-Host ($obj.DirName+"/"+$obj.LeafName) + + } + +# Asks permission to restore +Write-Host "`n`nProceed with restoring all these items?" -ForegroundColor Green +$proceed=Read-Host "y/n" + + if($proceed -eq "y") + { + for($i=0;$i -lt $myarray.Count ; $i++) + { + #Restores a single item + $myarray[$i].Restore() + + try + { + $ctx.ExecuteQuery() + Write-Host $myarray[$i].LeafName " restored" -ForegroundColor Green + } + catch [Net.WebException] + { + Write-Host $myarray[$i].LeafName " failed" $_.Message.ToString() -ForegroundColor Red + } + } + } + elseif($proceed -eq "n") + { + Write-Host "No items will be restored" + } + else + { + Write-Host "Command not recognized" + } + + + + + + + +} + + + + +# 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" + +# Insert the credentials and the name of the admin site +$Username="arleta@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$Site="https://tenant.sharepoint.com/sub1" + + + + Get-DeletedItems -Username $Username -AdminPassword $AdminPassword -Url $Site + + + + + + diff --git a/Versioning/Create a report on all file versions in OneDrive for Business/Capture1511.PNG b/Versioning/Create a report on all file versions in OneDrive for Business/Capture1511.PNG new file mode 100644 index 00000000..e6d65113 Binary files /dev/null and b/Versioning/Create a report on all file versions in OneDrive for Business/Capture1511.PNG differ diff --git a/Versioning/Create a report on all file versions in OneDrive for Business/GetVersionsinOneDrive.ps1 b/Versioning/Create a report on all file versions in OneDrive for Business/GetVersionsinOneDrive.ps1 new file mode 100644 index 00000000..10140465 --- /dev/null +++ b/Versioning/Create a report on all file versions in OneDrive for Business/GetVersionsinOneDrive.ps1 @@ -0,0 +1,102 @@ +function Get-SPOFolderFiles +{ +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=5)] + [string]$CSVPath, + [Parameter(Mandatory=$true,Position=6)] + [string]$CSVPath2 + ) + + + $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("Documents") + $ctx.Load($ll) + $ctx.ExecuteQuery() + + $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + $spqQuery.ViewXml =""; + $ODBitems=$ll.GetItems($spqQuery) + $ctx.Load($ODBitems) + $ctx.ExecuteQuery() + Write-Host "Found " $ODBitems.Count " folders and files" + + foreach($item in $ODBitems) + { + + Write-Host $item["FileRef"] "... " -NoNewline + $file = $ctx.Web.GetFileByServerRelativeUrl($item["FileRef"]); + $ctx.Load($file) + $ctx.Load($file.Versions) + + try + { + $ctx.ExecuteQuery() + } + catch + { + Write-Host "File not found" -ForegroundColor Red + } + + + 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 $CSVPath2 -Append + Write-Host "No versions available" -ForegroundColor DarkYellow + } + + if($file.Versions.Count -gt 0) + { + Write-Host $file.Versions.Count " version(s) found" -ForegroundColor Green + + foreach ($version in $file.Versions) + { + $user=$version.CreatedBy + $ctx.Load($version) + $ctx.Load($user) + $ctx.ExecuteQuery() + $version | Add-Member NoteProperty CreatedByUser($user.LoginName) + $version | Add-Member NoteProperty FileLeafRef($item["FileLeafRef"]) + $version |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" + + +#Enter the data +#User with sufficient access to read the files +$username="german@test.onmicrosoft.com" +#Url of the site with the files (e.g. OneDrive site) +$Url="https://test-my.sharepoint.com/personal/german_test_onmicrosoft_com" + +#Path for a csv where file versions will be recorded +$csvPath="C:\MyFiles\Versions.csv" +#Path for a csv where files with no version will be recorded +$csvPath2="C:\MyFiles\FileThatShowsNoVersionsAvailable4.csv" + + +# Do not enter password in the file. You will be prompted for it during the script execution +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +Get-SPOFolderFiles -Username $username -Url $Url -password $AdminPassword -CSVPath $csvPath -CSVPath2 $csvPath2 \ No newline at end of file diff --git a/Versioning/Create a report on all file versions in OneDrive for Business/desscription.md b/Versioning/Create a report on all file versions in OneDrive for Business/desscription.md new file mode 100644 index 00000000..58278007 --- /dev/null +++ b/Versioning/Create a report on all file versions in OneDrive for Business/desscription.md @@ -0,0 +1,31 @@ +Powershell script that generates a report on available file versions in one OneDrive for Business account. It iterates through folders and subfolders in order to retrieve all items. + + + + + + + +It requires installed SharePoint Online SDK + +You have to enter the library data before running the script: + +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" + + +#Enter the data +#User with sufficient access to read the files +$username="german@test.onmicrosoft.com" +#Url of the site with the files (e.g. OneDrive site) +$Url="https://test-my.sharepoint.com/personal/german_test_onmicrosoft_com" + +#Path for a csv where file versions will be recorded +$csvPath="C:\MyFiles\Versions.csv" +#Path for a csv where files with no version will be recorded +$csvPath2="C:\MyFiles\FileThatShowsNoVersionsAvailable4.csv" + +You will see the following output during the script execution and 2 csv files will be generated: + diff --git a/Workflows/Get workflow report for a site collection/SampleResults.csv b/Workflows/Get workflow report for a site collection/SampleResults.csv new file mode 100644 index 00000000..e5529813 --- /dev/null +++ b/Workflows/Get workflow report for a site collection/SampleResults.csv @@ -0,0 +1,3 @@ +#TYPE Microsoft.SharePoint.Client.Workflow.WorkflowAssociation +"SiteUrl","ListTitle","AllowManual","AssociationData","AutoStartChange","AutoStartCreate","BaseId","Created","Description","Enabled","HistoryListTitle","Id","InstantiationUrl","InternalName","IsDeclarative","ListId","Modified","Name","TaskListTitle","WebId","Context","Tag","Path","ObjectVersion","ServerObjectIsNull","TypedObject" +"https://etr45.sharepoint.com/sites/test1","test","True","false{32613E0A-2A96-4C71-A60E-9B8D1899FA6C}Enter Choice #1Enter Choice #2Enter Choice #3Workflow initiated: True{FA564E0F-0C70-4AB9-B863-0177E6DDD247}A workflow has been initiated on the following list item.True{FA564E0F-0C70-4AB9-B863-0177E6DDD247}TrueTrue{28CF69C5-FA48-462A-B5CD-27B6F9D2BD5F}UseAT{1DF5E554-EC7E-46A6-901D-D85A3881CB18}TrueTrueTrueTrueReview taskTrue{FA564E0F-0C70-4AB9-B863-0177E6DDD247}A review task has been created for the following list item.True{FA564E0F-0C70-4AB9-B863-0177E6DDD247}TrueTrue{28CF69C5-FA48-462A-B5CD-27B6F9D2BD5F}UseAT{1DF5E554-EC7E-46A6-901D-D85A3881CB18}TrueTrueTrueTrue","False","True","c6964bff-bf8d-41ac-ad5e-b61ec111731a","3/8/2020 12:19:48","Use this workflow to track items in a list.","True","Workflow History","41a550db-b5df-4fa7-b6d4-3cc1e5bb1a5a",,"test wf","False","91fb8ab4-ecf8-4f4a-becf-adb32f5d3f09","3/8/2020 12:19:48","test wf","Tasks","0da03cb4-066c-45ff-97c9-1d0a756e0c16","Microsoft.SharePoint.Client.ClientContext",,"Microsoft.SharePoint.Client.ObjectPathIdentity",,"False","Microsoft.SharePoint.Client.Workflow.WorkflowAssociation" diff --git a/Workflows/Get workflow report for all site collections/SampleResults.csv b/Workflows/Get workflow report for all site collections/SampleResults.csv new file mode 100644 index 00000000..e5529813 --- /dev/null +++ b/Workflows/Get workflow report for all site collections/SampleResults.csv @@ -0,0 +1,3 @@ +#TYPE Microsoft.SharePoint.Client.Workflow.WorkflowAssociation +"SiteUrl","ListTitle","AllowManual","AssociationData","AutoStartChange","AutoStartCreate","BaseId","Created","Description","Enabled","HistoryListTitle","Id","InstantiationUrl","InternalName","IsDeclarative","ListId","Modified","Name","TaskListTitle","WebId","Context","Tag","Path","ObjectVersion","ServerObjectIsNull","TypedObject" +"https://etr45.sharepoint.com/sites/test1","test","True","false{32613E0A-2A96-4C71-A60E-9B8D1899FA6C}Enter Choice #1Enter Choice #2Enter Choice #3Workflow initiated: True{FA564E0F-0C70-4AB9-B863-0177E6DDD247}A workflow has been initiated on the following list item.True{FA564E0F-0C70-4AB9-B863-0177E6DDD247}TrueTrue{28CF69C5-FA48-462A-B5CD-27B6F9D2BD5F}UseAT{1DF5E554-EC7E-46A6-901D-D85A3881CB18}TrueTrueTrueTrueReview taskTrue{FA564E0F-0C70-4AB9-B863-0177E6DDD247}A review task has been created for the following list item.True{FA564E0F-0C70-4AB9-B863-0177E6DDD247}TrueTrue{28CF69C5-FA48-462A-B5CD-27B6F9D2BD5F}UseAT{1DF5E554-EC7E-46A6-901D-D85A3881CB18}TrueTrueTrueTrue","False","True","c6964bff-bf8d-41ac-ad5e-b61ec111731a","3/8/2020 12:19:48","Use this workflow to track items in a list.","True","Workflow History","41a550db-b5df-4fa7-b6d4-3cc1e5bb1a5a",,"test wf","False","91fb8ab4-ecf8-4f4a-becf-adb32f5d3f09","3/8/2020 12:19:48","test wf","Tasks","0da03cb4-066c-45ff-97c9-1d0a756e0c16","Microsoft.SharePoint.Client.ClientContext",,"Microsoft.SharePoint.Client.ObjectPathIdentity",,"False","Microsoft.SharePoint.Client.Workflow.WorkflowAssociation" diff --git a/Workflows/Get workflow report for one site/SampleResults.csv b/Workflows/Get workflow report for one site/SampleResults.csv new file mode 100644 index 00000000..e5529813 --- /dev/null +++ b/Workflows/Get workflow report for one site/SampleResults.csv @@ -0,0 +1,3 @@ +#TYPE Microsoft.SharePoint.Client.Workflow.WorkflowAssociation +"SiteUrl","ListTitle","AllowManual","AssociationData","AutoStartChange","AutoStartCreate","BaseId","Created","Description","Enabled","HistoryListTitle","Id","InstantiationUrl","InternalName","IsDeclarative","ListId","Modified","Name","TaskListTitle","WebId","Context","Tag","Path","ObjectVersion","ServerObjectIsNull","TypedObject" +"https://etr45.sharepoint.com/sites/test1","test","True","false{32613E0A-2A96-4C71-A60E-9B8D1899FA6C}Enter Choice #1Enter Choice #2Enter Choice #3Workflow initiated: True{FA564E0F-0C70-4AB9-B863-0177E6DDD247}A workflow has been initiated on the following list item.True{FA564E0F-0C70-4AB9-B863-0177E6DDD247}TrueTrue{28CF69C5-FA48-462A-B5CD-27B6F9D2BD5F}UseAT{1DF5E554-EC7E-46A6-901D-D85A3881CB18}TrueTrueTrueTrueReview taskTrue{FA564E0F-0C70-4AB9-B863-0177E6DDD247}A review task has been created for the following list item.True{FA564E0F-0C70-4AB9-B863-0177E6DDD247}TrueTrue{28CF69C5-FA48-462A-B5CD-27B6F9D2BD5F}UseAT{1DF5E554-EC7E-46A6-901D-D85A3881CB18}TrueTrueTrueTrue","False","True","c6964bff-bf8d-41ac-ad5e-b61ec111731a","3/8/2020 12:19:48","Use this workflow to track items in a list.","True","Workflow History","41a550db-b5df-4fa7-b6d4-3cc1e5bb1a5a",,"test wf","False","91fb8ab4-ecf8-4f4a-becf-adb32f5d3f09","3/8/2020 12:19:48","test wf","Tasks","0da03cb4-066c-45ff-97c9-1d0a756e0c16","Microsoft.SharePoint.Client.ClientContext",,"Microsoft.SharePoint.Client.ObjectPathIdentity",,"False","Microsoft.SharePoint.Client.Workflow.WorkflowAssociation"