powershell - Ping TimeToLive - just get back number -


when this:

$pinging = get-wmiobject win32_pingstatus -filter "address='localhost'" | select-object timetolive 

i back:

@{timetolive=128} 

how number out , not @ thing around it?

i need call later in below...which erroring think becuase not looking @ number only:

switch($pinging) {     {$_ -le 128}          {return "this windows server"; break} } 

error:

cannot compare "@{timetolive=128}" "128" because objects not same type or object "@{timetolive=128}" not implement "icomparable" 

two options:

either use -expandproperty parameter in select-object

> $result = get-wmiobject win32_pingstatus -filter "address='localhost'" | select-object -expandproperty timetolive > $result 128 

or access property directly on variable assign object to

> $result = get-wmiobject win32_pingstatus -filter "address='localhost'" | select-object timetolive > $result.timetolive 128 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -