I have a function in powershell 2.0 called getip that gets the IP address 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 am facing is getting the result of this function variable. The following does not work ...
$ipaddress = (getip)
$ipaddress = getip
set-variable -name ipaddress -value (getip)
Any help with this issue would be greatly appreciated.
tommy source
share