Import-SPWebPart

Imports a web part to a page.

Import-SPWebPart -Manager <SPLimitedWebPartManagerPipeBind> -Zone <String> [-ZoneIndex [<Int32>]] [-DeleteExisting [<SwitchParameter>]] [-CustomReplaceText [<PropertiesPipeBind>]] -Identity <XmlDocumentPipeBind> [-WebPartTitle [<String>]] [-Publish [<SwitchParameter>]] [-ChromeType [<PartChromeType>]] [-AssignmentCollection [<SPAssignmentCollection>]]

Import-SPWebPart -Manager <SPLimitedWebPartManagerPipeBind> -Row <Int32> -Column <Int32> [-AddSpace [<SwitchParameter>]] [-CustomReplaceText [<PropertiesPipeBind>]] -Identity <XmlDocumentPipeBind> [-WebPartTitle [<String>]] [-Publish [<SwitchParameter>]] [-ChromeType [<PartChromeType>]] [-AssignmentCollection [<SPAssignmentCollection>]]

Import-SPWebPart -Manager <SPLimitedWebPartManagerPipeBind> -Zone <String> [-ZoneIndex [<Int32>]] [-DeleteExisting [<SwitchParameter>]] [-CustomReplaceText [<PropertiesPipeBind>]] [-Assembly [<String>]] [-TypeName [<String>]] [-WebPartTitle [<String>]] [-Publish [<SwitchParameter>]] [-ChromeType [<PartChromeType>]] [-AssignmentCollection [<SPAssignmentCollection>]]

Import-SPWebPart -Manager <SPLimitedWebPartManagerPipeBind> -Row <Int32> -Column <Int32> [-AddSpace [<SwitchParameter>]] [-Assembly [<String>]] [-TypeName [<String>]] [-WebPartTitle [<String>]] [-Publish [<SwitchParameter>]] [-ChromeType [<PartChromeType>]] [-AssignmentCollection [<SPAssignmentCollection>]]

Import-SPWebPart -File <SPFilePipeBind> -Zone <String> [-ZoneIndex [<Int32>]] [-DeleteExisting [<SwitchParameter>]] [-CustomReplaceText [<PropertiesPipeBind>]] -Identity <XmlDocumentPipeBind> [-WebPartTitle [<String>]] [-Publish [<SwitchParameter>]] [-ChromeType [<PartChromeType>]] [-AssignmentCollection [<SPAssignmentCollection>]]

Import-SPWebPart -File <SPFilePipeBind> -Row <Int32> -Column <Int32> [-AddSpace [<SwitchParameter>]] [-CustomReplaceText [<PropertiesPipeBind>]] -Identity <XmlDocumentPipeBind> [-WebPartTitle [<String>]] [-Publish [<SwitchParameter>]] [-ChromeType [<PartChromeType>]] [-AssignmentCollection [<SPAssignmentCollection>]]

Import-SPWebPart -File <SPFilePipeBind> -Zone <String> [-ZoneIndex [<Int32>]] [-DeleteExisting [<SwitchParameter>]] [-CustomReplaceText [<PropertiesPipeBind>]] [-Assembly [<String>]] [-TypeName [<String>]] [-WebPartTitle [<String>]] [-Publish [<SwitchParameter>]] [-ChromeType [<PartChromeType>]] [-AssignmentCollection [<SPAssignmentCollection>]]

Import-SPWebPart -File <SPFilePipeBind> -Row <Int32> -Column <Int32> [-AddSpace [<SwitchParameter>]] [-Assembly [<String>]] [-TypeName [<String>]] [-WebPartTitle [<String>]] [-Publish [<SwitchParameter>]] [-ChromeType [<PartChromeType>]] [-AssignmentCollection [<SPAssignmentCollection>]]

Parameters

1

ParameterRequiredTypeDescription
ManagerTrueSPLimitedWebPartManagerPipeBind

The URL to a web part page or an instance of an SPLimitedWebPartManager object.

ZoneTrueString

The name of the web part zone to add the web part to.

ZoneIndexFalseInt32

The index within the web part zone to add the web part to.

DeleteExistingFalseSwitchParameter

If specified, any existing web parts with the same name as the imported one will be deleted.

CustomReplaceTextFalsePropertiesPipeBind

Each key represents the name of a string to replace with the specified value.

IdentityTrueXmlDocumentPipeBind

The path to the web part file or a valid web part file in the form of an XmlDocument object.

WebPartTitleFalseString

The title to set the web part to.

PublishFalseSwitchParameter

If specified, the page will be published after importing the web part.

ChromeTypeFalsePartChromeType

The chrome settings for the web part.

AssignmentCollectionFalseSPAssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

2

ParameterRequiredTypeDescription
ManagerTrueSPLimitedWebPartManagerPipeBind

The URL to a web part page or an instance of an SPLimitedWebPartManager object.

RowTrueInt32

The zone to add the web part to.

ColumnTrueInt32

The zone index to add the web part to.

AddSpaceFalseSwitchParameter

Add some space before the web part.

CustomReplaceTextFalsePropertiesPipeBind

Each key represents the name of a string to replace with the specified value.

IdentityTrueXmlDocumentPipeBind

The path to the web part file or a valid web part file in the form of an XmlDocument object.

WebPartTitleFalseString

The title to set the web part to.

PublishFalseSwitchParameter

If specified, the page will be published after importing the web part.

ChromeTypeFalsePartChromeType

The chrome settings for the web part.

AssignmentCollectionFalseSPAssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

3

ParameterRequiredTypeDescription
ManagerTrueSPLimitedWebPartManagerPipeBind

The URL to a web part page or an instance of an SPLimitedWebPartManager object.

ZoneTrueString

The name of the web part zone to add the web part to.

ZoneIndexFalseInt32

The index within the web part zone to add the web part to.

DeleteExistingFalseSwitchParameter

If specified, any existing web parts with the same name as the imported one will be deleted.

CustomReplaceTextFalsePropertiesPipeBind

Each key represents the name of a string to replace with the specified value.

AssemblyFalseString

Specify the full name of the assembly containing the web part class to add.

TypeNameFalseString

Specify the full name of the web part class to add.

WebPartTitleFalseString

The title to set the web part to.

PublishFalseSwitchParameter

If specified, the page will be published after importing the web part.

ChromeTypeFalsePartChromeType

The chrome settings for the web part.

AssignmentCollectionFalseSPAssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

4

ParameterRequiredTypeDescription
ManagerTrueSPLimitedWebPartManagerPipeBind

The URL to a web part page or an instance of an SPLimitedWebPartManager object.

RowTrueInt32

The zone to add the web part to.

ColumnTrueInt32

The zone index to add the web part to.

AddSpaceFalseSwitchParameter

Add some space before the web part.

AssemblyFalseString

Specify the full name of the assembly containing the web part class to add.

TypeNameFalseString

Specify the full name of the web part class to add.

WebPartTitleFalseString

The title to set the web part to.

PublishFalseSwitchParameter

If specified, the page will be published after importing the web part.

ChromeTypeFalsePartChromeType

The chrome settings for the web part.

AssignmentCollectionFalseSPAssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

5

ParameterRequiredTypeDescription
FileTrueSPFilePipeBind

The URL to a web part page or an instance of an SPFile object.

ZoneTrueString

The name of the web part zone to add the web part to.

ZoneIndexFalseInt32

The index within the web part zone to add the web part to.

DeleteExistingFalseSwitchParameter

If specified, any existing web parts with the same name as the imported one will be deleted.

CustomReplaceTextFalsePropertiesPipeBind

Each key represents the name of a string to replace with the specified value.

IdentityTrueXmlDocumentPipeBind

The path to the web part file or a valid web part file in the form of an XmlDocument object.

WebPartTitleFalseString

The title to set the web part to.

PublishFalseSwitchParameter

If specified, the page will be published after importing the web part.

ChromeTypeFalsePartChromeType

The chrome settings for the web part.

AssignmentCollectionFalseSPAssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

6

ParameterRequiredTypeDescription
FileTrueSPFilePipeBind

The URL to a web part page or an instance of an SPFile object.

RowTrueInt32

The zone to add the web part to.

ColumnTrueInt32

The zone index to add the web part to.

AddSpaceFalseSwitchParameter

Add some space before the web part.

CustomReplaceTextFalsePropertiesPipeBind

Each key represents the name of a string to replace with the specified value.

IdentityTrueXmlDocumentPipeBind

The path to the web part file or a valid web part file in the form of an XmlDocument object.

WebPartTitleFalseString

The title to set the web part to.

PublishFalseSwitchParameter

If specified, the page will be published after importing the web part.

ChromeTypeFalsePartChromeType

The chrome settings for the web part.

AssignmentCollectionFalseSPAssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

7

ParameterRequiredTypeDescription
FileTrueSPFilePipeBind

The URL to a web part page or an instance of an SPFile object.

ZoneTrueString

The name of the web part zone to add the web part to.

ZoneIndexFalseInt32

The index within the web part zone to add the web part to.

DeleteExistingFalseSwitchParameter

If specified, any existing web parts with the same name as the imported one will be deleted.

CustomReplaceTextFalsePropertiesPipeBind

Each key represents the name of a string to replace with the specified value.

AssemblyFalseString

Specify the full name of the assembly containing the web part class to add.

TypeNameFalseString

Specify the full name of the web part class to add.

WebPartTitleFalseString

The title to set the web part to.

PublishFalseSwitchParameter

If specified, the page will be published after importing the web part.

ChromeTypeFalsePartChromeType

The chrome settings for the web part.

AssignmentCollectionFalseSPAssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

8

ParameterRequiredTypeDescription
FileTrueSPFilePipeBind

The URL to a web part page or an instance of an SPFile object.

RowTrueInt32

The zone to add the web part to.

ColumnTrueInt32

The zone index to add the web part to.

AddSpaceFalseSwitchParameter

Add some space before the web part.

AssemblyFalseString

Specify the full name of the assembly containing the web part class to add.

TypeNameFalseString

Specify the full name of the web part class to add.

WebPartTitleFalseString

The title to set the web part to.

PublishFalseSwitchParameter

If specified, the page will be published after importing the web part.

ChromeTypeFalsePartChromeType

The chrome settings for the web part.

AssignmentCollectionFalseSPAssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

Detailed Description

Imports a web part to a page.

Copyright 2016 Falchion Consulting, LLC

> For more information on this cmdlet and others:

> http://blog.falchionconsulting.com/

> Use of this cmdlet is at your own risk.

> Gary Lapointe assumes no liability.

Examples

------------------EXAMPLE------------------

PS C:\> Import-SPWebPart -File "http://portal/pages/default.aspx" -Identity "c:\my.webpart" -WebPartTitle "My Web part" -Zone "Left" -ZoneIndex 0 -DeleteExisting -Publish

This example adds a web part to the page http://portal/pages/default.aspx.