Hello everyone!<\/p>\n
I am fairly new at PowerShell, so forgive my noobishness.<\/p>\n
I have a task I am looking to accomplish.<\/p>\n
With the arrival of “PrintNightmare” we are looking at improving our domain security and locking down things on users systems.<\/p>\n
Some of our users printer drivers are having mismatch issues with what is corresponding to the server. Why or how? I do not know. I was not responsible. I am simply trying to resolve the issue in a better, and more effective way. So, to that end, I have chosen to try to use PoweShell.<\/p>\n
Let’s say, for example, I have a user using version X of a driver and the server has version Y.<\/p>\n
I’d like to devise a script that will - 1. poll the client’s workstation and obtain their hostname 2. Get a list of printer drivers they have installed 3. Do a reinstallation of said printers via the print server, ensuring their driver names match, which I know is imperative. 4. Do so in a manner which does not give the user any form of local admin rights -<\/p>\n
I want to do this via a script our SysAdmin executes, or, some form of a batch file we manually choose to run. In fact, we’d like to keep this as a “tool” to use ad-hoc whenever we find straggler users who are experiencing these issues. We DO NOT want to use a GPO or any 3rd party tools to do this. I / we believe we can accomplish everything we need within PowerShell.<\/p>\n
We believe we can even throw this into some form of ScheduledTask which will execute at a given time and reinstall their drivers automatically. That, is our end goal.<\/p>\n
As I mentioned previously, I am no PowerShell guru. I know a few basics and that’s it, and that, is why I am here.<\/p>\n
So far, I have dabbled and can do the add-printer -connectionName \\name of server to simply add a printer to a system. That works fine. I have not tested that against a machine that does not have local admin rights though. I suspect I’d have to put that in a batch that’s executed as Admin to get that to work. Feel free to correct me if I am wrong on that.<\/p>\n
My Supervisor likes my idea, and wants to expand my suggestion a bit further. He is of the mind that a script can be run and (somehow) list the drivers as variables, which, could then, be transposed into the execution script to “automate” driver reinstallation if you will, for lack of a better description. He does not want us to have to manually sift through the get-printerdriver list to manually have to populate the execution script. That is where I am at a (total) loss of how to accomplish something like that, IF, it were possible.<\/p>\n
I am freely open to any and all comments / suggestions on how to best accomplish this, again, within PowerShell.<\/p>\n
I thank each of you for reading this, and, for any assistance you can provide.<\/p>","upvoteCount":3,"answerCount":3,"datePublished":"2021-09-21T11:18:46.000Z","author":{"@type":"Person","name":"bravehrt777","url":"https://community.spiceworks.com/u/bravehrt777"},"suggestedAnswer":[{"@type":"Answer","text":"
Hello everyone!<\/p>\n
I am fairly new at PowerShell, so forgive my noobishness.<\/p>\n
I have a task I am looking to accomplish.<\/p>\n
With the arrival of “PrintNightmare” we are looking at improving our domain security and locking down things on users systems.<\/p>\n
Some of our users printer drivers are having mismatch issues with what is corresponding to the server. Why or how? I do not know. I was not responsible. I am simply trying to resolve the issue in a better, and more effective way. So, to that end, I have chosen to try to use PoweShell.<\/p>\n
Let’s say, for example, I have a user using version X of a driver and the server has version Y.<\/p>\n
I’d like to devise a script that will - 1. poll the client’s workstation and obtain their hostname 2. Get a list of printer drivers they have installed 3. Do a reinstallation of said printers via the print server, ensuring their driver names match, which I know is imperative. 4. Do so in a manner which does not give the user any form of local admin rights -<\/p>\n
I want to do this via a script our SysAdmin executes, or, some form of a batch file we manually choose to run. In fact, we’d like to keep this as a “tool” to use ad-hoc whenever we find straggler users who are experiencing these issues. We DO NOT want to use a GPO or any 3rd party tools to do this. I / we believe we can accomplish everything we need within PowerShell.<\/p>\n
We believe we can even throw this into some form of ScheduledTask which will execute at a given time and reinstall their drivers automatically. That, is our end goal.<\/p>\n
As I mentioned previously, I am no PowerShell guru. I know a few basics and that’s it, and that, is why I am here.<\/p>\n
So far, I have dabbled and can do the add-printer -connectionName \\name of server to simply add a printer to a system. That works fine. I have not tested that against a machine that does not have local admin rights though. I suspect I’d have to put that in a batch that’s executed as Admin to get that to work. Feel free to correct me if I am wrong on that.<\/p>\n
My Supervisor likes my idea, and wants to expand my suggestion a bit further. He is of the mind that a script can be run and (somehow) list the drivers as variables, which, could then, be transposed into the execution script to “automate” driver reinstallation if you will, for lack of a better description. He does not want us to have to manually sift through the get-printerdriver list to manually have to populate the execution script. That is where I am at a (total) loss of how to accomplish something like that, IF, it were possible.<\/p>\n
I am freely open to any and all comments / suggestions on how to best accomplish this, again, within PowerShell.<\/p>\n
I thank each of you for reading this, and, for any assistance you can provide.<\/p>","upvoteCount":3,"datePublished":"2021-09-21T11:18:46.000Z","url":"https://community.spiceworks.com/t/installing-printers-help/811720/1","author":{"@type":"Person","name":"bravehrt777","url":"https://community.spiceworks.com/u/bravehrt777"}},{"@type":"Answer","text":"
I believe that your plan is definitely viable, and will be keeping an eye on this thread because I’m thinking I should do the same thing.<\/p>\n
Have you any experience in programming or scripting? The specific language aside, do you have the mindset and knowledge to work through building a script? To mentally run through a process, break it down into logical steps, and then start building each piece?<\/p>\n
One step at a time, start small and add functionality to grow into a full solution. Are you able to perform any of your outlined steps yet?<\/p>\n
\nI’d like to devise a script that will -<\/p>\n
\n
- poll the client’s workstation and obtain their hostname<\/li>\n
- Get a list of printer drivers they have installed<\/li>\n
- Do a reinstallation of said printers via the print server, ensuring their driver names match, which I know is imperative.<\/li>\n
- Do so in a manner which does not give the user any form of local admin rights<\/li>\n<\/ol>\n<\/blockquote>\n
Post your (sanitized) code so far and we can help you figure out what is not working, or what might be a good next step.<\/p>\n
\nSo far, I have dabbled and can do the add-printer -connectionName \\name of server to simply add a printer to a system. That works fine. I have not tested that against a machine that does not have local admin rights though. I suspect I’d have to put that in a batch that’s executed as Admin to get that to work. Feel free to correct me if I am wrong on that.<\/p>\n<\/blockquote>\n
A good next step would be to test this piece on the non-admin machine. If it does not work then we can look at how to make it work. Again with the posting of what you’ve tried and your results.<\/p>\n
\nMy Supervisor likes my idea, and wants to expand my suggestion a bit further. He is of the mind that a script can be run and (somehow) list the drivers as variables, which, could then, be transposed into the execution script to “automate” driver reinstallation if you will, for lack of a better description. He does not want us to have to manually sift through the get-printerdriver list to manually have to populate the execution script. That is where I am at a (total) loss of how to accomplish something like that, IF, it were possible.<\/p>\n<\/blockquote>\n
Your supervisor is correct, this can all be done inside a single script. As mentioned above, work through each piece and add pieces thereto until you arrive at your destination.<\/p>\n