< Back

Format-XML

Sat Jan 18, 2020 9:01 pm

NAME Format-XML



SYNOPSIS

Accepts a string containing valid XML tags or an XMLElement object and

outputs it as a formatted string including newline and indentation of child

nodes.





SYNTAX

Format-XML [[-xml] <Object>] [-indent <Int32>] [<CommonParameters>]





DESCRIPTION

Valid XML returned by the NSX API is a single string with no newlines or

indentation. While PowerNSX cmdlets typicallly emit an XMLElement object,

which PowerShell outputs as formatted tables or lists when outputing to host,

making normal human interaction easy, for output to file or debug stream,

format-xml converts the API returned XML to more easily read formated XML

complete with linebreaks and indentation.



As a side effect, this has the added benefit of being useable as an

additional format handler on the PowerShell pipeline, so rather than

displaying output objects using familiar table and list output formats, the

user now has the option of displaying the native XML in a human readable

format.





PARAMETERS

-xml <Object>

String object containing valid XML, or XMLElement or XMLDocument object



Required? false

Position? 2

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-indent <Int32>

Number of whitespace charaters to indent child nodes by when formatting



Required? false

Position? named

Default value 2

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



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



PS C:\\>Get-NsxTransportZone | Format-Xml



Displays the XMLElement object returned by Get-NsxTransportZone as formatted

XML.











RELATED LINKS