Add-PnPFieldFromXml

Adds a field to a list or as a site column based upon a CAML/XML field definition

Syntax

Add-PnPFieldFromXml
   -FieldXml <String>
                      [-List <ListPipeBind>]
                      [-Web <WebPipeBind>]
                      [-Connection <SPOnlineConnection>]

Examples

------------------EXAMPLE 1------------------

$xml = '<Field Type="Text" Name="PSCmdletTest" DisplayName="PSCmdletTest" ID="{27d81055-f208-41c9-a976-61c5473eed4a}" Group="Test" Required="FALSE" StaticName="PSCmdletTest" />'
Add-PnPFieldFromXml -FieldXml $xml

Adds a field with the specified field CAML code to the site.

------------------EXAMPLE 2------------------

$xml = '<Field Type="Text" Name="PSCmdletTest" DisplayName="PSCmdletTest" ID="{27d81055-f208-41c9-a976-61c5473eed4a}" Group="Test" Required="FALSE" StaticName="PSCmdletTest" />'
Add-PnPFieldFromXml -List "Demo List" -FieldXml $xml

Adds a field with the specified field CAML code to the list "Demo List".

Parameters

-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:SPOnlineConnection
Position:Named
Accept pipeline input:False
Accept wildcard characters:False
-FieldXml

CAML snippet containing the field definition. See http://msdn.microsoft.com/en-us/library/office/ms437580(v=office.15).aspx

Type:String
Position:0
Accept pipeline input:False
Accept wildcard characters:False
-List

The name of the list, its ID or an actual list object where this field needs to be added

Type:ListPipeBind
Position:Named
Accept pipeline input:True
Accept wildcard characters:False
-Web

This parameter allows you to optionally apply the cmdlet action to a subweb within the current web. In most situations this parameter is not required and you can connect to the subweb using Connect-PnPOnline instead. Specify the GUID, server relative url (i.e. /sites/team1) or web instance of the web to apply the command to. Omit this parameter to use the current web.

Type:WebPipeBind
Position:Named
Accept pipeline input:False
Accept wildcard characters:False

Outputs

Microsoft.SharePoint.Client.Field