field
2 TopicsCopying Content Type and Fields from one Hub Site to another crashes Document Library
Hi, I have 2 Hub Sites on SharePoint Online (Site A and Site B). Site A has a Content Type called "Finance Document" with some fields. I follow the instruction on this page to create new Content Type, Fields and link the Fields to my Content Type using the field definition from Site A. https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/create-sharepoint-content-types-by-using-csom After that, my document library becomes inaccessible (screenshot), however I can still access its setting page or access it via CSOM code. Any idea why it happens ?853Views0likes0CommentsSharePoint Online: PowerShell script to Remove a defined column accross the Site collection
Our large SharePoint Online Site collection used for Intranet Corporate Portal based on Publishing site, we have a large number of subsites into. We had to remove a field place into the page library of all those subsites. The following script was built to do that removal. You can adapt it as you want for your own requirements. [string]$username = "Admin@yourtenant.onmicrosoft.com" [string]$PwdTXTPath = "C:\SECUREDPWD\ExportedPWD-$($username).txt" $secureStringPwd = ConvertTo-SecureString -string (Get-Content $PwdTXTPath) $adminCreds = New-Object System.Management.Automation.PSCredential $username, $secureStringPwd [string]$RootSiteToCheck = "https://yourtenant.sharepoint.com/sites/YourSiteCollection" [string]$SPListToCheck = "Pages" [string]$SPFieldInternalNameToCheck = "PublishedDate" function Load-DLLandAssemblies { [string]$defaultDLLPath = "" # Load assemblies to PowerShell session $defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) $defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) $defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) } function Check-And-Fix-Field-In-SPList ([Microsoft.SharePoint.Client.ClientContext]$Context, [Microsoft.SharePoint.Client.Web]$CurrentWeb) { $MyCurrentListTocheck = $CurrentWeb.Lists.GetByTitle($SPListToCheck) $AllSPListCT = $MyCurrentListTocheck.ContentTypes $Context.Load($MyCurrentListTocheck) $Context.Load($AllSPListCT) $Context.ExecuteQuery() Write-Host " ===>>> SubSite to check:", $CurrentWeb.Title, "- URL:", $CurrentWeb.Url -ForegroundColor Green Write-Host " ===>>> List to check:", $MyCurrentListTocheck.Title -ForegroundColor Green foreach($MySpListCT in $AllSPListCT) { Write-Host " -->> Content Type Name:", $MySpListCT.Name Write-Host " -->> Content Type ID:", $MySpListCT.id $Myfields = $MySpListCT.Fields $Context.Load($Myfields) $Context.ExecuteQuery() $MyfieldToCheck = ($Myfields | where {$_.InternalName -eq $SPFieldInternalNameToCheck}) if($MyfieldToCheck -ne $null) { Write-Host " ---------------------------------------------- " -ForegroundColor Yellow Write-Host " >>>> Field Name:", $MyfieldToCheck.Title -ForegroundColor Yellow Write-Host " >>>> Field InternalName:", $MyfieldToCheck.InternalName, "- Field ID:", $MyfieldToCheck.id -ForegroundColor Yellow Write-Host " >>>> Field Required:", $MyfieldToCheck.Required -ForegroundColor Yellow Write-Host " ---------------------------------------------- " -ForegroundColor Yellow $MyfieldToCheck.DeleteObject(); $MySpListCT.Update($false); $Context.Load($MySpListCT); $Context.ExecuteQuery() Write-Host " >>>> Field Deleted !!!!" -ForegroundColor Red } } } function Get-SPOSubWebs { Param( [Microsoft.SharePoint.Client.ClientContext]$Context, [Microsoft.SharePoint.Client.Web]$RootWeb ) $Webs = $RootWeb.Webs $Context.Load($Webs) $Context.ExecuteQuery() ForEach ($sWeb in $Webs) { Write-host " ====>> SubSite:", $sWeb.URL -ForegroundColor red Check-And-Fix-Field-In-SPList $Context $sWeb Get-SPOSubWebs -RootWeb $sWeb -Context $Context } } cls Write-Host " ---------------------------------------------- " Load-DLLandAssemblies Write-Host " ---------------------------------------------- " Write-host "===================================================================================================" -ForegroundColor Green $mySitectx = New-Object Microsoft.SharePoint.Client.ClientContext($RootSiteToCheck) $mySitectx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($adminCreds.UserName, $adminCreds.Password) $mySitectx.RequestTimeout = 1000000 # milliseconds $myCurrentWeb = $mySitectx.Web $mySitectx.Load($myCurrentWeb) $mySitectx.ExecuteQuery() Write-Host " " Write-Host " ---------------------------------------------------------" Write-Host " >>>> # Server Version:" $mySitectx.ServerVersion " # <<<<<<" -ForegroundColor Green Write-Host " ---------------------------------------------------------" Write-Host " " Write-host "===================================================================================================" Write-host " -->> RootSite:", $myCurrentWeb.URL -ForegroundColor green Write-host "===================================================================================================" Check-And-Fix-Field-In-SPList $mySitectx $myCurrentWeb Get-SPOSubWebs $mySitectx $myCurrentWeb Write-host "===================================================================================================" Fabrice Romelard French version: http://blogs.developpeur.org/fabrice69/archive/2018/11/27/sharepoint-online-script-powershell-pour-supprimer-une-colonne-dans-tous-les-sites-d-une-collection.aspx Source used: https://social.technet.microsoft.com/wiki/contents/articles/31151.sharepoint-online-content-types-in-powershell-get.aspx https://social.technet.microsoft.com/wiki/contents/articles/31444.sharepoint-online-content-types-in-powershell-edit.aspx https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.contenttype.aspx https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.field.aspx https://thesharedcontext.wordpress.com/2014/12/11/removing-a-site-column-from-a-content-type-using-the-client-object-model/ http://www.sharepointdiary.com/2016/08/sharepoint-online-rename-column-using-powershell.html1.9KViews0likes0Comments