February 24, 2016 at 2:47 am #35614
Right first off I have no experience what so ever with VBscripting or Powershell, so I might need my hand held a bit. I think its the only way I will be able to get this to work though. As I tried through just command prompt scripting but it will not work
Basically I have users who bring their own laptops (which are not bound to AD) (such as BYOD) and they want to be able to automatically install papercut and also install printers
I have been able to create a .EXE package which installs papercut client on their machine and it tries to connect to the printers
The part where it tries to connect to the printers through command prompt fails, as it is not asking the user for their domain username and password
Now I have confirmed this by going to file explorer and typing in the server name and it prompts for a password, then I run the script and all the printers connect fine
so its an issue when I have a new machine that has not authenticated to the print server that the script gets stuck
I have been searching on google and people and even a papercut guy replied back to my e-mail providing me a VBscript that should do the job:
printerName = "\\server\PrinterName"strUserName = inputBox("What is your username (domain\username)")strPassword = inputBox("What is your password")set WshShell = WScript.CreateObject("WScript.Shell")set WshNetwork = WScript.CreateObject("WScript.Network")WshShell.Run "cmd /k net use " & printerName & " /USER:" & strUserName & " " & strPassword,1,true WshNetwork.AddWindowsPrinterConnection printerName
This is all chinese to me. Can anyone please provide me some help in what and where to edit this script and how to maybe run it with powershell or something? I also want to add a few lines before it to install papercut local client ( which I could probably work out)
I tried editing these parts:
\\server\PrinterName but it wont work at all, I am sure I am doing it wrong
February 25, 2016 at 2:26 am #35667
You can try with the below command by launching the powershell as a administrator on the local machines.
Add-Printer -Name "mxdw 2" -DriverName "Microsoft XPS Document Writer v4" -PortName "portprompt:" -ConnectionName \\server\printername
This command adds a printer with name "mxdw2" to the local computer. The "mxdw" printer uses the "Microsoft XPS
Document Writer v4" driver and the "portprompt:" port, where -connectioname points to a server where printer is been shared.
February 25, 2016 at 3:35 am #35670
I am also pretty New to Powershell, so somebody can correct me if I'm wrong on this.
Out of Your post, I think that you are trying to Connect to a network share.
I'm not quite shure what you won't to accomplish but this is what I think you are trying to do.
People need to install a printer, because they use BYOD.
Are the BYOD machines in the domain? probably not.
But they are on a network that has conenction to the domain? Probably yes.
If you Write a PowerShell script, asking for the users domain name, if they have any?
Since this is only printers, I think you can make up a account in AD only for that purpose, but do NOT make it a domain user, so the user can log in to the domain With it.
It' also need to have permissions to the printer share.
Usually \\PRINTER01 as an example.
Then you can make a PowerShell script that ask for the domain name like this.
I put the commands in to this just to show you ( )
(Get-Credential) this promt the user for the username and password
and then store it in a variable
You need to do this first, so the sessions has rights to the printer.
Then you can use the command.
Add-printer -ConnectionName \\Printserver\Printername
You change the Print server to the printserver you have the printers installed on.
And also point to the right printer.
If you don't want to give out the username and password then I can help you With that to.
Please come back to me, and I will try to help you.
You must be logged in to reply to this topic.