0

I have sharepoint farm 2013 on-premises. i wrote the following powershell script to export all the site columns properties which are inside the "Custom columns" group. now i wanted to document the following 3 properties for our current site columns ShowInEditForm, ShowInNewForm and ShowInDisplayForm:-

#Get the Source Web $sourceWeb = Get-SPWeb "http://*****/" #Create a XML File to Export Fields $xmlFile = "C:\SiteColumns.xml" New-Item $xmlFile -type file -force #Wrap Field Schema XML inside <Fields> Element Add-Content $xmlFile "`n<Fields>" #Export All Site Columns of specific Group to XML file $sourceWeb.Fields | ForEach-Object { if ($_.Group -eq "Custom Columns") { Add-Content $xmlFile $_.SchemaXml } } #Closing Wrapper Add-Content $xmlFile "</Fields>" #Dispose the web object $sourceWeb.Dispose() 

now i got the xml file generated for all the related columns, but when i checked the xml file to get the properties for the site columns, i can not view all the properties. here are two cases:-

1- I have a site column named InternalStatus, and its xml will be as follow inside the generated .xml file:-

<Field Type="Choice" DisplayName="InternalStatus" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="Dropdown" FillInChoice="FALSE" Group="Custom Columns" ID="{26c00b45-ddd2-48aa-bac7-084fedc498ea}" SourceID="{35d8bcad-3ac7-4fda-9fe9-853460a8ac3a}" StaticName="InternalStatus" Name="InternalStatus" ShowInNewForm="TRUE" Version="3" ShowInDisplayForm="FALSE"><Default>Stage1</Default> <CHOICES> <CHOICE>Stage1</CHOICE> <CHOICE>Stage2</CHOICE> <CHOICE>Stage3</CHOICE> <CHOICE>Stage4</CHOICE> <CHOICE>Stage5</CHOICE> </CHOICES> </Field> 

So seems at-least this property is missing ShowInEditForm. Now as shown in the above xml the ShowInNewForm and ShowInDisplayForm properties are there , but i am not sure why the showInEditForm is missing ?

2- I have another site column named AssignedToHidden, and its xml will be as follow inside the generated .xml file:-

<Field Type="UserMulti" DisplayName="AssignedToHidden" List="UserInfo" Required="FALSE" EnforceUniqueValues="FALSE" ShowField="ImnName" UserSelectionMode="PeopleAndGroups" UserSelectionScope="0" Group="Custom Columns" ID="{97e1ca20-1b16-40bd-9f89-6a1283374937}" SourceID="{35d8bcad-3ac7-4fda-9fe9-853460a8ac3a}" StaticName="AssignedToHidden" Name="AssignedToHidden" Mult="TRUE" Sortable="FALSE" Version="1"/>

now for this site column these 3 properties are missing ShowInEditForm, ShowInNewForm and ShowInDisplayForm.. so i am not sure why..

so can anyone adivce what is the problem inside the site columns and/or inside the above power-shell script, that some site columns are missing some properties inside the generated xml file??

1 Answer 1

0

Could you try this please : PowerShell Script to Export Site columns:

#Get the Source Web $sourceWeb = Get-SPWeb "<a class="vglnk" href="http://dev.crescent.com" rel="nofollow"><span>http</span><span>://</span><span>dev</span><span>. </span><span>crescent</span><span>.</span><span>com</span></a>" #Create a XML File to Export Fields $xmlFile = "C:\SiteColumns.xml" New-Item $xmlFile -type file -force #Wrap Field Schema XML inside <Fields> Element Add-Content $xmlFile "`n<Fields>" #Export All Site Columns of specific Group to XML file $sourceWeb.Fields | ForEach-Object { if ($_.Group -eq "Crescent Travel Request") { Add-Content $xmlFile $_.SchemaXml } } #Closing Wrapper Add-Content $xmlFile "</Fields>" #Dispose the web object $sourceWeb.Dispose() 

PowerShell Script to Import Site Columns from XML:

#Get the Target Web $TargetWeb = Get-SPWeb "<a class="vglnk" href="http://test.crescent.com" rel="nofollow"><span>http</span><span>://</span><span>test</span><span>. </span><span>crescent</span><span>.</span><span>com</span></a>" #Get XML file exported [xml]$fieldsXML = Get-Content("C:\SiteColumns.xml") #Loop Through Each Field $fieldsXML.Fields.Field | ForEach-Object { #Check if the target web has the field already! if ($TargetWeb.Fields.ContainsField( $_.Name) -Eq $false){ #Add Site column to Target Web $TargetWeb.fields.AddFieldAsXml($_.OuterXml) } } 
1
  • the script to export the site columns xml ,, is exactly the same as the one i posted inside my original question... Commented Jul 17, 2017 at 16:09

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.