2

I am pulling data from a web service and want to convert the object data into a string.

I am calling using:

$URI = "http://siteURL"
$Con = New-WebServiceProxy -uri $URI -namespace WebServiceProxy -class Nlyte
$WebCon= $con.GetData('Server')
$OpenCon = [xml] $WebCon

I then query the data:

$OpenCon.Response.Server | Where-Object {$_.AssetID -eq 8186} | Select Asset_x0020_Name

The data comes back as so:

Asset_x0020_Name
----------------
SERVERNAME4001

How can I now take that object data and turn into into a string?

2 Answers 2

3

This may be used:

$OpenCon.Response.Server | Where-Object {$_.AssetID -eq 8186} | Select -ExpandProperty Asset_x0020_Name
Sign up to request clarification or add additional context in comments.

Comments

1

I decided a different approach is the simplest way to go. Instead of trying to convert the individual object values to a string I just put the entire object into a variable and call each value from there.

$Server = $a.Response.Server | Where-Object {$_.AssetID -eq 8186}
$Server.Asset_x0020_Name

1 Comment

You can also do this: ($a.Response.Server | Where-Object {$_.AssetID -eq 8186}).Asset_x0020_Name

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.