Skip to content

Instantly share code, notes, and snippets.

@belotn
Last active March 31, 2020 04:09
Show Gist options
  • Save belotn/5404601 to your computer and use it in GitHub Desktop.
Save belotn/5404601 to your computer and use it in GitHub Desktop.
Script to check the Citrix XML Services
@(MyXMLServerList)| select @{N="Server";E={$_}},@{N="State";E={
$url="http://${_}:8085/scripts/wpnbr.dll"
$data = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="4.1">
<RequestAddress>
<Flags>no-load-bias</Flags>
<Name>
<AppName>MyApp</AppName>
</Name>
</RequestAddress>
</NFuseProtocol>'
[System.Net.WebRequest]$webRequest = [System.Net.WebRequest]::Create($url)
$webRequest.ServicePoint.Expect100Continue = $false
$webRequest.ContentType ="text/xml"
$webRequest.Method = "POST"
$enc = [System.Text.Encoding]::GetEncoding($codePageName)
[byte[]]$bytes = $enc.GetBytes($data)
$webRequest.ContentLength = $bytes.Length
[System.IO.Stream]$reqStream = $webRequest.GetRequestStream()
$reqStream.Write($bytes, 0, $bytes.Length)
$reqStream.Flush()
$resp = $webRequest.GetResponse()
$rs = $resp.GetResponseStream()
[System.IO.StreamReader]$sr = New-Object System.IO.StreamReader -argumentList $rs
@{$true="Success";$false="Failed"}[ $sr.ReadToEnd() -match 'TicketTag']
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment