WAP İpuçları – #4

Kimi zaman WAP üzerinden Orchestrator runbooklarını çağırmak zorunda kalabilirsiniz. Bunun için aşağıdaki basit PowerShell scriptini automation tabında kullanmanız yeterlidir.

$myCredentials = Get-Credential(“Domain\Username“)

$mySCOWebService = “http://orc.local:81/Orchestrator2012/Orchestrator.svc/Jobs/

$xmlQuery = ‘<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes”?>

<entry xmlns:d=”http://schemas.microsoft.com/ado/2007/08/dataservices” xmlns:m=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata” xmlns=”http://www.w3.org/2005/Atom“>

<content type=”application/xml”>

<m:properties>

<d:RunbookId type=”Edm.Guid”>RunbookGUID</d:RunbookId>

</m:properties>

</content>

</entry>

#Using the .NET Framework, create a new HTTP $httpSession object

$httpSession = [System.Net.HttpWebRequest]::Create($mySCOWebService)

$httpSession.Credentials = $myCredentials

$httpSession.Accept = “application/atom+xml,application/xml”

$httpSession.Headers.Add(“Accept-Charset”, “UTF-8”)

$httpSession.ContentType = “application/atom+xml”

$httpSession.Method = “POST”

$httpConnection=new-object System.IO.StreamWriter $httpSession.GetRequestStream()

# Place our Query in the request session we have established and send it to Orchestrator

$httpConnection.Write($xmlQuery)

$httpConnection.Flush()

$httpConnection.Close()

# Now, check the response we received from Orchestrator, to ensure that the request was successful

$httpSessionResponse=$httpSession.GetResponse()

$httpResponse=$httpSessionResponse.GetResponseStream()

$xmlResponse=new-object System.IO.StreamReader $httpResponse

$results=$xmlResponse.ReadToEnd()

$xmlResponce.Close()

$httpSessionResponse.Close()

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 37 = 38