Powershell script - map a networked printer onto a remote PC

Hi everyone,

Below is a script I have be writing, (with some help from Experts here), to get the IP of a remote PC. Confirm it and based on the confirmation of the IP, I am trying to install a printer, (that is shared on a print server), on the remote PC.

The script completes but no printer is added on the remote PC.

Any ideas?

$strComputerID = "pc.domain.com"
$Ipinfo = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=TRUE and DHCPEnabled=TRUE" -comp $strComputerID
$IPinfo.IPAddress
$PrinterPath = "\\prd-printserv\ams-L3-TOS6550C-P1-BW"
$net = new-Object -com WScript.Network

if($Ipinfo.IPAddress -eq "172.16.13.73"){$net.AddWindowsPrinterConnection($PrinterPath)}
else{"Wrong IP, no printer for you!"}
LVL 15
alienvoiceAsked:
Who is Participating?
 
alienvoiceConnect With a Mentor Author Commented:
Turns out WMI can't be used the way I intended. Switch to using vb script instead.
0
 
AkulshCommented:
Your $PrinterPath = "\\Server\PrintShare" line has a very odd and long name for PrintShare.

Have you tried a short name of PrintShare just for testing? I presume your Server name is correct.
0
 
slidingfoxCommented:
is the IP Address an array?

if so, try changing your if statement to read

if ($ipinfo.IPAddress -contains "172.16.13.73")
0
 
alienvoiceAuthor Commented:
Turns out WMI can't be used the way I intended. Switch to using vb script instead.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.