powershell function output to variable
Posted
by tommy
on Stack Overflow
See other posts from Stack Overflow
or by tommy
Published on 2010-06-10T18:28:14Z
Indexed on
2010/06/10
18:32 UTC
Read the original article
Hit count: 279
powershell
|powershell-v2.0
I have a function in powershell 2.0 named getip which gets the IP address(es) of a remote system.
function getip {
$strComputer = "computername"
$colItems = GWMI -cl "Win32_NetworkAdapterConfiguration" -name "root\CimV2" -comp $strComputer -filter "IpEnabled = TRUE"
ForEach ($objItem in $colItems)
{Write-Host $objItem.IpAddress}
}
The problem I'm having is with getting the output of this function to a variable. The folowing doesn't work...
$ipaddress = (getip)
$ipaddress = getip
set-variable -name ipaddress -value (getip)
any help with this problem would be greatly appreciated.
© Stack Overflow or respective owner