-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All PRTG - Output Function #3
Labels
Projects
Comments
You could use something like this: Function Write-XmlToScreen ([xml]$XML)
{
$StringWriter = New-Object System.IO.StringWriter;
$XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
$XmlWriter.Formatting = "indented";
$xml.WriteTo($XmlWriter);
$XmlWriter.Flush();
$StringWriter.Flush();
Write-Output $StringWriter.ToString();
} Using this you can just build your XML like this: $XML = "<prtg>"
$XML += "<result><channel>Channel1</channel><value>1</value></result>"
$XML += "</prtg>" Running the function against $XML will return properly formatted XML data: Write-XmlToScreen $XML Output: <prtg>
<result>
<channel>Channel1</channel>
<value>1</value>
</result>
</prtg> As you can imagine you can just add to $XML throughout the script and send it all to PRTG at the end. |
That's a very good start. But I thought of a function that has an array or special object as input and then the PRTG compliant XML is created as a return. |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create a function to create XML Output for PRTG.
The text was updated successfully, but these errors were encountered: