I am executing a command for which I am getting output like below
Identifier: 3 SFP
Connector: 7 LC
Transceiver: 7004404000000000 4,8,16_Gbps M5 sw Short_dist
Encoding: 6 64B66B
Baud Rate: 140 (units 100 megabaud)
Length 9u: 0 (units km)
Length 9u: 0 (units 100 meters)
Length 50u (OM2): 3 (units 10 meters)
Length 50u (OM3): 10 (units 10 meters)
Length 62.5u:0 (units 10 meters)
Length Cu: 0 (units 1 meter)
Vendor OUI: 00:05:1e
Vendor PN: 57-0000088-01
Vendor Rev: A
Wavelength: 850 (units nm)
Options: 003a Loss_of_Sig,Tx_Fault,Tx_Disable
BR Max: 0
BR Min: 0
Date Code: 180316
DD Type: 0x68
Enh Options: 0xfa
Status/Ctrl: 0xb2
Pwr On Time: 3.52 years (30822 hours)
E-Wrap Control: 0
O-Wrap Control: 0
Alarm flags[0,1] = 0x5, 0x40
Warn Flags[0,1] = 0x5, 0x40
Temperature: 32 Centigrade
Current: 8.082 mAmps
Voltage: 3311.6 mVolts
RX Power: -5.5 dBm (280.4uW)
TX Power: -2.8 dBm (523.1 uW)
I need to fetch the last 2 lines only, that is starting with RX and TX out of it.
I was trying like
#$streamOut | Select-String -Pattern "^RX" | select -ExpandProperty line
$streamOut | Select-String -Pattern "RX" | select -ExpandProperty line
This is by code
$session = New-SSHSession -ComputerName $SAN_IP -Credential $cred
$Strem = New-SSHShellStream -SSHSession $Session
$streamOut=@()
$SystemView = $Strem.WriteLine("sfpshow $port_Num")
sleep -Seconds 5
$streamOut = @($Strem.read())
sleep -Seconds 5
$RXTX_Data = @($streamOut | ? { $_ -match "^RX" -or $_ -match "^TX"})
$RXTX_Data
When I use the below solution in above code, it is returning blank. the $streamOut is array
PS C:\Windows\system32> $streamOut.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
But it is returning the entire output.
Please let me know on this
$streamOut | Select-String -Pattern "^(RX|TX)" | Select-Object -ExpandProperty Lineworks for me, provided that$streamOutis an array of lines, such as from a call toGet-Content. Please add the code where you assign$streamOut.