Powershell script - map a networked printer onto a remote PC

Posted on 2012-09-03
Last Modified: 2012-09-14
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 = ""
$Ipinfo = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=TRUE and DHCPEnabled=TRUE" -comp $strComputerID
$PrinterPath = "\\prd-printserv\ams-L3-TOS6550C-P1-BW"
$net = new-Object -com WScript.Network

if($Ipinfo.IPAddress -eq ""){$net.AddWindowsPrinterConnection($PrinterPath)}
else{"Wrong IP, no printer for you!"}
Question by:alienvoice
    LVL 3

    Expert Comment

    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.
    LVL 6

    Expert Comment

    is the IP Address an array?

    if so, try changing your if statement to read

    if ($ipinfo.IPAddress -contains "")
    LVL 15

    Accepted Solution

    Turns out WMI can't be used the way I intended. Switch to using vb script instead.
    LVL 15

    Author Closing Comment

    Turns out WMI can't be used the way I intended. Switch to using vb script instead.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    A post on a forum I visit frequently mobilized me to create a script to remove a password (the one required to open a file) from any number of Word files. Because nobody would want to open a 100 files and manually save them... Of course, you have t…
    Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now