From d9c202e04985c725fd680da760a36da84e67c66d Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Thu, 30 Jan 2020 18:48:03 +0100 Subject: [PATCH] Update ModifyDisplayFormUrl-BackToDefault.ps1 --- .../ModifyDisplayFormUrl-BackToDefault.ps1 | 71 +++++++------------ 1 file changed, 27 insertions(+), 44 deletions(-) diff --git a/Content Types/Display Forms/Unable to view items- modify the DisplayFormUrl back to default one/ModifyDisplayFormUrl-BackToDefault.ps1 b/Content Types/Display Forms/Unable to view items- modify the DisplayFormUrl back to default one/ModifyDisplayFormUrl-BackToDefault.ps1 index 9c4b7f01..5c5027ac 100644 --- a/Content Types/Display Forms/Unable to view items- modify the DisplayFormUrl back to default one/ModifyDisplayFormUrl-BackToDefault.ps1 +++ b/Content Types/Display Forms/Unable to view items- modify the DisplayFormUrl back to default one/ModifyDisplayFormUrl-BackToDefault.ps1 @@ -1,53 +1,36 @@  -function Set-SPOContentType -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] +function Set-SPOContentType{ + param ( + [Parameter(Mandatory=$true,Position=1)] [string]$Username, [Parameter(Mandatory=$true,Position=2)] $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.Load($ctx.Web.Lists) - $ctx.ExecuteQuery() - - - - foreach($ll in $ctx.Web.Lists) - { - Write-Host $ll.Title -ForegroundColor Green - $ctx.Load($ll.ContentTypes) - $ctx.ExecuteQuery() - foreach($cc in $ll.ContentTypes) - { - - if($cc.Name -eq "Item") - { - $cc.DisplayFormUrl="" - - $cc.Update($false) - $ctx.ExecuteQuery() - } - - - - - - } - } - - - - $ctx.Dispose() - - - } + ) + + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.Load($ctx.Web.Lists) + $ctx.ExecuteQuery() + + foreach($ll in $ctx.Web.Lists){ + Write-Host $ll.Title -ForegroundColor Green + $ctx.Load($ll.ContentTypes) + $ctx.ExecuteQuery() + + foreach($cc in $ll.ContentTypes){ + if($cc.Name -eq "Item"){ + $cc.DisplayFormUrl="" + $cc.Update($false) + $ctx.ExecuteQuery() + } + } + } + + $ctx.Dispose() +}