Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Resource =
- | VM of VMResource
- | Unit of UnitResource
- type VMResource = {
- ComputerName: string
- Ip: string
- Attributes: string[]
- }
- type UnitResource = {
- UnitName: string
- Ip: string
- Username: string
- Password: string
- Attributes: string[]
- }
- Add-Type -Path "pathtomydll.dll"
- $fullRequestUrl = "http://localhost:2121/Resources/Get"
- $body = "{`"Id`":`"Test`",`"RequestedResources`":[{`"ResourceType`":{`"Case`":`"VM`"},`"Attributes`":[`"A1`",`"A2`"]},{`"ResourceType`":{`"Case`":`"Unit`"},`"Attributes`":[]}]}"
- $resp = Invoke-WebRequest $fullRequestUrl -Method Post -Body $body -ContentType "application/json"
- $obj = [ServerProtocolTypes+GetResourcesResponse]::FromJson($resp)
- $obj.GetType() # GetResourcesResponse
- Add-Type -Path "pathtomydll.dll"
- $fullRequestUrl = "http://localhost:2121/Resources/Get"
- $body = "{`"Id`":`"Test`",`"RequestedResources`":[{`"ResourceType`":{`"Case`":`"VM`"},`"Attributes`":[`"A1`",`"A2`"]},{`"ResourceType`":{`"Case`":`"Unit`"},`"Attributes`":[]}]}"
- $job = Start-Job -ScriptBlock { param($url, $reqBody) Add-Type -Path "pathtomydll.dll"; $resp = Invoke-WebRequest $url -Method Post -Body $reqBody -ContentType "application/json"; return [ServerProtocolTypes+GetResourcesResponse]::FromJson($resp) } -ArgumentList ($fullRequestUrl, $body)
- Wait-Job $job
- $obj = Receive-Job $job
- $obj.GetType() # PSObject
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement