We help IT Professionals succeed at work.

Add-printer command on Powershell Version 2

jskfan
jskfan used Ask the Experts™
on
Add-printer command on Powershell Version 2


I am trying to run add-printer powershell command   but I m getting error.
add-printer -name "MyTest Printer" -drivername "Canon MX920 series Printer"

Thank you

PS C:\Users\administrator> add-printer -name "MyTest Printer" -drivername "Canon MX920 series Printer"
The term 'add-printer' is not recognized as the name of a cmdlet, function, script file, or operable p
 spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:12
+ add-printer <<<<  -name "MyTest Printer" -drivername "Canon MX920 series Printer" -port "Envy"
    + CategoryInfo          : ObjectNotFound: (add-printer:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\administrator>

Open in new window


the remote computer is running Version 2 of Powershell

PS C:\Users\administrator> $psversiontable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5420
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1


PS C:\Users\administrator>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
Looks like the PrintManagement module requires PS 5.1 and W8.1/2012r2, and you won't have any way (even if you would upgrade to WMF 5.1)  to enable it on this system. You'll have to fall back to e..g VBS code.

However, the cmdlet allows for remote use (running on another machine with PS 5.1)  - you can try if that works, but I doubt it.

Author

Commented:
You'll have to fall back to e..g VBS code.

Can you please provide the script.

I need to add a printer (Printer Name, Host Name, Standard TCP/IP, Driver) Then enable the option  to "print directly to printer"

Actually I was able to do all that with Powershell command but not on Windows 7


Thank you

Author

Commented:
Thanks.. I will post a question for VBScript