From 93c0f4ab90e5b1ef0c926381d2fcb4b6dcd19e06 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Thu, 30 Jan 2020 22:48:40 +0100 Subject: [PATCH] Update GetSingleContentTypeLoop.ps1 --- .../GetSingleContentTypeLoop.ps1 | 58 +++++++------------ 1 file changed, 21 insertions(+), 37 deletions(-) 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