powershell - Struggling with foreach -


I am new and, well, awesome on this whole scripting thing: so any help would be appreciated.

Actually I am trying to create a PowerShell script which installs an undetermined number printer on an undetermined number of computers. The computer name and printer name will come from local text files.

This is what I have done so far:

  $ credentials = gate-credential $ printerlist = Get-Content C: \ setup \ printers.txt get-content c : \ Setup \ names.txt | Foreach-object {forefront printer ($ printer in printer printer) {rundll32 printui.dll printUIEntry / ge / c $ _ / n $ printer}}  

Edit: I'm getting the error, Unable to complete the process of per-machine printer connection can not be completed (error 0x0000007b) I tried to modify the script, but I can come up with it, which should probably be in lesser way.

I do not think you have an issue with your foreach loop.

I think this is the only use of rundll32 printui.dll printUIEntry

sets the default printer:

  rundll32 printui.dll, printUIEntry / y / c "\\ COMPUTER_NAME" / n "\\ PRINT_SERVER_NAME \ PRINTER_NAME"  

POSESHEEL CONSOLE for a computer individually Try setting your code without / in to see if you still get the same error, there may be a permit, but I do not think so.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -