PackageDeployment Module Help

Package Deployment Module

Set-XmlNode Cmdlet

Version 4.0.0.5

Set-XmlNode

Synopsis

Modify XML file

Syntax

Set-XmlNode [-NodeType] <String> [-Action] <String> [-Path] <String> [-ContinueOnError] [-Wow64] [[-XPathQuery] <String>] [[-Index] <Int32>] [[-Attribute] <String>] [[-HintPath] <String>] [[-Content] <String[]>] [[-Context] <String>] [<CommonParameters>]

Description

Use this command to add new entries to an XML file or to change or delete existing entries. The changed file is only stored if the XML file is well-formed, the schema is not validated, however.

Parameters

-Action <String>

The following actions are available: Add, Change, Delete.
Action Change: This action does not apply to the type Element. If attributes or contents need to be changed but are not available, they are added automatically.

Required

True

Position

1

Accepts pipeline input

False

-Attribute <String>

This entry provides the name of the queried attribute if you select Entry type = Attribute. You are allowed to use the * wild card.

Required

False

Position

5

Accepts pipeline input

False

-Content <String[]>

Specifies the XML contents (for the actions Add and Change) that will be replaced and/or added to the XML file. Click ... to open an editor where you can enter complex or multiple lined contents. You can use variables.

Required

False

Position

7

Accepts pipeline input

False

-Context <String>

User: Execution under user account; logging in HKEY_CURRENT_USER, i.e. for the user.
UserPerService: User-related command, execution in Service context.
Computer: Execution under user account; logging in HKEY_CURRENT_MACHINE, i.e. for the computer.
ComputerPerService: Execution in service context; logging in HKEY_LOCAL_MACHINE, i.e. for the computer.

Required

False

Position

8

Accepts pipeline input

False

-ContinueOnError <SwitchParameter>

Continues script execution in spite of errors in the respective command

Required

False

Position

Named

Accepts pipeline input

False

-HintPath <String>

#TODO#

Required

False

Position

6

Accepts pipeline input

False

-Index <Int32>

The index determines which element is to be edited if the query finds several matches in the XML file. The following options are available: All (default), First match, Last match, Specific index. Specify the location of the specific element on the match list, for example 3 for the third incidence in the XML file. If necessary, use the Read-XmlNode command to define the respective index value.

Required

False

Position

4

Accepts pipeline input

False

-NodeType <String>

Select the type of the part of the XML file you want to edit:
Element - Basic structural unit of an XML file that usually has a tag at the beginning and the end.
If you want to delete an element, the element that is identified in the XPath query is deleted with all subelements and contents. If you want to add a new element, the contents of the field Entry value is added to the specified element of the XML file. If you have not specified an XML query, the contents of the field Entry value is used to replace the complete contents of the XML file. This is how you can create a new XML file.
Attribute of an element
If you want to delete an attribute, the attribute is deleted completely from the element identified in the XPath query. If you want to add or change an attribute, the attribute is added to the identified element. The command automatically detects whether the attribute already exists and acts accordingly.
Contents of an element - This refers to the text content of an element between the start and end tag (without subelements)
If you want to delete the contents of an element, the contents are deleted completely from the element identified in the XPath query. If you want to add or change the contents of an element, the contents are added to the identified element or they replace the existing contents. Subelements are not treated as contents and therefore they are ignored.

Required

True

Position

0

Accepts pipeline input

False

-Path <String>

Path and name of the XML file you want to edit. If not specified, the extension .XML is used automatically.

Required

True

Position

2

Accepts pipeline input

False

-Wow64 <SwitchParameter>

By default, the PackageDeployment module assumes to run in a 64-bit PowerShell process on 64-bit systems, and therefore defaults to the 64-bit application location (if different from the 32-bit application location) for file and registry accesses. If you want to access the 32-bit counterparts (in the file system %WinDir%\SysWOW64 instead of %WinDir%\System32, in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node instead of HKEY_LOCAL_MACHINE\SOFTWARE), use the -Wow64 switch.

Required

False

Position

Named

Accepts pipeline input

False

-XPathQuery <String>

Used to identify the editable part of the XML file with the help of the XPath syntax.
XPath query example: //Sample/node1/node2/Object[@type="STRING"]. In this example, the system queries the Object element in Sample/node1/node2 to which the type="STRING" applies. In most cases, the system finds several elements that match the query; therefore, specify an Index in addition.

Required

False

Position

3

Accepts pipeline input

False

<CommonParameters>

For more information about common parameters, type "Get-Help about_CommonParameters".