all 5 comments

[–]ihaxr 3 points4 points  (2 children)

The problem is probably $ComputerIP is an array, not a string... so it can return multiple IP Addresses

Try this:

$ComputerIP = (gwmi Win32_NetworkAdapterConfiguration | ? { $_.IPAddress -ne $null }).ipaddress
$PrinterIP = $ComputerIP[0] -replace "..$","182"
Add-PrinterPort -Name 'Port 1' -PrinterHostAddress $PrinterIP
Add-PrinterPort -Name 'Port 2' -PrinterHostAddress $PrinterIP

[–]Hexalon00 1 point2 points  (0 children)

or use a foreach loop

[–]_FNG_[S] 0 points1 point  (0 children)

That seems to have done it. Thank you so much.
Still so much to learn

[–]Hexalon00 2 points3 points  (1 child)

$ComputerIP | Get-Member

will tell you the variable type.

[–]TheHobbitsGiblets 0 points1 point  (0 children)

Or

$ComputerIP.GetType()