alienvoice
asked on
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_NetworkAdapterConfig uration -Filter "IPEnabled=TRUE and DHCPEnabled=TRUE" -comp $strComputerID
$IPinfo.IPAddress
$PrinterPath = "\\prd-printserv\ams-L3-TO S6550C-P1- BW"
$net = new-Object -com WScript.Network
if($Ipinfo.IPAddress -eq "172.16.13.73"){$net.AddWi ndowsPrint erConnecti on($Printe rPath)}
else{"Wrong IP, no printer for you!"}
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_NetworkAdapterConfig
$IPinfo.IPAddress
$PrinterPath = "\\prd-printserv\ams-L3-TO
$net = new-Object -com WScript.Network
if($Ipinfo.IPAddress -eq "172.16.13.73"){$net.AddWi
else{"Wrong IP, no printer for you!"}
is the IP Address an array?
if so, try changing your if statement to read
if ($ipinfo.IPAddress -contains "172.16.13.73")
if so, try changing your if statement to read
if ($ipinfo.IPAddress -contains "172.16.13.73")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Turns out WMI can't be used the way I intended. Switch to using vb script instead.
Have you tried a short name of PrintShare just for testing? I presume your Server name is correct.