From 7879b21438e6fd83e369c01f7fa5bec63c826472 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 31 Jan 2020 22:22:32 +0100 Subject: [PATCH] Update GetSingleContentTypeLoopGroup.ps1 --- .../GetSingleContentTypeLoopGroup.ps1 | 64 +++++++------------ 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/Content Types/Get/Get content types belonging to a group/GetSingleContentTypeLoopGroup.ps1 b/Content Types/Get/Get content types belonging to a group/GetSingleContentTypeLoopGroup.ps1 index cce6abe6..858b76fe 100644 --- a/Content Types/Get/Get content types belonging to a group/GetSingleContentTypeLoopGroup.ps1 +++ b/Content Types/Get/Get content types belonging to a group/GetSingleContentTypeLoopGroup.ps1 @@ -1,49 +1,33 @@  -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, -[Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string]$GroupName - ) - - $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.Group -eq $GroupName) - { - 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.Group -eq $GroupName){ + Write-Host $cc.Name + } + } +} # Paths to SDK. Please verify location on your computer. @@ -58,4 +42,4 @@ $GroupName="Business Intelligence" -Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -GroupName $GroupName \ No newline at end of file +Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -GroupName $GroupName