Updates from: 06/02/2021 03:16:46
Service Microsoft Docs article Related commit history on GitHub Change details
Microsoft.PowerShell.Utility Select Xml (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Utility/Select-Xml.md
--- external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 06/01/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-xml?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Select-Xml
Finds text in an XML string or document.
### Xml (Default) ```
-Select-Xml [-Xml] <XmlNode[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> [-Xml] <XmlNode[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### Path ```
-Select-Xml [-Path] <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> [-Path] <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### LiteralPath ```
-Select-Xml -LiteralPath <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> -LiteralPath <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### Content ```
-Select-Xml -Content <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> -Content <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ## DESCRIPTION
-The **Select-Xml** cmdlet lets you use XPath queries to search for text in XML strings and documents.
-Enter an XPath query, and use the *Content*, *Path*, or *Xml* parameter to specify the XML to be searched.
+The `Select-Xml` cmdlet lets you use XPath queries to search for text in XML strings and documents.
+Enter an XPath query, and use the **Content**, **Path**, or **Xml** parameter to specify the XML to
+be searched.
## EXAMPLES ### Example 1: Select AliasProperty nodes
+This example gets the alias properties in the `Types.ps1xml`. For information about this file, see
+[about_Types.ps1xml](../Microsoft.PowerShell.Core/About/about_Types.ps1xml.md).
+
+The first command saves the path to the `Types.ps1xml` file in the `$Path` variable.
+
+The second command saves the XML path to the **AliasProperty** node in the `$XPath` variable.
+
+The `Select-Xml` cmdlet gets the **AliasProperty** nodes that are identified by
+the XPath statement from the `Types.ps1xml` file. The command uses a pipeline operator (`|`) to send the
+**AliasProperty** nodes to the `Select-Object` cmdlet. The **ExpandProperty** parameter expands the
+**Node** object and returns its **Name** and **ReferencedMemberName** properties.
+
+```powershell
+$Path = "$Pshome\Types.ps1xml"
+$XPath = "/Types/Type/Members/AliasProperty"
+Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node
```
-PS C:\> $Path = "$Pshome\Types.ps1xml"
-PS C:\> $XPath = "/Types/Type/Members/AliasProperty"
-PS C:\> Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node
+
+```Output
Name ReferencedMemberName ---- -------------------- Count Length
Name __Class
Namespace ModuleName ```
-This example gets the alias properties in the Types.ps1xml.
-(For information about this file, see about_Types.ps1xml.)
-
-The first command saves the path to the Types.ps1xml file in the $Path variable.
-
-The second command saves the XML path to the AliasProperty node in the $XPath variable.
-
-The third command uses the **Select-Xml** cmdlet to get the AliasProperty nodes that are identified by the XPath statement from the Types.ps1xml file.
-The command uses a pipeline operator to send the AliasProperty nodes to the Select-Object cmdlet.
-The *ExpandProperty* parameter expands the **Node** object and returns its Name and ReferencedMemberName properties.
-
-The result shows the Name and ReferencedMemberName of each alias property in the Types.ps1xml file.
-For example, there is a **Count** property that is an alias of the **Length** property.
+The result shows the Name and **ReferencedMemberName** of each alias property in the `Types.ps1xml`
+file. For example, there is a **Count** property that is an alias of the **Length** property.
### Example 2: Input an XML document
-```
-PS C:\> [xml]$Types = Get-Content $Pshome\Types.ps1xml
-PS C:\> Select-Xml -Xml $Types -XPath "//MethodName"
-```
+This example shows how to use the **XML** parameter to provide an XML document to the `Select-Xml`
+cmdlet.
-This example shows how to use the *XML* parameter to provide an XML document to the **Select-Xml** cmdlet.
+The `Get-Content` cmdlet gets the content of the `Types.ps1xml` file and saves it in the `$Types`
+variable. The `[xml]` casts the variable as an XML object.
-The first command uses the Get-Content cmdlet to get the content of the Types.ps1xml file and save it in the $Types variable.
-The \[xml\] casts the variable as an XML object.
+The `Select-Xml` cmdlet gets the **MethodName** nodes in the `Types.ps1xml` file. The command uses
+the **Xml** parameter to specify the XML content in the `$Types` variable and the **XPath**
+parameter to specify the path to the **MethodName** node.
-The second command uses the **Select-Xml** cmdlet to get the MethodName nodes in the Types.ps1xml file.
-The command uses the *Xml* parameter to specify the XML content in the $Types variable and the *XPath* parameter to specify the path to the MethodName node.
+```powershell
+[xml]$Types = Get-Content $Pshome\Types.ps1xml
+Select-Xml -Xml $Types -XPath "//MethodName"
+```
### Example 3: Search PowerShell Help files
+This example shows how to use the `Select-Xml` cmdlet to search the PowerShell XML-based cmdlet help
+files. In this example, we'll search for the cmdlet name that serves as a title for each help file
+and the path to the help file.
+
+The `$Namespace` variable contains a hash table that represents the XML namespace that is used for
+the help files.
+
+The `$Path` variable contains the path to the PowerShell help files. If there are no help files in
+this path on your computer, use the `Update-Help` cmdlet to download the help files. For more
+information about Updatable Help, see
+[about_Updatable_Help](../Microsoft.PowerShell.Core/About/about_Updatable_Help.md).
+
+The `Select-Xml` cmdlet searches the XML files for cmdlet names by finding `Command:Name` element
+anywhere in the files. The results are stored in the `$Xml` variable. `Select-Xml` returns a
+**SelectXmlInfo** object that has a **Node** property, which is a **System.Xml.XmlElement** object.
+The **Node** property has an **InnerXML** property that contains the actual XML that is retrieved.
+
+The `$Xml` variable is piped to the `Format-Table` cmdlet. The `Format-Table` command uses a
+calculated property to get the **Node.InnerXML** property of each object in the `$Xml` variable,
+trim the white space before and after the text, and display it in the table, along with the **Path**
+to the source file.
+
+```powershell
+$Namespace = @{
+ command = "http://schemas.microsoft.com/maml/dev/command/2004/10"
+ maml = "http://schemas.microsoft.com/maml/2004/10"
+ dev = "http://schemas.microsoft.com/maml/dev/2004/10"
+}
+
+$Path = "$Pshome\en-us\*dll-Help.xml"
+$Xml = Select-Xml -Path $Path -Namespace $Namespace -XPath "//command:name"
+$Xml | Format-Table @{Label="Name"; Expression= {($_.node.innerxml).trim()}}, Path -AutoSize
```
-PS C:\> $Namespace = @{command = "http://schemas.microsoft.com/maml/dev/command/2004/10"; maml = "http://schemas.microsoft.com/maml/2004/10"; dev = "http://schemas.microsoft.com/maml/dev/2004/10"}
-
-The second command saves the path to the help files in the $Path variable.If there are no help files in this path on your computer, use the Update-Help cmdlet to download the help files. For more information about Updatable Help, see about_Updatable_Help (https://go.microsoft.com/fwlink/?LinkId=235801).
-PS C:\> $Path = "$Pshome\en-us\*dll-Help.xml"
-
-The third command uses the **Select-Xml** cmdlet to search the XML for cmdlet names by finding Command:Name element anywhere in the files. It saves the results in the $Xml variable.**Select-Xml** returns a **SelectXmlInfo** object that has a Node property, which is a **System.Xml.XmlElement** object. The Node property has an InnerXML property, which contains the actual XML that is retrieved.
-PS C:\> $Xml = Select-Xml -Path $Path -Namespace $Namespace -XPath "//command:name"
-
-The fourth command sends the XML in the $Xml variable to the Format-Table cmdlet. The **Format-Table** command uses a calculated property to get the Node.InnerXML property of each object in the $Xml variable, trim the white space before and after the text, and display it in the table, along with the path to the source file.
-PS C:\> $Xml | Format-Table @{Label="Name"; Expression= {($_.node.innerxml).trim()}}, Path -AutoSize
+```Output
Name Path ---- ---- Export-Counter C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Diagnostics.dll-Help.xml
Checkpoint-Computer C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microso
... ```
-This example shows how to use the **Select-Xml** cmdlet to search the PowerShell XML-based cmdlet help files.
-In this example, we'll search for the cmdlet name that serves as a title for each help file and the path to the help file.
+### Example 4: Different ways to input XML
-The first command creates a hash table that represents the XML namespace that is used for the help files and saves it in the $Namespace variable.
+This example shows two different ways to send XML to the `Select-Xml` cmdlet.
-### Example 4: Different ways to input XML
+The first command saves a here-string that contains XML in the `$Xml` variable. For more information
+about here-strings, see
+[about_Quoting_Rules](../Microsoft.PowerShell.Core/About/about_Quoting_Rules.md).
-```
-PS C:\> $Xml = @"
+`Select-Xml` uses the **Content** parameter to specify the XML in the `$Xml` variable.
+
+The third command is the same as the second, except that tt uses a pipeline operator (`|`) to send
+the XML in the `$Xml` variable to the `Select-Xml` cmdlet.
++
+```powershell
+$Xml = @"
<?xml version="1.0" encoding="utf-8"?> <Book> <projects>
PS C:\> $Xml = @"
</Book> "@
-The second command uses the *Content* parameter of **Select-Xml** to specify the XML in the $Xml variable.
-PS C:\> Select-Xml -Content $Xml -XPath "//edition" | foreach {$_.node.InnerXML}
+Select-Xml -Content $Xml -XPath "//edition" | foreach {$_.node.InnerXML}
En.Book1.com Ge.Book1.Com Fr.Book1.com Pl.Book1.com
-The third command is equivalent to the second. It uses a pipeline operator (|) to send the XML in the $Xml variable to the **Select-Xml** cmdlet.
-PS C:\> $Xml | Select-Xml -XPath "//edition" | foreach {$_.node.InnerXML}
+$Xml | Select-Xml -XPath "//edition" | foreach {$_.node.InnerXML}
En.Book1.com Ge.Book1.Com
Fr.Book1.com
Pl.Book1.com ```
-This example shows two different ways to send XML to the **Select-Xml** cmdlet.
-
-The first command saves a here-string that contains XML in the $Xml variable.
-(For more information about here-strings, see about_Quoting_Rules.)
- ### Example 5: Use the default xmlns namespace
-```
-PS C:\> $SnippetNamespace = @{snip = "http://schemas.microsoft.com/PowerShell/Snippets"}
+This example shows how to use the `Select-Xml` cmdlet with XML documents that use the default xmlns
+namespace. The example gets the titles of Windows PowerShell ISE user-created snippet files. For
+information about snippets, see [New-IseSnippet](xref:ISE.New-IseSnippet).
-The second command uses the **Select-Xml** cmdlet to get the content of the Title element of each snippet. It uses the *Path* parameter to specify the Snippets directory and the *Namespace* parameter to specify the namespace in the $SnippetNamespace variable. The value of the *XPath* parameter is the "snip" namespace key, a colon (:), and the name of the Title element.The command uses a pipeline operator (|) to send each **Node** property that **Select-Xml** returns to the ForEach-Object cmdlet, which gets the title in the value of the **InnerXml** property of the node.
-PS C:\> Select-Xml -Path $Home\Documents\WindowsPowerShell\Snippets -Namespace $SnippetNamespace -XPath "//snip:Title" | foreach {$_.Node.Innerxml}
-```
+The `$SnippetNamespace` variable contains a hash table for the default namespace that snippet XML
+files use. The hash table value is the XMLNS schema URI in the snippet XML. The hash table key name,
+**snip**, is arbitrary. You can use any name that is not reserved, but you cannot use **xmlns**.
+
+The `Select-Xml` cmdlet gets the content of the **Title** element of each snippet. It uses the
+**Path** parameter to specify the Snippets directory and the **Namespace** parameter to specify the
+namespace in the `$SnippetNamespace` variable. The value of the **XPath** parameter is the
+`snip:Title`. The results are piped to the `ForEach-Object` cmdlet, which gets the title from the
+value of the **InnerXml** property of the node.
-This example shows how to use the **Select-Xml** cmdlet with XML documents that use the default xmlns namespace.
-The example gets the titles of Windows PowerShell ISE user-created snippet files.
-For information about snippets, see New-IseSnippet.
+```powershell
+$SnippetNamespace = @{snip = "http://schemas.microsoft.com/PowerShell/Snippets"}
-The first command creates a hash table for the default namespace that snippet XML files use and assigns it to the $SnippetNamespace variable.
-The hash table value is the XMLNS schema URI in the snippet XML.
-The hash table key name, snip, is arbitrary.
-You can use any name that is not reserved, but you cannot use xmlns.
+Select-Xml -Path $Home\Documents\WindowsPowerShell\Snippets -Namespace $SnippetNamespace -XPath "//snip:Title" |
+ ForEach-Object {$_.Node.Innerxml}
+```
## PARAMETERS ### -Content
-Specifies a string that contains the XML to search.
-You can also pipe strings to **Select-Xml**.
+Specifies a string that contains the XML to search. You can also pipe strings to `Select-Xml`.
```yaml Type: System.String[]
Accept wildcard characters: False
### -LiteralPath
-Specifies the paths and file names of the XML files to search.
-Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed.
-No characters are interpreted as wildcards.
-If the path includes escape characters, enclose it in single quotation marks.
-Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
+Specifies the paths and file names of the XML files to search. Unlike **Path**, the value of the
+**LiteralPath** parameter is used exactly as it is typed. No characters are interpreted as
+wildcards. If the path includes escape characters, enclose it in single quotation marks. Single
+quotation marks tell PowerShell not to interpret any characters as escape sequences.
```yaml Type: System.String[]
Accept wildcard characters: False
### -Namespace
-Specifies a hash table of the namespaces used in the XML.
-Use the format @{\<namespaceName\> = \<namespaceValue\>}.
+Specifies a hash table of the namespaces used in the XML. Use the
+format`@{<namespaceName> = <namespaceValue>}`.
-When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the namespace name.
-You cannot use xmlns.
-In the XPath statement, prefix each node name with the namespace name and a colon, such as //namespaceName:Node.
+When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the
+namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the
+namespace name and a colon, such as `//namespaceName:Node`.
```yaml Type: System.Collections.Hashtable
Accept wildcard characters: False
### -Path
-Specifies the path and file names of the XML files to search.
-Wildcard characters are permitted.
+Specifies the path and file names of the XML files to search. Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
Specifies one or more XML nodes.
-An XML document will be processed as a collection of XML nodes.
-If you pipe an XML document to **Select-Xml**, each document node will be searched separately as it comes through the pipeline.
+An XML document will be processed as a collection of XML nodes. If you pipe an XML document to
+`Select-Xml`, each document node will be searched separately as it comes through the pipeline.
```yaml Type: System.Xml.XmlNode[]
Accept wildcard characters: False
### -XPath
-Specifies an XPath search query.
-The query language is case-sensitive.
-This parameter is required.
+Specifies an XPath search query. The query language is case-sensitive. This parameter is required.
```yaml Type: System.String
Microsoft.PowerShell.Utility Select Xml (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Utility/Select-Xml.md
--- external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 06/01/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-xml?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Select-Xml
Finds text in an XML string or document.
### Xml (Default) ```
-Select-Xml [-Xml] <XmlNode[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> [-Xml] <XmlNode[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### Path ```
-Select-Xml [-Path] <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> [-Path] <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### LiteralPath ```
-Select-Xml -LiteralPath <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> -LiteralPath <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### Content ```
-Select-Xml -Content <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> -Content <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ## DESCRIPTION
-The **Select-Xml** cmdlet lets you use XPath queries to search for text in XML strings and documents.
-Enter an XPath query, and use the *Content*, *Path*, or *Xml* parameter to specify the XML to be searched.
+The `Select-Xml` cmdlet lets you use XPath queries to search for text in XML strings and documents.
+Enter an XPath query, and use the **Content**, **Path**, or **Xml** parameter to specify the XML to
+be searched.
## EXAMPLES ### Example 1: Select AliasProperty nodes
+This example gets the alias properties in the `Types.ps1xml`. For information about this file, see
+[about_Types.ps1xml](../Microsoft.PowerShell.Core/About/about_Types.ps1xml.md).
+
+The first command saves the path to the `Types.ps1xml` file in the `$Path` variable.
+
+The second command saves the XML path to the **AliasProperty** node in the `$XPath` variable.
+
+The `Select-Xml` cmdlet gets the **AliasProperty** nodes that are identified by
+the XPath statement from the `Types.ps1xml` file. The command uses a pipeline operator (`|`) to send the
+**AliasProperty** nodes to the `Select-Object` cmdlet. The **ExpandProperty** parameter expands the
+**Node** object and returns its **Name** and **ReferencedMemberName** properties.
+
+```powershell
+$Path = "$Pshome\Types.ps1xml"
+$XPath = "/Types/Type/Members/AliasProperty"
+Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node
```
-PS C:\> $Path = "$Pshome\Types.ps1xml"
-PS C:\> $XPath = "/Types/Type/Members/AliasProperty"
-PS C:\> Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node
+
+```Output
Name ReferencedMemberName ---- -------------------- Count Length
Name __Class
Namespace ModuleName ```
-This example gets the alias properties in the Types.ps1xml.
-(For information about this file, see about_Types.ps1xml.)
-
-The first command saves the path to the Types.ps1xml file in the $Path variable.
-
-The second command saves the XML path to the AliasProperty node in the $XPath variable.
-
-The third command uses the **Select-Xml** cmdlet to get the AliasProperty nodes that are identified by the XPath statement from the Types.ps1xml file.
-The command uses a pipeline operator to send the AliasProperty nodes to the Select-Object cmdlet.
-The *ExpandProperty* parameter expands the **Node** object and returns its Name and ReferencedMemberName properties.
-
-The result shows the Name and ReferencedMemberName of each alias property in the Types.ps1xml file.
-For example, there is a **Count** property that is an alias of the **Length** property.
+The result shows the Name and **ReferencedMemberName** of each alias property in the `Types.ps1xml`
+file. For example, there is a **Count** property that is an alias of the **Length** property.
### Example 2: Input an XML document
-```
-PS C:\> [xml]$Types = Get-Content $Pshome\Types.ps1xml
-PS C:\> Select-Xml -Xml $Types -XPath "//MethodName"
-```
+This example shows how to use the **XML** parameter to provide an XML document to the `Select-Xml`
+cmdlet.
-This example shows how to use the *XML* parameter to provide an XML document to the **Select-Xml** cmdlet.
+The `Get-Content` cmdlet gets the content of the `Types.ps1xml` file and saves it in the `$Types`
+variable. The `[xml]` casts the variable as an XML object.
-The first command uses the Get-Content cmdlet to get the content of the Types.ps1xml file and save it in the $Types variable.
-The \[xml\] casts the variable as an XML object.
+The `Select-Xml` cmdlet gets the **MethodName** nodes in the `Types.ps1xml` file. The command uses
+the **Xml** parameter to specify the XML content in the `$Types` variable and the **XPath**
+parameter to specify the path to the **MethodName** node.
-The second command uses the **Select-Xml** cmdlet to get the MethodName nodes in the Types.ps1xml file.
-The command uses the *Xml* parameter to specify the XML content in the $Types variable and the *XPath* parameter to specify the path to the MethodName node.
+```powershell
+[xml]$Types = Get-Content $Pshome\Types.ps1xml
+Select-Xml -Xml $Types -XPath "//MethodName"
+```
### Example 3: Search PowerShell Help files
+This example shows how to use the `Select-Xml` cmdlet to search the PowerShell XML-based cmdlet help
+files. In this example, we'll search for the cmdlet name that serves as a title for each help file
+and the path to the help file.
+
+The `$Namespace` variable contains a hash table that represents the XML namespace that is used for
+the help files.
+
+The `$Path` variable contains the path to the PowerShell help files. If there are no help files in
+this path on your computer, use the `Update-Help` cmdlet to download the help files. For more
+information about Updatable Help, see
+[about_Updatable_Help](../Microsoft.PowerShell.Core/About/about_Updatable_Help.md).
+
+The `Select-Xml` cmdlet searches the XML files for cmdlet names by finding `Command:Name` element
+anywhere in the files. The results are stored in the `$Xml` variable. `Select-Xml` returns a
+**SelectXmlInfo** object that has a **Node** property, which is a **System.Xml.XmlElement** object.
+The **Node** property has an **InnerXML** property that contains the actual XML that is retrieved.
+
+The `$Xml` variable is piped to the `Format-Table` cmdlet. The `Format-Table` command uses a
+calculated property to get the **Node.InnerXML** property of each object in the `$Xml` variable,
+trim the white space before and after the text, and display it in the table, along with the **Path**
+to the source file.
+
+```powershell
+$Namespace = @{
+ command = "http://schemas.microsoft.com/maml/dev/command/2004/10"
+ maml = "http://schemas.microsoft.com/maml/2004/10"
+ dev = "http://schemas.microsoft.com/maml/dev/2004/10"
+}
+
+$Path = "$Pshome\en-us\*dll-Help.xml"
+$Xml = Select-Xml -Path $Path -Namespace $Namespace -XPath "//command:name"
+$Xml | Format-Table @{Label="Name"; Expression= {($_.node.innerxml).trim()}}, Path -AutoSize
```
-PS C:\> $Namespace = @{command = "http://schemas.microsoft.com/maml/dev/command/2004/10"; maml = "http://schemas.microsoft.com/maml/2004/10"; dev = "http://schemas.microsoft.com/maml/dev/2004/10"}
-
-The second command saves the path to the help files in the $Path variable.If there are no help files in this path on your computer, use the Update-Help cmdlet to download the help files. For more information about Updatable Help, see about_Updatable_Help (https://go.microsoft.com/fwlink/?LinkId=235801).
-PS C:\> $Path = "$Pshome\en-us\*dll-Help.xml"
-
-The third command uses the **Select-Xml** cmdlet to search the XML for cmdlet names by finding Command:Name element anywhere in the files. It saves the results in the $Xml variable.**Select-Xml** returns a **SelectXmlInfo** object that has a Node property, which is a **System.Xml.XmlElement** object. The Node property has an InnerXML property, which contains the actual XML that is retrieved.
-PS C:\> $Xml = Select-Xml -Path $Path -Namespace $Namespace -XPath "//command:name"
-
-The fourth command sends the XML in the $Xml variable to the Format-Table cmdlet. The **Format-Table** command uses a calculated property to get the Node.InnerXML property of each object in the $Xml variable, trim the white space before and after the text, and display it in the table, along with the path to the source file.
-PS C:\> $Xml | Format-Table @{Label="Name"; Expression= {($_.node.innerxml).trim()}}, Path -AutoSize
+```Output
Name Path ---- ---- Export-Counter C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Diagnostics.dll-Help.xml
Checkpoint-Computer C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microso
... ```
-This example shows how to use the **Select-Xml** cmdlet to search the PowerShell XML-based cmdlet help files.
-In this example, we'll search for the cmdlet name that serves as a title for each help file and the path to the help file.
+### Example 4: Different ways to input XML
-The first command creates a hash table that represents the XML namespace that is used for the help files and saves it in the $Namespace variable.
+This example shows two different ways to send XML to the `Select-Xml` cmdlet.
-### Example 4: Different ways to input XML
+The first command saves a here-string that contains XML in the `$Xml` variable. For more information
+about here-strings, see
+[about_Quoting_Rules](../Microsoft.PowerShell.Core/About/about_Quoting_Rules.md).
-```
-PS C:\> $Xml = @"
+`Select-Xml` uses the **Content** parameter to specify the XML in the `$Xml` variable.
+
+The third command is the same as the second, except that tt uses a pipeline operator (`|`) to send
+the XML in the `$Xml` variable to the `Select-Xml` cmdlet.
++
+```powershell
+$Xml = @"
<?xml version="1.0" encoding="utf-8"?> <Book> <projects>
PS C:\> $Xml = @"
</Book> "@
-The second command uses the *Content* parameter of **Select-Xml** to specify the XML in the $Xml variable.
-PS C:\> Select-Xml -Content $Xml -XPath "//edition" | foreach {$_.node.InnerXML}
+Select-Xml -Content $Xml -XPath "//edition" | foreach {$_.node.InnerXML}
En.Book1.com Ge.Book1.Com Fr.Book1.com Pl.Book1.com
-The third command is equivalent to the second. It uses a pipeline operator (|) to send the XML in the $Xml variable to the **Select-Xml** cmdlet.
-PS C:\> $Xml | Select-Xml -XPath "//edition" | foreach {$_.node.InnerXML}
+$Xml | Select-Xml -XPath "//edition" | foreach {$_.node.InnerXML}
En.Book1.com Ge.Book1.Com
Fr.Book1.com
Pl.Book1.com ```
-This example shows two different ways to send XML to the **Select-Xml** cmdlet.
-
-The first command saves a here-string that contains XML in the $Xml variable.
-(For more information about here-strings, see about_Quoting_Rules.)
- ### Example 5: Use the default xmlns namespace
-```
-PS C:\> $SnippetNamespace = @{snip = "http://schemas.microsoft.com/PowerShell/Snippets"}
+This example shows how to use the `Select-Xml` cmdlet with XML documents that use the default xmlns
+namespace. The example gets the titles of Windows PowerShell ISE user-created snippet files. For
+information about snippets, see [New-IseSnippet](xref:ISE.New-IseSnippet).
-The second command uses the **Select-Xml** cmdlet to get the content of the Title element of each snippet. It uses the *Path* parameter to specify the Snippets directory and the *Namespace* parameter to specify the namespace in the $SnippetNamespace variable. The value of the *XPath* parameter is the "snip" namespace key, a colon (:), and the name of the Title element.The command uses a pipeline operator (|) to send each **Node** property that **Select-Xml** returns to the ForEach-Object cmdlet, which gets the title in the value of the **InnerXml** property of the node.
-PS C:\> Select-Xml -Path $Home\Documents\WindowsPowerShell\Snippets -Namespace $SnippetNamespace -XPath "//snip:Title" | foreach {$_.Node.Innerxml}
-```
+The `$SnippetNamespace` variable contains a hash table for the default namespace that snippet XML
+files use. The hash table value is the XMLNS schema URI in the snippet XML. The hash table key name,
+**snip**, is arbitrary. You can use any name that is not reserved, but you cannot use **xmlns**.
+
+The `Select-Xml` cmdlet gets the content of the **Title** element of each snippet. It uses the
+**Path** parameter to specify the Snippets directory and the **Namespace** parameter to specify the
+namespace in the `$SnippetNamespace` variable. The value of the **XPath** parameter is the
+`snip:Title`. The results are piped to the `ForEach-Object` cmdlet, which gets the title from the
+value of the **InnerXml** property of the node.
-This example shows how to use the **Select-Xml** cmdlet with XML documents that use the default xmlns namespace.
-The example gets the titles of Windows PowerShell ISE user-created snippet files.
-For information about snippets, see New-IseSnippet.
+```powershell
+$SnippetNamespace = @{snip = "http://schemas.microsoft.com/PowerShell/Snippets"}
-The first command creates a hash table for the default namespace that snippet XML files use and assigns it to the $SnippetNamespace variable.
-The hash table value is the XMLNS schema URI in the snippet XML.
-The hash table key name, snip, is arbitrary.
-You can use any name that is not reserved, but you cannot use xmlns.
+Select-Xml -Path $Home\Documents\WindowsPowerShell\Snippets -Namespace $SnippetNamespace -XPath "//snip:Title" |
+ ForEach-Object {$_.Node.Innerxml}
+```
## PARAMETERS ### -Content
-Specifies a string that contains the XML to search.
-You can also pipe strings to **Select-Xml**.
+Specifies a string that contains the XML to search. You can also pipe strings to `Select-Xml`.
```yaml Type: System.String[]
Accept wildcard characters: False
### -LiteralPath
-Specifies the paths and file names of the XML files to search.
-Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed.
-No characters are interpreted as wildcards.
-If the path includes escape characters, enclose it in single quotation marks.
-Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
+Specifies the paths and file names of the XML files to search. Unlike **Path**, the value of the
+**LiteralPath** parameter is used exactly as it is typed. No characters are interpreted as
+wildcards. If the path includes escape characters, enclose it in single quotation marks. Single
+quotation marks tell PowerShell not to interpret any characters as escape sequences.
```yaml Type: System.String[]
Accept wildcard characters: False
### -Namespace
-Specifies a hash table of the namespaces used in the XML.
-Use the format @{\<namespaceName\> = \<namespaceValue\>}.
+Specifies a hash table of the namespaces used in the XML. Use the
+format`@{<namespaceName> = <namespaceValue>}`.
-When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the namespace name.
-You cannot use xmlns.
-In the XPath statement, prefix each node name with the namespace name and a colon, such as //namespaceName:Node.
+When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the
+namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the
+namespace name and a colon, such as `//namespaceName:Node`.
```yaml Type: System.Collections.Hashtable
Accept wildcard characters: False
### -Path
-Specifies the path and file names of the XML files to search.
-Wildcard characters are permitted.
+Specifies the path and file names of the XML files to search. Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
Specifies one or more XML nodes.
-An XML document will be processed as a collection of XML nodes.
-If you pipe an XML document to **Select-Xml**, each document node will be searched separately as it comes through the pipeline.
+An XML document will be processed as a collection of XML nodes. If you pipe an XML document to
+`Select-Xml`, each document node will be searched separately as it comes through the pipeline.
```yaml Type: System.Xml.XmlNode[]
Accept wildcard characters: False
### -XPath
-Specifies an XPath search query.
-The query language is case-sensitive.
-This parameter is required.
+Specifies an XPath search query. The query language is case-sensitive. This parameter is required.
```yaml Type: System.String
Microsoft.PowerShell.Utility Select Xml (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Utility/Select-Xml.md
--- external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 06/01/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-xml?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Select-Xml
Finds text in an XML string or document.
### Xml (Default) ```
-Select-Xml [-Xml] <XmlNode[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> [-Xml] <XmlNode[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### Path ```
-Select-Xml [-Path] <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> [-Path] <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### LiteralPath ```
-Select-Xml -LiteralPath <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> -LiteralPath <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### Content ```
-Select-Xml -Content <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> -Content <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ## DESCRIPTION
-The **Select-Xml** cmdlet lets you use XPath queries to search for text in XML strings and documents.
-Enter an XPath query, and use the *Content*, *Path*, or *Xml* parameter to specify the XML to be searched.
+The `Select-Xml` cmdlet lets you use XPath queries to search for text in XML strings and documents.
+Enter an XPath query, and use the **Content**, **Path**, or **Xml** parameter to specify the XML to
+be searched.
## EXAMPLES ### Example 1: Select AliasProperty nodes
+This example gets the alias properties in the `Types.ps1xml`. For information about this file, see
+[about_Types.ps1xml](../Microsoft.PowerShell.Core/About/about_Types.ps1xml.md).
+
+The first command saves the path to the `Types.ps1xml` file in the `$Path` variable.
+
+The second command saves the XML path to the **AliasProperty** node in the `$XPath` variable.
+
+The `Select-Xml` cmdlet gets the **AliasProperty** nodes that are identified by
+the XPath statement from the `Types.ps1xml` file. The command uses a pipeline operator (`|`) to send the
+**AliasProperty** nodes to the `Select-Object` cmdlet. The **ExpandProperty** parameter expands the
+**Node** object and returns its **Name** and **ReferencedMemberName** properties.
+
+```powershell
+$Path = "$Pshome\Types.ps1xml"
+$XPath = "/Types/Type/Members/AliasProperty"
+Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node
```
-PS C:\> $Path = "$Pshome\Types.ps1xml"
-PS C:\> $XPath = "/Types/Type/Members/AliasProperty"
-PS C:\> Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node
+
+```Output
Name ReferencedMemberName ---- -------------------- Count Length
Name __Class
Namespace ModuleName ```
-This example gets the alias properties in the Types.ps1xml.
-(For information about this file, see about_Types.ps1xml.)
-
-The first command saves the path to the Types.ps1xml file in the $Path variable.
-
-The second command saves the XML path to the AliasProperty node in the $XPath variable.
-
-The third command uses the **Select-Xml** cmdlet to get the AliasProperty nodes that are identified by the XPath statement from the Types.ps1xml file.
-The command uses a pipeline operator to send the AliasProperty nodes to the Select-Object cmdlet.
-The *ExpandProperty* parameter expands the **Node** object and returns its Name and ReferencedMemberName properties.
-
-The result shows the Name and ReferencedMemberName of each alias property in the Types.ps1xml file.
-For example, there is a **Count** property that is an alias of the **Length** property.
+The result shows the Name and **ReferencedMemberName** of each alias property in the `Types.ps1xml`
+file. For example, there is a **Count** property that is an alias of the **Length** property.
### Example 2: Input an XML document
-```
-PS C:\> [xml]$Types = Get-Content $Pshome\Types.ps1xml
-PS C:\> Select-Xml -Xml $Types -XPath "//MethodName"
-```
+This example shows how to use the **XML** parameter to provide an XML document to the `Select-Xml`
+cmdlet.
-This example shows how to use the *XML* parameter to provide an XML document to the **Select-Xml** cmdlet.
+The `Get-Content` cmdlet gets the content of the `Types.ps1xml` file and saves it in the `$Types`
+variable. The `[xml]` casts the variable as an XML object.
-The first command uses the Get-Content cmdlet to get the content of the Types.ps1xml file and save it in the $Types variable.
-The \[xml\] casts the variable as an XML object.
+The `Select-Xml` cmdlet gets the **MethodName** nodes in the `Types.ps1xml` file. The command uses
+the **Xml** parameter to specify the XML content in the `$Types` variable and the **XPath**
+parameter to specify the path to the **MethodName** node.
-The second command uses the **Select-Xml** cmdlet to get the MethodName nodes in the Types.ps1xml file.
-The command uses the *Xml* parameter to specify the XML content in the $Types variable and the *XPath* parameter to specify the path to the MethodName node.
+```powershell
+[xml]$Types = Get-Content $Pshome\Types.ps1xml
+Select-Xml -Xml $Types -XPath "//MethodName"
+```
### Example 3: Search PowerShell Help files
+This example shows how to use the `Select-Xml` cmdlet to search the PowerShell XML-based cmdlet help
+files. In this example, we'll search for the cmdlet name that serves as a title for each help file
+and the path to the help file.
+
+The `$Namespace` variable contains a hash table that represents the XML namespace that is used for
+the help files.
+
+The `$Path` variable contains the path to the PowerShell help files. If there are no help files in
+this path on your computer, use the `Update-Help` cmdlet to download the help files. For more
+information about Updatable Help, see
+[about_Updatable_Help](../Microsoft.PowerShell.Core/About/about_Updatable_Help.md).
+
+The `Select-Xml` cmdlet searches the XML files for cmdlet names by finding `Command:Name` element
+anywhere in the files. The results are stored in the `$Xml` variable. `Select-Xml` returns a
+**SelectXmlInfo** object that has a **Node** property, which is a **System.Xml.XmlElement** object.
+The **Node** property has an **InnerXML** property that contains the actual XML that is retrieved.
+
+The `$Xml` variable is piped to the `Format-Table` cmdlet. The `Format-Table` command uses a
+calculated property to get the **Node.InnerXML** property of each object in the `$Xml` variable,
+trim the white space before and after the text, and display it in the table, along with the **Path**
+to the source file.
+
+```powershell
+$Namespace = @{
+ command = "http://schemas.microsoft.com/maml/dev/command/2004/10"
+ maml = "http://schemas.microsoft.com/maml/2004/10"
+ dev = "http://schemas.microsoft.com/maml/dev/2004/10"
+}
+
+$Path = "$Pshome\en-us\*dll-Help.xml"
+$Xml = Select-Xml -Path $Path -Namespace $Namespace -XPath "//command:name"
+$Xml | Format-Table @{Label="Name"; Expression= {($_.node.innerxml).trim()}}, Path -AutoSize
```
-PS C:\> $Namespace = @{command = "http://schemas.microsoft.com/maml/dev/command/2004/10"; maml = "http://schemas.microsoft.com/maml/2004/10"; dev = "http://schemas.microsoft.com/maml/dev/2004/10"}
-
-The second command saves the path to the help files in the $Path variable.If there are no help files in this path on your computer, use the Update-Help cmdlet to download the help files. For more information about Updatable Help, see about_Updatable_Help (https://go.microsoft.com/fwlink/?LinkId=235801).
-PS C:\> $Path = "$Pshome\en-us\*dll-Help.xml"
-
-The third command uses the **Select-Xml** cmdlet to search the XML for cmdlet names by finding Command:Name element anywhere in the files. It saves the results in the $Xml variable.**Select-Xml** returns a **SelectXmlInfo** object that has a Node property, which is a **System.Xml.XmlElement** object. The Node property has an InnerXML property, which contains the actual XML that is retrieved.
-PS C:\> $Xml = Select-Xml -Path $Path -Namespace $Namespace -XPath "//command:name"
-
-The fourth command sends the XML in the $Xml variable to the Format-Table cmdlet. The **Format-Table** command uses a calculated property to get the Node.InnerXML property of each object in the $Xml variable, trim the white space before and after the text, and display it in the table, along with the path to the source file.
-PS C:\> $Xml | Format-Table @{Label="Name"; Expression= {($_.node.innerxml).trim()}}, Path -AutoSize
+```Output
Name Path ---- ---- Export-Counter C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Diagnostics.dll-Help.xml
Checkpoint-Computer C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microso
... ```
-This example shows how to use the **Select-Xml** cmdlet to search the PowerShell XML-based cmdlet help files.
-In this example, we'll search for the cmdlet name that serves as a title for each help file and the path to the help file.
+### Example 4: Different ways to input XML
-The first command creates a hash table that represents the XML namespace that is used for the help files and saves it in the $Namespace variable.
+This example shows two different ways to send XML to the `Select-Xml` cmdlet.
-### Example 4: Different ways to input XML
+The first command saves a here-string that contains XML in the `$Xml` variable. For more information
+about here-strings, see
+[about_Quoting_Rules](../Microsoft.PowerShell.Core/About/about_Quoting_Rules.md).
-```
-PS C:\> $Xml = @"
+`Select-Xml` uses the **Content** parameter to specify the XML in the `$Xml` variable.
+
+The third command is the same as the second, except that tt uses a pipeline operator (`|`) to send
+the XML in the `$Xml` variable to the `Select-Xml` cmdlet.
++
+```powershell
+$Xml = @"
<?xml version="1.0" encoding="utf-8"?> <Book> <projects>
PS C:\> $Xml = @"
</Book> "@
-The second command uses the *Content* parameter of **Select-Xml** to specify the XML in the $Xml variable.
-PS C:\> Select-Xml -Content $Xml -XPath "//edition" | foreach {$_.node.InnerXML}
+Select-Xml -Content $Xml -XPath "//edition" | foreach {$_.node.InnerXML}
En.Book1.com Ge.Book1.Com Fr.Book1.com Pl.Book1.com
-The third command is equivalent to the second. It uses a pipeline operator (|) to send the XML in the $Xml variable to the **Select-Xml** cmdlet.
-PS C:\> $Xml | Select-Xml -XPath "//edition" | foreach {$_.node.InnerXML}
+$Xml | Select-Xml -XPath "//edition" | foreach {$_.node.InnerXML}
En.Book1.com Ge.Book1.Com
Fr.Book1.com
Pl.Book1.com ```
-This example shows two different ways to send XML to the **Select-Xml** cmdlet.
-
-The first command saves a here-string that contains XML in the $Xml variable.
-(For more information about here-strings, see about_Quoting_Rules.)
- ### Example 5: Use the default xmlns namespace
-```
-PS C:\> $SnippetNamespace = @{snip = "http://schemas.microsoft.com/PowerShell/Snippets"}
+This example shows how to use the `Select-Xml` cmdlet with XML documents that use the default xmlns
+namespace. The example gets the titles of Windows PowerShell ISE user-created snippet files. For
+information about snippets, see [New-IseSnippet](xref:ISE.New-IseSnippet).
-The second command uses the **Select-Xml** cmdlet to get the content of the Title element of each snippet. It uses the *Path* parameter to specify the Snippets directory and the *Namespace* parameter to specify the namespace in the $SnippetNamespace variable. The value of the *XPath* parameter is the "snip" namespace key, a colon (:), and the name of the Title element.The command uses a pipeline operator (|) to send each **Node** property that **Select-Xml** returns to the ForEach-Object cmdlet, which gets the title in the value of the **InnerXml** property of the node.
-PS C:\> Select-Xml -Path $Home\Documents\WindowsPowerShell\Snippets -Namespace $SnippetNamespace -XPath "//snip:Title" | foreach {$_.Node.Innerxml}
-```
+The `$SnippetNamespace` variable contains a hash table for the default namespace that snippet XML
+files use. The hash table value is the XMLNS schema URI in the snippet XML. The hash table key name,
+**snip**, is arbitrary. You can use any name that is not reserved, but you cannot use **xmlns**.
+
+The `Select-Xml` cmdlet gets the content of the **Title** element of each snippet. It uses the
+**Path** parameter to specify the Snippets directory and the **Namespace** parameter to specify the
+namespace in the `$SnippetNamespace` variable. The value of the **XPath** parameter is the
+`snip:Title`. The results are piped to the `ForEach-Object` cmdlet, which gets the title from the
+value of the **InnerXml** property of the node.
-This example shows how to use the **Select-Xml** cmdlet with XML documents that use the default xmlns namespace.
-The example gets the titles of Windows PowerShell ISE user-created snippet files.
-For information about snippets, see New-IseSnippet.
+```powershell
+$SnippetNamespace = @{snip = "http://schemas.microsoft.com/PowerShell/Snippets"}
-The first command creates a hash table for the default namespace that snippet XML files use and assigns it to the $SnippetNamespace variable.
-The hash table value is the XMLNS schema URI in the snippet XML.
-The hash table key name, snip, is arbitrary.
-You can use any name that is not reserved, but you cannot use xmlns.
+Select-Xml -Path $Home\Documents\WindowsPowerShell\Snippets -Namespace $SnippetNamespace -XPath "//snip:Title" |
+ ForEach-Object {$_.Node.Innerxml}
+```
## PARAMETERS ### -Content
-Specifies a string that contains the XML to search.
-You can also pipe strings to **Select-Xml**.
+Specifies a string that contains the XML to search. You can also pipe strings to `Select-Xml`.
```yaml Type: System.String[]
Accept wildcard characters: False
### -LiteralPath
-Specifies the paths and file names of the XML files to search.
-Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed.
-No characters are interpreted as wildcards.
-If the path includes escape characters, enclose it in single quotation marks.
-Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
+Specifies the paths and file names of the XML files to search. Unlike **Path**, the value of the
+**LiteralPath** parameter is used exactly as it is typed. No characters are interpreted as
+wildcards. If the path includes escape characters, enclose it in single quotation marks. Single
+quotation marks tell PowerShell not to interpret any characters as escape sequences.
```yaml Type: System.String[]
Accept wildcard characters: False
### -Namespace
-Specifies a hash table of the namespaces used in the XML.
-Use the format @{\<namespaceName\> = \<namespaceValue\>}.
+Specifies a hash table of the namespaces used in the XML. Use the
+format`@{<namespaceName> = <namespaceValue>}`.
-When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the namespace name.
-You cannot use xmlns.
-In the XPath statement, prefix each node name with the namespace name and a colon, such as //namespaceName:Node.
+When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the
+namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the
+namespace name and a colon, such as `//namespaceName:Node`.
```yaml Type: System.Collections.Hashtable
Accept wildcard characters: False
### -Path
-Specifies the path and file names of the XML files to search.
-Wildcard characters are permitted.
+Specifies the path and file names of the XML files to search. Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
Specifies one or more XML nodes.
-An XML document will be processed as a collection of XML nodes.
-If you pipe an XML document to **Select-Xml**, each document node will be searched separately as it comes through the pipeline.
+An XML document will be processed as a collection of XML nodes. If you pipe an XML document to
+`Select-Xml`, each document node will be searched separately as it comes through the pipeline.
```yaml Type: System.Xml.XmlNode[]
Accept wildcard characters: False
### -XPath
-Specifies an XPath search query.
-The query language is case-sensitive.
-This parameter is required.
+Specifies an XPath search query. The query language is case-sensitive. This parameter is required.
```yaml Type: System.String
Microsoft.PowerShell.Utility Select Xml (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Utility/Select-Xml.md
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 06/09/2017 Last updated : 06/01/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/select-xml?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Select-Xml
Finds text in an XML string or document.
### Xml (Default) ```
-Select-Xml [-Xml] <XmlNode[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> [-Xml] <XmlNode[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### Path ```
-Select-Xml [-Path] <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> [-Path] <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### LiteralPath ```
-Select-Xml -LiteralPath <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> -LiteralPath <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ### Content ```
-Select-Xml -Content <String[]> [-XPath] <String> [-Namespace <Hashtable>] [<CommonParameters>]
+Select-Xml [-XPath] <string> -Content <string[]> [-Namespace <hashtable>] [<CommonParameters>]
``` ## DESCRIPTION
-The **Select-Xml** cmdlet lets you use XPath queries to search for text in XML strings and documents.
-Enter an XPath query, and use the *Content*, *Path*, or *Xml* parameter to specify the XML to be searched.
+The `Select-Xml` cmdlet lets you use XPath queries to search for text in XML strings and documents.
+Enter an XPath query, and use the **Content**, **Path**, or **Xml** parameter to specify the XML to
+be searched.
## EXAMPLES ### Example 1: Select AliasProperty nodes
+This example gets the alias properties in the `Types.ps1xml`. For information about this file, see
+[about_Types.ps1xml](../Microsoft.PowerShell.Core/About/about_Types.ps1xml.md).
+
+The first command saves the path to the `Types.ps1xml` file in the `$Path` variable.
+
+The second command saves the XML path to the **AliasProperty** node in the `$XPath` variable.
+
+The `Select-Xml` cmdlet gets the **AliasProperty** nodes that are identified by
+the XPath statement from the `Types.ps1xml` file. The command uses a pipeline operator (`|`) to send the
+**AliasProperty** nodes to the `Select-Object` cmdlet. The **ExpandProperty** parameter expands the
+**Node** object and returns its **Name** and **ReferencedMemberName** properties.
+
+```powershell
+$Path = "$Pshome\Types.ps1xml"
+$XPath = "/Types/Type/Members/AliasProperty"
+Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node
```
-PS C:\> $Path = "$Pshome\Types.ps1xml"
-PS C:\> $XPath = "/Types/Type/Members/AliasProperty"
-PS C:\> Select-Xml -Path $Path -XPath $Xpath | Select-Object -ExpandProperty Node
+
+```Output
Name ReferencedMemberName ---- -------------------- Count Length
Name __Class
Namespace ModuleName ```
-This example gets the alias properties in the Types.ps1xml.
-(For information about this file, see about_Types.ps1xml.)
-
-The first command saves the path to the Types.ps1xml file in the $Path variable.
-
-The second command saves the XML path to the AliasProperty node in the $XPath variable.
-
-The third command uses the **Select-Xml** cmdlet to get the AliasProperty nodes that are identified by the XPath statement from the Types.ps1xml file.
-The command uses a pipeline operator to send the AliasProperty nodes to the Select-Object cmdlet.
-The *ExpandProperty* parameter expands the **Node** object and returns its Name and ReferencedMemberName properties.
-
-The result shows the Name and ReferencedMemberName of each alias property in the Types.ps1xml file.
-For example, there is a **Count** property that is an alias of the **Length** property.
+The result shows the Name and **ReferencedMemberName** of each alias property in the `Types.ps1xml`
+file. For example, there is a **Count** property that is an alias of the **Length** property.
### Example 2: Input an XML document
-```
-PS C:\> [xml]$Types = Get-Content $Pshome\Types.ps1xml
-PS C:\> Select-Xml -Xml $Types -XPath "//MethodName"
-```
+This example shows how to use the **XML** parameter to provide an XML document to the `Select-Xml`
+cmdlet.
-This example shows how to use the *XML* parameter to provide an XML document to the **Select-Xml** cmdlet.
+The `Get-Content` cmdlet gets the content of the `Types.ps1xml` file and saves it in the `$Types`
+variable. The `[xml]` casts the variable as an XML object.
-The first command uses the Get-Content cmdlet to get the content of the Types.ps1xml file and save it in the $Types variable.
-The \[xml\] casts the variable as an XML object.
+The `Select-Xml` cmdlet gets the **MethodName** nodes in the `Types.ps1xml` file. The command uses
+the **Xml** parameter to specify the XML content in the `$Types` variable and the **XPath**
+parameter to specify the path to the **MethodName** node.
-The second command uses the **Select-Xml** cmdlet to get the MethodName nodes in the Types.ps1xml file.
-The command uses the *Xml* parameter to specify the XML content in the $Types variable and the *XPath* parameter to specify the path to the MethodName node.
+```powershell
+[xml]$Types = Get-Content $Pshome\Types.ps1xml
+Select-Xml -Xml $Types -XPath "//MethodName"
+```
### Example 3: Search PowerShell Help files
+This example shows how to use the `Select-Xml` cmdlet to search the PowerShell XML-based cmdlet help
+files. In this example, we'll search for the cmdlet name that serves as a title for each help file
+and the path to the help file.
+
+The `$Namespace` variable contains a hash table that represents the XML namespace that is used for
+the help files.
+
+The `$Path` variable contains the path to the PowerShell help files. If there are no help files in
+this path on your computer, use the `Update-Help` cmdlet to download the help files. For more
+information about Updatable Help, see
+[about_Updatable_Help](../Microsoft.PowerShell.Core/About/about_Updatable_Help.md).
+
+The `Select-Xml` cmdlet searches the XML files for cmdlet names by finding `Command:Name` element
+anywhere in the files. The results are stored in the `$Xml` variable. `Select-Xml` returns a
+**SelectXmlInfo** object that has a **Node** property, which is a **System.Xml.XmlElement** object.
+The **Node** property has an **InnerXML** property that contains the actual XML that is retrieved.
+
+The `$Xml` variable is piped to the `Format-Table` cmdlet. The `Format-Table` command uses a
+calculated property to get the **Node.InnerXML** property of each object in the `$Xml` variable,
+trim the white space before and after the text, and display it in the table, along with the **Path**
+to the source file.
+
+```powershell
+$Namespace = @{
+ command = "http://schemas.microsoft.com/maml/dev/command/2004/10"
+ maml = "http://schemas.microsoft.com/maml/2004/10"
+ dev = "http://schemas.microsoft.com/maml/dev/2004/10"
+}
+
+$Path = "$Pshome\en-us\*dll-Help.xml"
+$Xml = Select-Xml -Path $Path -Namespace $Namespace -XPath "//command:name"
+$Xml | Format-Table @{Label="Name"; Expression= {($_.node.innerxml).trim()}}, Path -AutoSize
```
-PS C:\> $Namespace = @{command = "http://schemas.microsoft.com/maml/dev/command/2004/10"; maml = "http://schemas.microsoft.com/maml/2004/10"; dev = "http://schemas.microsoft.com/maml/dev/2004/10"}
-
-The second command saves the path to the help files in the $Path variable.If there are no help files in this path on your computer, use the Update-Help cmdlet to download the help files. For more information about Updatable Help, see about_Updatable_Help (https://go.microsoft.com/fwlink/?LinkId=235801).
-PS C:\> $Path = "$Pshome\en-us\*dll-Help.xml"
-
-The third command uses the **Select-Xml** cmdlet to search the XML for cmdlet names by finding Command:Name element anywhere in the files. It saves the results in the $Xml variable.**Select-Xml** returns a **SelectXmlInfo** object that has a Node property, which is a **System.Xml.XmlElement** object. The Node property has an InnerXML property, which contains the actual XML that is retrieved.
-PS C:\> $Xml = Select-Xml -Path $Path -Namespace $Namespace -XPath "//command:name"
-
-The fourth command sends the XML in the $Xml variable to the Format-Table cmdlet. The **Format-Table** command uses a calculated property to get the Node.InnerXML property of each object in the $Xml variable, trim the white space before and after the text, and display it in the table, along with the path to the source file.
-PS C:\> $Xml | Format-Table @{Label="Name"; Expression= {($_.node.innerxml).trim()}}, Path -AutoSize
+```Output
Name Path ---- ---- Export-Counter C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microsoft.PowerShell.Commands.Diagnostics.dll-Help.xml
Checkpoint-Computer C:\Windows\system32\WindowsPowerShell\v1.0\en-us\Microso
... ```
-This example shows how to use the **Select-Xml** cmdlet to search the PowerShell XML-based cmdlet help files.
-In this example, we'll search for the cmdlet name that serves as a title for each help file and the path to the help file.
+### Example 4: Different ways to input XML
-The first command creates a hash table that represents the XML namespace that is used for the help files and saves it in the $Namespace variable.
+This example shows two different ways to send XML to the `Select-Xml` cmdlet.
-### Example 4: Different ways to input XML
+The first command saves a here-string that contains XML in the `$Xml` variable. For more information
+about here-strings, see
+[about_Quoting_Rules](../Microsoft.PowerShell.Core/About/about_Quoting_Rules.md).
-```
-PS C:\> $Xml = @"
+`Select-Xml` uses the **Content** parameter to specify the XML in the `$Xml` variable.
+
+The third command is the same as the second, except that tt uses a pipeline operator (`|`) to send
+the XML in the `$Xml` variable to the `Select-Xml` cmdlet.
++
+```powershell
+$Xml = @"
<?xml version="1.0" encoding="utf-8"?> <Book> <projects>
PS C:\> $Xml = @"
</Book> "@
-The second command uses the *Content* parameter of **Select-Xml** to specify the XML in the $Xml variable.
-PS C:\> Select-Xml -Content $Xml -XPath "//edition" | foreach {$_.node.InnerXML}
+Select-Xml -Content $Xml -XPath "//edition" | foreach {$_.node.InnerXML}
En.Book1.com Ge.Book1.Com Fr.Book1.com Pl.Book1.com
-The third command is equivalent to the second. It uses a pipeline operator (|) to send the XML in the $Xml variable to the **Select-Xml** cmdlet.
-PS C:\> $Xml | Select-Xml -XPath "//edition" | foreach {$_.node.InnerXML}
+$Xml | Select-Xml -XPath "//edition" | foreach {$_.node.InnerXML}
En.Book1.com Ge.Book1.Com
Fr.Book1.com
Pl.Book1.com ```
-This example shows two different ways to send XML to the **Select-Xml** cmdlet.
-
-The first command saves a here-string that contains XML in the $Xml variable.
-(For more information about here-strings, see about_Quoting_Rules.)
- ### Example 5: Use the default xmlns namespace
-```
-PS C:\> $SnippetNamespace = @{snip = "http://schemas.microsoft.com/PowerShell/Snippets"}
+This example shows how to use the `Select-Xml` cmdlet with XML documents that use the default xmlns
+namespace. The example gets the titles of Windows PowerShell ISE user-created snippet files. For
+information about snippets, see [New-IseSnippet](xref:ISE.New-IseSnippet).
-The second command uses the **Select-Xml** cmdlet to get the content of the Title element of each snippet. It uses the *Path* parameter to specify the Snippets directory and the *Namespace* parameter to specify the namespace in the $SnippetNamespace variable. The value of the *XPath* parameter is the "snip" namespace key, a colon (:), and the name of the Title element.The command uses a pipeline operator (|) to send each **Node** property that **Select-Xml** returns to the ForEach-Object cmdlet, which gets the title in the value of the **InnerXml** property of the node.
-PS C:\> Select-Xml -Path $Home\Documents\WindowsPowerShell\Snippets -Namespace $SnippetNamespace -XPath "//snip:Title" | foreach {$_.Node.Innerxml}
-```
+The `$SnippetNamespace` variable contains a hash table for the default namespace that snippet XML
+files use. The hash table value is the XMLNS schema URI in the snippet XML. The hash table key name,
+**snip**, is arbitrary. You can use any name that is not reserved, but you cannot use **xmlns**.
+
+The `Select-Xml` cmdlet gets the content of the **Title** element of each snippet. It uses the
+**Path** parameter to specify the Snippets directory and the **Namespace** parameter to specify the
+namespace in the `$SnippetNamespace` variable. The value of the **XPath** parameter is the
+`snip:Title`. The results are piped to the `ForEach-Object` cmdlet, which gets the title from the
+value of the **InnerXml** property of the node.
-This example shows how to use the **Select-Xml** cmdlet with XML documents that use the default xmlns namespace.
-The example gets the titles of Windows PowerShell ISE user-created snippet files.
-For information about snippets, see New-IseSnippet.
+```powershell
+$SnippetNamespace = @{snip = "http://schemas.microsoft.com/PowerShell/Snippets"}
-The first command creates a hash table for the default namespace that snippet XML files use and assigns it to the $SnippetNamespace variable.
-The hash table value is the XMLNS schema URI in the snippet XML.
-The hash table key name, snip, is arbitrary.
-You can use any name that is not reserved, but you cannot use xmlns.
+Select-Xml -Path $Home\Documents\WindowsPowerShell\Snippets -Namespace $SnippetNamespace -XPath "//snip:Title" |
+ ForEach-Object {$_.Node.Innerxml}
+```
## PARAMETERS ### -Content
-Specifies a string that contains the XML to search.
-You can also pipe strings to **Select-Xml**.
+Specifies a string that contains the XML to search. You can also pipe strings to `Select-Xml`.
```yaml Type: System.String[]
Accept wildcard characters: False
### -LiteralPath
-Specifies the paths and file names of the XML files to search.
-Unlike *Path*, the value of the *LiteralPath* parameter is used exactly as it is typed.
-No characters are interpreted as wildcards.
-If the path includes escape characters, enclose it in single quotation marks.
-Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
+Specifies the paths and file names of the XML files to search. Unlike **Path**, the value of the
+**LiteralPath** parameter is used exactly as it is typed. No characters are interpreted as
+wildcards. If the path includes escape characters, enclose it in single quotation marks. Single
+quotation marks tell PowerShell not to interpret any characters as escape sequences.
```yaml Type: System.String[]
Accept wildcard characters: False
### -Namespace
-Specifies a hash table of the namespaces used in the XML.
-Use the format @{\<namespaceName\> = \<namespaceValue\>}.
+Specifies a hash table of the namespaces used in the XML. Use the
+format`@{<namespaceName> = <namespaceValue>}`.
-When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the namespace name.
-You cannot use xmlns.
-In the XPath statement, prefix each node name with the namespace name and a colon, such as //namespaceName:Node.
+When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the
+namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the
+namespace name and a colon, such as `//namespaceName:Node`.
```yaml Type: System.Collections.Hashtable
Accept wildcard characters: False
### -Path
-Specifies the path and file names of the XML files to search.
-Wildcard characters are permitted.
+Specifies the path and file names of the XML files to search. Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
Specifies one or more XML nodes.
-An XML document will be processed as a collection of XML nodes.
-If you pipe an XML document to **Select-Xml**, each document node will be searched separately as it comes through the pipeline.
+An XML document will be processed as a collection of XML nodes. If you pipe an XML document to
+`Select-Xml`, each document node will be searched separately as it comes through the pipeline.
```yaml Type: System.Xml.XmlNode[]
Accept wildcard characters: False
### -XPath
-Specifies an XPath search query.
-The query language is case-sensitive.
-This parameter is required.
+Specifies an XPath search query. The query language is case-sensitive. This parameter is required.
```yaml Type: System.String
community 2021 Updates https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/community/2021-updates.md
--- Title: What's New in PowerShell Docs for 2021
+ Title: What's New in PowerShell-Docs for 2021
description: List of changes to the PowerShell documentation for 2021 Previously updated : 05/03/2021 Last updated : 06/01/2021 --- # What's new in PowerShell Docs for 2021
contributions from the community.
Help us make the documentation better for you. Read the [Contributor's Guide][contrib] to learn how to get started.
+## 2021-May
+
+New Content
+
+- Migrated two articles from the Windows Server content to the PowerShell docset
+ - [PowerShell scripting performance considerations](/powershell/scripting/dev-cross-plat/performance/script-authoring-considerations)
+ - [PowerShell module authoring considerations](/powershell/scripting/dev-cross-plat/performance/module-auth)
+- Added [PowerShell Language Specification 3.0](/powershell/scripting/lang-spec/chapter-01)
+ - The specification document is available from the Microsoft Download
+ Center as a [Microsoft Word document](https://www.microsoft.com/download/details.aspx?id=36389).
+- Updated content for PowerShell 7.2-Preview6 release
+- Moved Samples under the Learn node in the Table of Contents
+
+### Top Community Contributors
+
+GitHub stats
+
+- 53 PRs merged (6 from Community)
+- 37 issues opened (35 from Community)
+- 39 issues closed (36 Community issues closed)
+
+The following people have contributed to PowerShell docs by submitting pull requests or filing
+issues. Thank you!
+
+| GitHub Id | PRs merged | Issues opened |
+| ---------------- | :--------: | :-----------: |
+| kvprasoon | 2 | |
+| jErprog | 1 | |
+| aamnah | 1 | |
+| BetaLyte | 1 | |
+| TheNCuber | 1 | |
+| trollyanov | | 6 |
+| Tarjei-stavanger | | 3 |
+| aungminko93750 | | 3 |
+| SetTrend | | 2 |
+| cdichter | | 2 |
+| reuvygroovy | | 2 |
+ ## 2021-April New Content -- Published new Learn content [Write your first PowerShell code](https://docs.microsoft.com/learn/modules/powershell-write-first/)
+- Published new Learn content [Write your first PowerShell code](/learn/modules/powershell-write-first/)
- Updated docs for PowerShell 7.2-preview.5 - Updated metadata on ~3300 articles in the Windows module documentation - Preparing for Windows Server 2022 release and fixing updateable help
community Hall Of Fame https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/community/hall-of-fame.md
Pull Requests help us fix those issues and make the documentation better for eve
| Docs PRs Merged | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | Grand Total | | --------------- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ----------: |
-| Community | 3 | 194 | 446 | 467 | 321 | 162 | 36 | 1629 |
+| Community | 3 | 194 | 446 | 467 | 321 | 162 | 42 | 1635 |
| matt9ucci | | | 157 | 80 | 30 | 1 | 2 | 270 | | nschonni | | | | 14 | 138 | 10 | | 162 | | kiazhi | | 25 | 78 | 12 | | | | 115 |
Pull Requests help us fix those issues and make the documentation better for eve
| Dan1el42 | | 20 | | | | | | 20 | | NReilingh | | 2 | | 13 | 3 | | | 18 | | it-praktyk | | | | 16 | 1 | | | 17 |
+| vors | | 15 | 1 | | | | | 16 |
+| kvprasoon | | 2 | 1 | 7 | 2 | 2 | 2 | 16 |
| markekraus | | | 11 | 5 | | | | 16 |
-| kvprasoon | | 2 | 1 | 7 | 2 | 2 | | 14 |
-| purdo17 | | | | 13 | | | | 13 |
| skycommand | | | 1 | 3 | 3 | 6 | | 13 |
+| purdo17 | | | | 13 | | | | 13 |
| k-takai | | | | 5 | 1 | 7 | | 13 | | PlagueHO | | 10 | | | 1 | | | 11 | | exchange12rocks | | | 7 | 3 | | | 1 | 11 |
GitHub issues help us identify errors and gaps in our documentation.
| Docs Issues Opened | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | Grand Total | | ------------------ | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ----------: |
-| Community | 3 | 54 | 95 | 213 | 575 | 584 | 145 | 1669 |
+| Community | 3 | 54 | 95 | 213 | 575 | 584 | 178 | 1702 |
| mklement0 | | | 19 | 60 | 56 | 61 | 13 | 209 |
+| jszabo98 | | | | 2 | 15 | 6 | 1 | 24 |
| iSazonov | | | 1 | 4 | 10 | 8 | 1 | 24 |
-| jszabo98 | | | | 2 | 15 | 6 | | 23 |
| juvtib | | | | | | 15 | 6 | 21 | | doctordns | | | 5 | 3 | 5 | 7 | | 20 | | KirkMunro | | | | 7 | 7 | 1 | | 15 |