From 9105bedfaddad80ecab5538435440c1a007a20d9 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Wed, 29 Jan 2020 23:46:25 +0100 Subject: [PATCH 01/16] Update description.md --- .../description.md | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md index bc34af8c..eec2be23 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md @@ -1,29 +1,17 @@ A short Powershell script to allow management of content types for all SharePoint Online lists and libraries across all sites in a site collection - - -It is an equivalent of List>>List Settings>>Advanced>>Content types in Graphic User Interface (see screenshot) - - - - - - +It is an equivalent of **List**>>**List Settings**>>**Advanced**>>**Content types in Graphic User Interface** ([see screenshot](https://github.com/PowershellScripts/AllGalleryScriptsSamples/blob/develop/Content%20Types/Content%20Types%20Management%20Setting/Allow%20content%20type%20management%20for%20all%20lists%20in%20site%20collection/contentTypeManagement.png)) Applies to lists and libraries. - - -It requires installed SharePoint Online SDK +*It requires installed* [SharePoint Online SDK](www.microsoft.com/en-us/download/details.aspx?id=42038) You have to enter the list information before running the script: - - ```PowerShell # Paths to SDK. Please verify location on your computer. @@ -36,33 +24,26 @@ $AdminPassword="Pass" $Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" $ContentTypesEnabled=$true ``` - - - - - -Please share your thoughts in the Q&A section! - - +### Please share your thoughts in the Q&A section! -Wiki article with detailed code description: +#### Wiki article with detailed code description: [SharePoint Online: Turn on support for multiple content types in a list or library using Powershell](http://social.technet.microsoft.com/wiki/contents/articles/30038.sharepoint-online-turn-on-support-for-multiple-content-types-in-a-list-or-library-using-powershell.aspx) -Related scripts -Set-SPOList properties (module) +#### Related scripts +[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) -Disable or enable attachments to list items using Powershell +[Disable or enable attachments to list items using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795) -Change search setting for all lists in a site using CSOM and Powershell +[Change search setting for all lists in a site using CSOM and Powershell](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48) -Allow content type management for all lists in a site using Powershell +[Allow content type management for all lists in a site using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Allow-content-type-5bca5157) -Set content type management setting for SharePoint Online list using Powershell +[Set content type management setting for SharePoint Online list using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Set-content-type-39ae4bce)

From 0f71c38dedec432b8b64503fddc0949bd0171f8e Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Wed, 29 Jan 2020 23:51:00 +0100 Subject: [PATCH 02/16] Update ContentTypeManagementSubsitesIncluded.ps1 --- .../ContentTypeManagementSubsitesIncluded.ps1 | 87 +++++++++---------- 1 file changed, 39 insertions(+), 48 deletions(-) diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 index 9e762df4..71ad751b 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 @@ -3,61 +3,52 @@ # Created by Arleta Wanat, 2015 # -function Set-SPOListsContentTypesEnabled -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SPOListsContentTypesEnabled{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [bool]$ContentTypesEnabled -) - -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $ctx.ExecuteQuery() - -$Lists=$ctx.Web.Lists - $ctx.Load($ctx.Web) - $ctx.Load($ctx.Web.Webs) -$ctx.Load($Lists) -$ctx.ExecuteQuery() - -Foreach($ll in $Lists) -{ - $ll.ContentTypesEnabled = $ContentTypesEnabled - $ll.Update() - - - try - { - $ctx.ExecuteQuery() - Write-Host $ll.Title " Done" -ForegroundColor Green - } - - catch [Net.WebException] - { - - Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red - } + ) + + $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $ctx.ExecuteQuery() + + $Lists=$ctx.Web.Lists + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Web.Webs) + $ctx.Load($Lists) + $ctx.ExecuteQuery() + + Foreach($ll in $Lists){ + $ll.ContentTypesEnabled = $ContentTypesEnabled + $ll.Update() + + try{ + $ctx.ExecuteQuery() + Write-Host $ll.Title " Done" -ForegroundColor Green + } + catch [Net.WebException]{ + Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + } + } + + if($ctx.Web.Webs.Count -gt 0){ + Write-Host "--"-ForegroundColor DarkGreen + + for($i=0;$i -lt $ctx.Web.Webs.Count ;$i++){ + Set-SPOListsContentTypesEnabled -Username $Username -Url $ctx.Web.Webs[$i].Url -AdminPassword $AdminPassword -ContentTypesEnabled $ContentTypesEnabled + } + } } -if($ctx.Web.Webs.Count -gt 0) - { - Write-Host "--"-ForegroundColor DarkGreen - for($i=0;$i -lt $ctx.Web.Webs.Count ;$i++) - { - Set-SPOListsContentTypesEnabled -Username $Username -Url $ctx.Web.Webs[$i].Url -AdminPassword $AdminPassword -ContentTypesEnabled $ContentTypesEnabled - } - } - -} - @@ -80,4 +71,4 @@ $ContentTypesEnabled=$true -Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled \ No newline at end of file +Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled From b3bc53f7b9c36b4d3de5113e16e15a007d47da6c Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 31 Jan 2020 00:30:13 +0100 Subject: [PATCH 03/16] Update GetCTNamesinAllLists.ps1 --- .../GetCTNamesinAllLists.ps1 | 74 +++++++------------ 1 file changed, 26 insertions(+), 48 deletions(-) diff --git a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 index d5c99a27..8eef5e5a 100644 --- a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 +++ b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 @@ -1,64 +1,42 @@  -function Get-SPOList -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOList{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url - ) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ctx.ExecuteQuery() - - $ctx.Load($ctx.Web.Lists) - $ctx.ExecuteQuery() - Write-Host - Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - foreach( $ll in $ctx.Web.Lists) - { + ) - $ctx.Load($ll.ContentTypes) + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.ExecuteQuery() - try - { - $ctx.ExecuteQuery() - } - catch - { - } + $ctx.Load($ctx.Web.Lists) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + foreach( $ll in $ctx.Web.Lists){ + $ctx.Load($ll.ContentTypes) - - - Write-Host $ll.Title -ForegroundColor Green - - foreach($cc in $ll.ContentTypes) - { - Write-Output $cc.Name - } + try{ + $ctx.ExecuteQuery() + } + catch{} - - + Write-Host $ll.Title -ForegroundColor Green - - - } - - - - } - - + foreach($cc in $ll.ContentTypes){ + Write-Output $cc.Name + } + } +} - - + # Paths to SDK. Please verify location on your computer. @@ -71,4 +49,4 @@ $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" -Get-SPOList -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl \ No newline at end of file +Get-SPOList -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl From 48c51aa69736a9ecb39e902d441490763c78d427 Mon Sep 17 00:00:00 2001 From: PowershellScripts <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 11 Feb 2020 13:24:38 +0200 Subject: [PATCH 04/16] Update GetCTNamesinAllLists.ps1 --- .../GetCTNamesinAllLists.ps1 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 index 8eef5e5a..45c10140 100644 --- a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 +++ b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 @@ -1,5 +1,3 @@ - - function Get-SPOList{ param ( [Parameter(Mandatory=$true,Position=1)] @@ -22,16 +20,17 @@ function Get-SPOList{ foreach( $ll in $ctx.Web.Lists){ $ctx.Load($ll.ContentTypes) - try{ - $ctx.ExecuteQuery() - } - catch{} + try{ + $ctx.ExecuteQuery() + } + catch{ + } Write-Host $ll.Title -ForegroundColor Green - foreach($cc in $ll.ContentTypes){ - Write-Output $cc.Name - } + foreach($cc in $ll.ContentTypes){ + Write-Output $cc.Name + } } } From 9f37fd0fbbb6e7cff94c715e6f1ee7d49c88bf0b Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Thu, 27 Feb 2020 23:36:07 +0100 Subject: [PATCH 05/16] Update description.md --- .../description.md | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md index e17f799d..ae4331ff 100644 --- a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md +++ b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md @@ -1,22 +1,10 @@ -A short Powershell script to set the EnableAttachments property for a SharePoint Online list. The property is responsible for the Attach File icon under new item tab. If you disable the button, you and your users will not be able to add the attachments to list items. +A short Powershell script to set the EnableAttachments property for a SharePoint Online list. The property is responsible for the **Attach File** icon under **new item** tab. If you disable the button, you and your users will not be able to add the attachments to list items. -A short Powershell script to set the EnableAttachments property for a SharePoint Online list. The property is responsible for the Attach File icon under new item tab (see screenshot). The button allows you to add attachments to the list item. - - - - - - - - + If you disable the button, you and your users will not be able to add the attachments to list items: - - - - - + Applies to lists. @@ -24,7 +12,7 @@ Applies to lists. -It requires installed SharePoint Online SDK +It requires installed [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038) You have to enter the list information before running the script: @@ -45,18 +33,14 @@ $ListName="Tasks list" $Attachments =$false ``` -### Related scripts -Set direction of the reading order for a single list +## **Related scripts** +[Set direction of the reading order for a single list](https://gallery.technet.microsoft.com/office/Set-the-direction-of-the-f17ca66a) -Set-SPOList properties (module) - - - - +[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) -### Related article +## **Related article** -SharePoint Online: Disable or enable attachments to list items using Powershell +[SharePoint Online: Disable or enable attachments to list items using Powershell](https://social.technet.microsoft.com/wiki/contents/articles/30024.sharepoint-online-disable-or-enable-attachments-to-list-items-using-powershell.aspx)

From a37898138e7ee68cf6c16318ad913e8920686564 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Thu, 27 Feb 2020 23:36:41 +0100 Subject: [PATCH 06/16] Update ListAttachments.ps1 --- .../ListAttachments.ps1 | 50 ++++++++----------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 index 275e2759..874aabc2 100644 --- a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 +++ b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 @@ -1,57 +1,49 @@ - + # # Created by Arleta Wanat, 2015 # -function Set-SPOList -{ -param ( +function Set-SPOList{ + param ( [Parameter(Mandatory=$true,Position=0)] - [string]$ListName, + [string]$ListName, [Parameter(Mandatory=$true,Position=1)] - [bool]$Attachments - ) + [bool]$Attachments + ) -$ll=$ctx.Web.Lists.GetByTitle($ListName) + $ll=$ctx.Web.Lists.GetByTitle($ListName) -$ll.EnableAttachments = $Attachments - $ll.Update() + $ll.EnableAttachments = $Attachments + $ll.Update() - try - { + try{ $ctx.ExecuteQuery() Write-Host "Done" -ForegroundColor Green - } - - catch [Net.WebException] - { - - Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red - } - - + } + catch [Net.WebException] { + Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + } } -function Connect-SPOCSOM -{ - param ( - [Parameter(Mandatory=$true,Position=1)] +function Connect-SPOCSOM{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] [string]$AdminPassword, [Parameter(Mandatory=$true,Position=2)] [string]$Url -) + ) -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) $ctx.ExecuteQuery() -$global:ctx=$ctx + $global:ctx=$ctx } @@ -78,4 +70,4 @@ $Attachments =$true Connect-SPOCSOM -Username $Username -AdminPassword $AdminPassword -Url $Url -Set-SPOList -ListName $ListName -Attachments $Attachments \ No newline at end of file +Set-SPOList -ListName $ListName -Attachments $Attachments From 00d8e31143a0fafb4fec61ae0a8d53a5695ccea5 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 18:47:09 +0100 Subject: [PATCH 07/16] Update description.md --- .../description.md | 33 ++++--------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/User Profiles/Export all user profiles using Powershell/description.md b/User Profiles/Export all user profiles using Powershell/description.md index 06ca6781..34f308f6 100644 --- a/User Profiles/Export all user profiles using Powershell/description.md +++ b/User Profiles/Export all user profiles using Powershell/description.md @@ -1,43 +1,24 @@ The script retrieves all user profile properties for SharePoint Online users within one site. - - The script uses the following endpoint to retrieve a user property: -/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='' +```/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v=''``` - For more details, please consult: -User profiles REST API reference +[User profiles REST API reference](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn790354(v=office.15)?redirectedfrom=MSDN) - - - - -How to use? - +## How to use? Download, open the script and enter correct values in the following lines: -PowerShell +```PowerShell $SiteUrl="https://t321.sharepoint.com" $AdminCenter="https://t321-admin.sharepoint.com" $ExportTo="C:\Users\Arletka\Documents\SpUsers3.csv" + ``` - -Expected results +## Expected results - - - - - - - - - - - - + From 7a07a455cd2e0edaa2b06e9fd022bbee4673f378 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 18:48:10 +0100 Subject: [PATCH 08/16] Update ExportSPOUserAllPropertiesWithREST.ps1 --- .../ExportSPOUserAllPropertiesWithREST.ps1 | 81 +++++++------------ 1 file changed, 28 insertions(+), 53 deletions(-) diff --git a/User Profiles/Export all user profiles using Powershell/ExportSPOUserAllPropertiesWithREST.ps1 b/User Profiles/Export all user profiles using Powershell/ExportSPOUserAllPropertiesWithREST.ps1 index 17b1c888..374e29b6 100644 --- a/User Profiles/Export all user profiles using Powershell/ExportSPOUserAllPropertiesWithREST.ps1 +++ b/User Profiles/Export all user profiles using Powershell/ExportSPOUserAllPropertiesWithREST.ps1 @@ -1,58 +1,36 @@ -function Get-SPOUserProperty -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOUserProperty{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] $password, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string] $url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string] $userLogin - ) - - - - $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $RestUrl=$url+"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+$userLogin+"'" - - $request = [System.Net.WebRequest]::Create($RESTUrl) - $request.Credentials = $Credentials - $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") - $request.Accept = "application/json;odata=verbose" - [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get - $request.Method=$Method - $response = $request.GetResponse() - $requestStream = $response.GetResponseStream() - $read = New-Object System.IO.StreamReader $requestStream - $data=$read.ReadToEnd() - $results = $data | ConvertFrom-Json - - - - return ($results.d.userprofileproperties.results) - - - - - - - - - } - - - - - - - - + ) + + $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $RestUrl=$url+"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+$userLogin+"'" + + $request = [System.Net.WebRequest]::Create($RESTUrl) + $request.Credentials = $Credentials + $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") + $request.Accept = "application/json;odata=verbose" + [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get + $request.Method=$Method + $response = $request.GetResponse() + $requestStream = $response.GetResponseStream() + $read = New-Object System.IO.StreamReader $requestStream + $data=$read.ReadToEnd() + $results = $data | ConvertFrom-Json + + return ($results.d.userprofileproperties.results) +} #Paths to SDK Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.dll" Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.Runtime.dll" - #Enter the data @@ -65,16 +43,13 @@ $cred=Get-Credential Connect-SPOService $AdminCenter -Credential $cred $users=Get-SPOUser -Site $SiteUrl - -foreach($user in $users) -{ +foreach($user in $users){ Write-Verbose $user.LoginName $props=Get-SPOUserProperty -Username $cred.UserName -Url $SiteUrl -password $cred.Password -userLogin $user.LoginName $uss=New-Object PSObject - foreach($prop in $props) - { + + foreach($prop in $props){ $uss | Add-Member -MemberType NoteProperty -Name $prop.Key -Value $prop.Value - } $uss | Export-Csv -Path $ExportTo -Append -Force From eb76ad512557f99861a654464b484b4c763591ca Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 18:49:39 +0100 Subject: [PATCH 09/16] Update description.md --- .../description.md | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/User Profiles/Get MUI Languages for multiple users using REST/description.md b/User Profiles/Get MUI Languages for multiple users using REST/description.md index 150e60d4..8cf1df11 100644 --- a/User Profiles/Get MUI Languages for multiple users using REST/description.md +++ b/User Profiles/Get MUI Languages for multiple users using REST/description.md @@ -1,27 +1,18 @@ The script retrieves a SPS-MUILanguages property for specified SharePoint Online users. - - The script uses the following endpoint to retrieve a user property: -/getuserprofilepropertyfor(accountname=@v, propertyname='')?@v='' - - +```/getuserprofilepropertyfor(accountname=@v, propertyname='')?@v=''``` For more details, please consult: -User profiles REST API reference - - - - +[User profiles REST API reference](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn790354(v=office.15)?redirectedfrom=MSDN) -### How to use? +## How to use? - Download, open the script and enter correct values in the following lines: -PowerShell +```PowerShell #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="t@t321.onmicrosoft.com" @@ -29,10 +20,7 @@ $Url="https://t321.sharepoint.com" $userLogins=("t@t321.onmicrosoft.com","user1@t321.onmicrosoft.com","user2@t321.onmicrosoft.com","user5@t321.onmicrosoft.com","yasen@t321.onmicrosoft.com") + ``` +## Expected results -Expected results - - - - - + From 5378f04931fc17baa796c9f03992f13489a88307 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 18:50:33 +0100 Subject: [PATCH 10/16] Update GetSPOUserLanguagesWithREST.ps1 --- .../GetSPOUserLanguagesWithREST.ps1 | 76 ++++++------------- 1 file changed, 25 insertions(+), 51 deletions(-) diff --git a/User Profiles/Get MUI Languages for multiple users using REST/GetSPOUserLanguagesWithREST.ps1 b/User Profiles/Get MUI Languages for multiple users using REST/GetSPOUserLanguagesWithREST.ps1 index 1bd38dae..0c10a640 100644 --- a/User Profiles/Get MUI Languages for multiple users using REST/GetSPOUserLanguagesWithREST.ps1 +++ b/User Profiles/Get MUI Languages for multiple users using REST/GetSPOUserLanguagesWithREST.ps1 @@ -1,71 +1,45 @@ -function Get-SPOUserProperty -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOUserProperty{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] $password, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string] $url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string] $userLogin - ) + ) + $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $RestUrl=$url+"/_api/sp.userprofiles.peoplemanager/getuserprofilepropertyfor(accountname=@v, propertyname='SPS-MUILanguages')?@v='i%3A0%23.f%7Cmembership%7C"+$userLogin+"'" - - $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $RestUrl=$url+"/_api/sp.userprofiles.peoplemanager/getuserprofilepropertyfor(accountname=@v, propertyname='SPS-MUILanguages')?@v='i%3A0%23.f%7Cmembership%7C"+$userLogin+"'" - - $request = [System.Net.WebRequest]::Create($RESTUrl) - $request.Credentials = $Credentials - $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") - $request.Accept = "application/json;odata=verbose" - [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get - $request.Method=$Method - $response = $request.GetResponse() - $requestStream = $response.GetResponseStream() - $read = New-Object System.IO.StreamReader $requestStream - $data=$read.ReadToEnd() - - $results = $data | ConvertFrom-Json - - - - return (New-Object PSObject -Prop @{'Languages'=$results.d.GetUserProfilePropertyFor; 'User'=$userLogin}) - - - - - - - - - } - - - - - - + $request = [System.Net.WebRequest]::Create($RESTUrl) + $request.Credentials = $Credentials + $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") + $request.Accept = "application/json;odata=verbose" + [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get + $request.Method=$Method + $response = $request.GetResponse() + $requestStream = $response.GetResponseStream() + $read = New-Object System.IO.StreamReader $requestStream + $data=$read.ReadToEnd() + $results = $data | ConvertFrom-Json + return (New-Object PSObject -Prop @{'Languages'=$results.d.GetUserProfilePropertyFor; 'User'=$userLogin}) +} #Paths to SDK Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.dll" Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.Runtime.dll" - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="t@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com" - $userLogins=("t@t321.onmicrosoft.com","user1@t321.onmicrosoft.com","user2@t321.onmicrosoft.com","user5@t321.onmicrosoft.com","yasen@t321.onmicrosoft.com") - - -foreach($userLogin in $userLogins) -{ -Get-SPOUserProperty -Username $username -Url $Url -password $AdminPassword -userLogin $userLogin -} \ No newline at end of file +foreach($userLogin in $userLogins){ + Get-SPOUserProperty -Username $username -Url $Url -password $AdminPassword -userLogin $userLogin +} From 60a11cdbfe05745760da7e850cf03d128dd17579 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 18:52:04 +0100 Subject: [PATCH 11/16] Update description.md --- .../description.md | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/User Profiles/Get all user profile properties using Powershell and REST/description.md b/User Profiles/Get all user profile properties using Powershell and REST/description.md index d4fc507d..e3a6bd1a 100644 --- a/User Profiles/Get all user profile properties using Powershell and REST/description.md +++ b/User Profiles/Get all user profile properties using Powershell and REST/description.md @@ -1,24 +1,15 @@ -The script retrieves all user profile properties for the specified SharePoint Online user. - - +The script retrieves all user profile properties for the specified SharePoint Online user. The script uses the following endpoint to retrieve a user property: -/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='' - - +```/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v=''``` For more details, please consult: -User profiles REST API reference - - - - +[User profiles REST API reference](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn790354(v=office.15)?redirectedfrom=MSDN) -### How to use? +## How to use? - Download, open the script and enter correct values in the following lines: ```PowerShell @@ -28,17 +19,7 @@ $username="Admin@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com" $userLogin="user2@t321.onmicrosoft.com" ``` -Expected result - - - - - - - - - - - +## Expected result + From ce159b81ceccbac3c067d6d8010790bf02e98a24 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 18:52:47 +0100 Subject: [PATCH 12/16] Update GetSPOUserAllPropertiesWithREST.ps1 --- .../GetSPOUserAllPropertiesWithREST.ps1 | 75 +++++++------------ 1 file changed, 25 insertions(+), 50 deletions(-) diff --git a/User Profiles/Get all user profile properties using Powershell and REST/GetSPOUserAllPropertiesWithREST.ps1 b/User Profiles/Get all user profile properties using Powershell and REST/GetSPOUserAllPropertiesWithREST.ps1 index 4f0beaed..ebb4c2ee 100644 --- a/User Profiles/Get all user profile properties using Powershell and REST/GetSPOUserAllPropertiesWithREST.ps1 +++ b/User Profiles/Get all user profile properties using Powershell and REST/GetSPOUserAllPropertiesWithREST.ps1 @@ -1,66 +1,41 @@ -function Get-SPOUserProperty -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOUserProperty{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] $password, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string] $url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string] $userLogin - ) - - - - $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $RestUrl=$url+"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+$userLogin+"'" - - $request = [System.Net.WebRequest]::Create($RESTUrl) - $request.Credentials = $Credentials - $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") - $request.Accept = "application/json;odata=verbose" - [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get - $request.Method=$Method - $response = $request.GetResponse() - $requestStream = $response.GetResponseStream() - $read = New-Object System.IO.StreamReader $requestStream - $data=$read.ReadToEnd() - $results = $data | ConvertFrom-Json - - - - return ($results.d.userprofileproperties.results) - - - - - - - - - } - - - - - - - - + ) + + $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $RestUrl=$url+"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|"+$userLogin+"'" + + $request = [System.Net.WebRequest]::Create($RESTUrl) + $request.Credentials = $Credentials + $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") + $request.Accept = "application/json;odata=verbose" + [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get + $request.Method=$Method + $response = $request.GetResponse() + $requestStream = $response.GetResponseStream() + $read = New-Object System.IO.StreamReader $requestStream + $data=$read.ReadToEnd() + $results = $data | ConvertFrom-Json + + return ($results.d.userprofileproperties.results) +} #Paths to SDK Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.dll" Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.Runtime.dll" - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="Admin@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com" $userLogin="user2@t321.onmicrosoft.com" - - - Get-SPOUserProperty -Username $username -Url $Url -password $AdminPassword -userLogin $userLogin | select key, value From 0159f7ba446468edcda0b4a9df56f41673ef0552 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 18:54:21 +0100 Subject: [PATCH 13/16] Update description.md --- .../description.md | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/User Profiles/Get user work email using Powershell and REST/description.md b/User Profiles/Get user work email using Powershell and REST/description.md index e3f5f0a9..5f4c1d34 100644 --- a/User Profiles/Get user work email using Powershell and REST/description.md +++ b/User Profiles/Get user work email using Powershell and REST/description.md @@ -1,24 +1,15 @@ The script retrieves a WorkEmail property for a single SharePoint Online user. - - The script uses the following endpoint to retrieve a user property: -/getuserprofilepropertyfor(accountname=@v, propertyname='')?@v='' - - +```/getuserprofilepropertyfor(accountname=@v, propertyname='')?@v=''``` For more details, please consult: -User profiles REST API reference - - +[User profiles REST API reference](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn790354(v=office.15)?redirectedfrom=MSDN) +## How to use? - -### How to use? - - Download, open the script and enter correct values in the following lines: ```PowerShell @@ -28,8 +19,7 @@ $username="t@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com/polski" $userLogin="t@t321.onmicrosoft.com" ``` -Expected result +## Expected result - - + From 957d0ff8c6d998aeff2113eaf193d005b5cf408d Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 18:54:58 +0100 Subject: [PATCH 14/16] Update GetSPOUserEmailWithREST.ps1 --- .../GetSPOUserEmailWithREST.ps1 | 77 +++++++------------ 1 file changed, 26 insertions(+), 51 deletions(-) diff --git a/User Profiles/Get user work email using Powershell and REST/GetSPOUserEmailWithREST.ps1 b/User Profiles/Get user work email using Powershell and REST/GetSPOUserEmailWithREST.ps1 index 2ea7506d..ae023415 100644 --- a/User Profiles/Get user work email using Powershell and REST/GetSPOUserEmailWithREST.ps1 +++ b/User Profiles/Get user work email using Powershell and REST/GetSPOUserEmailWithREST.ps1 @@ -1,67 +1,42 @@ -function Get-SPOUserProperty -{ -param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOUserProperty{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [Parameter(Mandatory=$true,Position=2)] $password, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string] $url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string] $userLogin - ) - - - - $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) - $RestUrl=$url+"/_api/sp.userprofiles.peoplemanager/getuserprofilepropertyfor(accountname=@v, propertyname='WorkEmail')?@v='i%3A0%23.f%7Cmembership%7C"+$userLogin+"'" - - $request = [System.Net.WebRequest]::Create($RESTUrl) - $request.Credentials = $Credentials - $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") - $request.Accept = "application/json;odata=verbose" - [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get - $request.Method=$Method - $response = $request.GetResponse() - $requestStream = $response.GetResponseStream() - $read = New-Object System.IO.StreamReader $requestStream - $data=$read.ReadToEnd() - # Because the string contains duplicate 'ID' keys. - $results = $data | ConvertFrom-Json - - - - return ($results.d) - - - - - - - - - } - - - - - - - - + ) + + $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) + $RestUrl=$url+"/_api/sp.userprofiles.peoplemanager/getuserprofilepropertyfor(accountname=@v, propertyname='WorkEmail')?@v='i%3A0%23.f%7Cmembership%7C"+$userLogin+"'" + + $request = [System.Net.WebRequest]::Create($RESTUrl) + $request.Credentials = $Credentials + $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f") + $request.Accept = "application/json;odata=verbose" + [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get + $request.Method=$Method + $response = $request.GetResponse() + $requestStream = $response.GetResponseStream() + $read = New-Object System.IO.StreamReader $requestStream + $data=$read.ReadToEnd() + # Because the string contains duplicate 'ID' keys. + $results = $data | ConvertFrom-Json + + return ($results.d) +} #Paths to SDK Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.dll" Add-Type -Path "H:\Libraries\Microsoft.SharePoint.Client.Runtime.dll" - #Enter the data $AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString $username="t@t321.onmicrosoft.com" $Url="https://t321.sharepoint.com/polski" $userLogin="t@t321.onmicrosoft.com" - - - Get-SPOUserProperty -Username $username -Url $Url -password $AdminPassword -userLogin $userLogin From 01fb2a253d77d2ddce7bfa2c7d5b72cade046ed4 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 20:15:40 +0100 Subject: [PATCH 15/16] Update description.md --- .../description.md | 265 +----------------- 1 file changed, 4 insertions(+), 261 deletions(-) diff --git a/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md b/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md index 221ec711..9991cf47 100644 --- a/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md +++ b/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md @@ -6,9 +6,9 @@ That means that users having access to more than one site will appear more than -The .zip contains: +The ```.zip``` contains: -.exe file with a console application. Install to run. Enter global administrator credentials, the the admin Center url, and the report's path. +```.exe``` file with a console application. Install to run. Enter global administrator credentials, the the admin Center url, and the report's path. sample report @@ -25,354 +25,97 @@ The following properties are retrieved: - +``` "SPS-UserPrincipalName","UserProfile_GUID","SID","ADGuid","AccountName","FirstName","SPS-PhoneticFirstName", "LastName", - - - "SPS-PhoneticLastName", - - - "PreferredName", - - - "SPS-PhoneticDisplayName", - - - "WorkPhone", - - - "Department", - - - "Title", - - - "SPS-JobTitle", - - - "SPS-Department", - - - "Manager", - - - "AboutMe", - - - "PersonalSpace", - - - "PictureURL", - - - "UserName", - - - "QuickLinks", - - - "WebSite", - - - "SPS-DataSource", - - - "SPS-MemberOf", - - - "SPS-Dotted-line", - - - "SPS-Peers", - - - "SPS-Responsibility", - - - "SPS-SipAddress", - - - "SPS-MySiteUpgrade", - - - "SPS-DontSuggestList", - - - "SPS-ProxyAddresses", - - - "SPS-HireDate", - - - "SPS-DisplayOrder", - - - "SPS-ClaimID", - - - "SPS-ClaimProviderID", - - - "SPS-ClaimProviderType", - - - "SPS-LastColleagueAdded", - - - "SPS-OWAUrl", - - - "SPS-SavedAccountName", - - - "SPS-SavedSID", - - - "SPS-ResourceSID", - - - "SPS-ResourceAccountName", - - - "SPS-ObjectExists", - - - "SPS-MasterAccountName", - - - "SPS-UserPrincipalName", - - - "SPS-PersonalSiteCapabilities", - - - "SPS-O15FirstRunExperience", - - - "SPS-PersonalSiteFirstCreationTime", - - - "SPS-PersonalSiteLastCreationTime", - - - "SPS-PersonalSiteNumberOfRetries", - - - "SPS-PersonalSiteFirstCreationError", - - - "SPS-LastKeywordAdded", - - - "SPS-FeedIdentifier", - - - "SPS-PersonalSiteInstantiationState", - - - "WorkEmail", - - - "CellPhone", - - - "Fax", - - - "HomePhone", - - - "Office", - - - "SPS-Location", - - - "Assistant", - - - "SPS-PastProjects", - - - "SPS-Skills", - - - "SPS-School", - - - "SPS-Birthday", - - - "SPS-StatusNotes", - - - "SPS-Interests", - - - "SPS-HashTags", - - - "SPS-PictureTimestamp", - - - "SPS-EmailOptin", - - - "SPS-PicturePlaceholderState", - - - "SPS-PrivacyPeople", - - - "SPS-PrivacyActivity", - - - "SPS-PictureExchangeSyncState", - - - "SPS-MUILanguages", - - - "SPS-ContentLanguages", - - - "SPS-TimeZone", - - - "SPS-RegionalSettings-FollowWeb", - - - "SPS-Locale", - - - "SPS-CalendarType", - - - "SPS-AltCalendarType", - - - "SPS-AdjustHijriDays", - - - "SPS-ShowWeeks", - - - "SPS-WorkDays", - - - "SPS-WorkDayStartHour", - - - "SPS-WorkDayEndHour", - - - "SPS-Time24", - - - "SPS-FirstDayOfWeek", - - - "SPS-FirstWeekOfYear", - - - "SPS-RegionalSettings-Initialized", - - - "OfficeGraphEnabled" - - - - - - +``` ```C# static void Main(string[] args) From fc9891ed80487eedac8e32785bb8bdcfb5b799f5 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Sun, 1 Mar 2020 20:16:06 +0100 Subject: [PATCH 16/16] Update description.md --- .../description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md b/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md index 9991cf47..4a2b7fe9 100644 --- a/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md +++ b/User Profiles/Retrieve all user profiles and their properties using C# and CSOM/description.md @@ -138,7 +138,7 @@ static void Main(string[] args) Console.ReadKey(); } ``` -It would not exist without Geetanjali's inspiring article: http://social.technet.microsoft.com/wiki/contents/articles/24627.sharepoint-online-export-user-profile-properties-using-csom.aspx +It would not exist without Geetanjali's inspiring [article](http://social.technet.microsoft.com/wiki/contents/articles/24627.sharepoint-online-export-user-profile-properties-using-csom.aspx).