Someone know how insert two arguments where at the end of the foreach below? If variable $.Sinal is 0 (zero) the message is fiber cut, if $.Sinal is 2 the message is Poweroff.
This script queries a device and returns two tables. I pass the variables the values and treat them in this foreach. However, there was a change in the way the equipment sends information adding an additional value. In this case what I need is if it is value = 1 the message is “Fiber cut” but if it is = 2 the message is “Poweroff”
Thanks a lot for your reply. After put the code the following error appear:
ForEach-Object : Cannot bind parameter ‘RemainingScripts’. Cannot convert the “if” value of type “System.String” to type “System.Management.Automation.ScriptBlock”.
<text>ONU STATUS: [ONU: 11/12/7 STATUS: Power
Off] [ONU: 11/14/3 STATUS: Power Off] [ONU: 11/16/1 STATUS: Power Off] [ONU: 11/16/3 STATUS: Power Off] [ONU: 11/5/11 STATUS: Power Off] [ONU: 11/6/5 STATUS: Power Of
f] [ONU: 11/7/1 STATUS: Signal Off] [ONU: 11/9/10 STATUS: Signal Off] [ONU: 12/10/2 STATUS: Power Off] [ONU: 12/11/13 STATUS: Signal Off] [ONU: 12/16/3 STATUS: Power O
ff] [ONU: 12/6/6 STATUS: Signal Off]</text>
It is almost OK. Only the space (tabulation) we need adjust.
ONU STATUS:
[ONU: 11/11/9 STATUS: Power
Off] [ONU: 11/13/1 STATUS: Power Off] [ONU: 11/15/1 STATUS: Power Off] [ONU: 11/16/3 STATUS: Power Off] [ONU: 11/5/11 STATUS: Power Off] [ONU: 11/6/5 STATUS: Power Off
] [ONU: 11/7/1 STATUS: Signal Off] [ONU: 11/9/10 STATUS: Signal Off] [ONU: 12/10/3 STATUS: Power Off] [ONU: 12/16/3 STATUS: Power Off] [ONU: 12/6/6 STATUS: Signal Off]
[ONU: 12/8/6 STATUS: Power Off]
Thanks so much for all your time to reply that post. The code is working. The tabspace isn’t a problem. Now, I search a way to count how many times the number 0 and the number 2 appear int two other variables like: 0 = $signaoff and 2=$poweroff.