Piping output from one command to another – HP Scripting Tools for Windows PowerShell User Manual
Page 12
comma is interpreted as a list separator by PowerShell. Without double quotes, part of what should
be a string is interpreted by PowerShell as a number. The operation of combined ranges is defined
as creating a combination of each subnet address with each other subnet.
The following are examples of input range parameters using double quotes.
Description
Range Parameter
Specifies two addresses to check, 192.168.1.1 and 192.168.1.15.
“192.168.1.1,15”
Specifies four addresses to check, 192.168.217.93, 192.168.217.103,
192.168.216.93, 192.168.216.103.
“192.168.217,216.93,103”
Specifies twenty-two addresses to check, 192.168.217.93 through
192.168.217.103 and 192.168.216.93 through 192.168.216.103.
“192.168.217,216.93-103”
Piping output from one command to another
A useful feature of PowerShell is the ability to pipe output from one command to another. The
preceding section provided examples of using Find-HPiLO to locate iLO devices. You may want
to use those with other commands rather than input the iLOs you find again or store them somewhere
and re-use them.
The following is a script that pipes output from Find-HPiLO through Add-Member to add two
required fields, and then to Get-HPiLOFirmwareVersion to produce the firmware version
information for the iLOs found. The –Verbose parameter is used to view more information.
PowerShell script:
Find-HPiLO 192.168.217.97-103 -Verbose |
% {Add-Member -PassThru -InputObject $_ Username admin}|
% {Add-Member -PassThru -InputObject $_ Password admin123}|
Get-HPiLOFirmwareVersion -Verbose
Script output:
The following is typical output from this script.
Warning : It might take a while to search all the HP iLO servers if the input
is a very large range. Use Verbose for more information.
VERBOSE: Using 7 threads for search.
VERBOSE: Pinging 192.168.217.97
VERBOSE: Pinging 192.168.217.98
VERBOSE: Pinging 192.168.217.99
VERBOSE: Pinging 192.168.217.100
VERBOSE: Pinging 192.168.217.101
VERBOSE: Pinging 192.168.217.102
VERBOSE: Pinging 192.168.217.103
VERBOSE: No iLO at 192.168.217.97
VERBOSE: No system responds at 192.168.217.99
VERBOSE: No system responds at 192.168.217.100
VERBOSE: No system responds at 192.168.217.101
VERBOSE: No iLO at 192.168.217.102
VERBOSE: Using 2 threads.
VERBOSE: Sending to 192.168.217.98 - ilo2m203100ld.company.net
VERBOSE: Sending to 192.168.217.103 - iloromqap8207bc.company.net
VERBOSE: Errors-0, Warnings-0, Total-2
IP : 192.168.217.98
HOSTNAME : ilo2m203100ld.company.net
STATUS_TYPE : OK
STATUS_MESSAGE : OK
FIRMWARE_DATE : Jan 24 2013
FIRMWARE_VERSION : 1.55
12
HP Scripting Tools for Windows PowerShell cmdlets