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
Post a Comment