Tuesday, 15 May 2012

Powershell syntax help needed -



Powershell syntax help needed -

i have powershell command automation purposes in our monitoring system, i'm trying write in 1 line.

basically, we're checking multiple hyper-v virtual machines create sure replicating properly. way we're doing checking lastly replication date/time , comparing current date/time. here's one-liner have checking 1 machine.

(new-timespan -start(get-vm termserv002| measure-vmreplication | select -expand lastreplicationtime)).totalminutes

this works perfectly. however, we'd check of vms on hyper-v box. can without running new-timespan running command -

get-vm | {$_.replicationstate -ne "disabled"} | measure-vmreplication | select vmname, lastreplicationtime

this gives me every vm on box , lastly replication time.

ultimately, i'd output vmname , lastreplicationtime in minutes current date/time. if can on 1 line, homerun!

any suggestions? no matter how seek meld 2 together, can't seem syntax right (or it's not possible.)

i can't test give try:

get-vm | {$_.replicationstate -ne "disabled"} | measure-vmreplication | select vmname, @{n="lastreplicationtime";e={ (new-timespan -start ($_.lastreplicationtime) -end (get-date)).totalminutes }}

powershell

No comments:

Post a Comment