Script to reset printer settings to black and white - powershell

I am new to the whole scripting scene if I'm honest. I have done various things with batch files in the past, but have been looking at PowerShell.
As it is I really don't have any idea where to begin or if what I want to achieve is even possible.
My boss is after getting printing costs reduced so need to look at being able to set a printer default of black and white, a user then has to manually select colour through preferences and then it will automatically revert back to a default of black and white.
I have been looking at various things online today and cant seem to find anything specific to this requirement, so not sure it is even possible.
I have considered the possibility of either a logon script that forces the print settings back or some form of task that will run say every hour in the background.
We use UTAX devices, but they are rebadged Kyocera.
The printers are connected to PCs via network, but there is no server involved. Each printer is a local install on each PC, no shares or anything like that.
PCs are running mix of Win7 and WinXP.
Something I've also considered is two instances of the printer installed - 1 for colour and 1 for black and white, naming them to reflect what they are. But I'm not convinced this will take off due to people being set in their ways for printing.
The driver version we have to work with is UTAX v6.0.2212. You can set profiles, but the factory default is colour and also if the user logs on and they change to colour from the printing default of black and white and forget to revert back then it remains on setting of colour.
Thanks in advance for any help.

I happened across your posting yesterday whilst I was looking for a similar application.
One of my clients is attempting to reduce their printing costs, specifically by reducing the number of colour prints that are produced.
We also thought about having 2 printers for each physical printer eg.
HP LaserJet (Colour)
HP LasreJet (Mono)
But felt that this was a bit of a heavy handed approach to seomthing that should be relatively simple to resolve !
As such I was looking for a methodology to allow:-
a. Automatically set the Printer to Mono at Startup
b. Allow users a rapid way to switch to Colour, if they really need to print in Colour
c. Revert back to Mono after printing
So after much head scratching I managed to produce a VB.NET application that sits in the System Tray as an icon.
This application can be started in the Login Script or Startup folder.
Ith then forces the current Default Printer to Mono
Double Clicking the System Tray icon sets the current Default Printer to Colour mode
A 60 second countdown then starts, after which the printer is reverted back to Mono.
I am hoping that this will be sufficient for my clients needs and will reduce the number of accidental colour prints.
Let me know if this would be of interest to you !
James

Related

Mysterious blank space randomly appears in Powershell console buffer

I am plagued by a very strange phenomenon. I tend to write fairly esoteric Powershell modules for stuff I do at work. Often, after running one of these, and the module has ended I will move onto some other tasks, and when I happen to bring up my Powershell console window again, several blank lines (or just blank "space") will have appeared in the buffer. It never appears right away, which is the most confounding part.
Afterwards, the blinking cursor exists at the end of this blank space, and the blank space cannot be "backspaced" (so it's not something inadvertently entering spaces or newlines). It's just there, as part of the buffer. I usually just clear the screen with cls to keep it from annoying me.
I used to just chalk this up to the buggy Windows Powershell 5.1 buffering. However now that I've begun using Powershell 7 (and Windows Terminal), I see that the issue still exists.
Here is a screenshot of a v7 Windows Terminal tab an hour or so after my module finished running:
Sometimes it seems the longer I wait the more blank space has appeared. Here is a screenshot of the same console tab about 20 hours later:
I'm sorry I don't have a better way of explaining this. I realize that without any code or pattern to analyze, that this is a very poor question, by SO standards, but I am just as confused as you are. The only pattern I've noticed is that this only seems to happen after I run my various custom modules. However this accounts for the majority of my Powershell usage, so it might be a red herring.
Usually my modules simply do some processing (talking to computers, AD, etc) and just output some information via Write-Host, and occasionally output a [PSCustomObject], which I always capture in a variable. Even if I was accidentally outputting some blank lines or something to the pipeline, I can't see how that would manifest as blank buffer space that grows over time. I thought maybe I was incorrectly killing async jobs or something and that was somehow causing this, but this happens even in purely synchronous code.
To be clear, in the screenshots above there is no code actually running. That module was the only thing I had run in this particular console tab/session, and it doesn't run any background processes. So I can't understand why the buffer is changing all on its own. In both screenshots, the tab/window is the same size as it was when the module first completed, so it's not just a bunch of spaces in the buffer that are being dynamically resized. And as noted, when the module fist completed there were NO rogue characters in the buffer at all.
One other thing about my usage is that it's all done on a remote VM, accessed through RDP, which I use daily. The only other thing I can think of is that maybe something about the console window being minimized/maximized/resized, the resolution changing, or the login session being connected/reconnected has something to do with it.
Does this sound familiar to anyone? Any ideas for what could be causing this or what I can try to understand the behavior better are much appreciated.
I've confirmed that this actually happens as a direct result of simply "restoring" and "maximizing" the Powershell console window and/or Windows Terminal window. When the issue is "present", doing this will often add another "set" of blank space to the buffer before the cursor. Minimizing seems to have no effect, only going from maximized to "restored" and back to maximized.
I've also confirmed that this has nothing to do with my custom modules. I can replicate the issue by simply opening a fresh, maximized console window/tab, running get-process and then "restoring" and maximizing. It doesn't happen every time though.
It also has nothing to do with my custom profile script, as it happens even on a freshly-imaged computer with no profile.
At this point I'm going back to blaming it on buffer/rendering/window manager implementation bugs in powershell and moving on with my life.

How can I completely reset Powerhsell?

I'd like to reset every single change made to Powershell. Including permission, window sizes, colors, formatting, etc. As if I just installed Powershell on my machine, totally virgin.
Is there a way to do this with one command?

Setting up the default browser (IE, Homepage)

Those are actually two different questions but still they are connected. I am trying to make a script to automate the installation of company PCs for new employees.
An old script used to work fine but as of the 1703 update (or some time prior. No-one really knows), the changes no longer do their job and I cannot seem to find a fix.
The task:
Change the default browser from Edge to Internet Explorer
Set the IE homepage to "https://www.google.com"
Concerning the first problem: I have tried changing the Registry entries at
HKCU:\Software\Microsoft\Shell\Associations\UrlAssociations\http(s)\UserChoice\ No luck there. I have also tried exporting and the setting using DISM but importing them back has proven to be beyond my capabilities (Basically, I ran into this problem: https://social.technet.microsoft.com/Forums/en-US/d5fad871-8f5e-4c74-abaf-627809f8844b/ I cannot programatically change the settings for an existing user)
When facing the second problem, I tried searching the registry for the default site "go.microsoft.com/fwlink/p?LinkId=..." and changing the values. At one startup (After I modiffied the registry key
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main value "Start Page"), IE displayed a prompt to the user informing them that an external appliation wishes to change the homepage but no change actually occured. And this only happened once (even after I changed the value again to a different site)
A preferred method would be using Powershell but after googling and ripping my hair out for two days straight, I am open to any suggestions. If it makes any difference, it's a 64-bit Windows 10 Pro

Win7- Are msconfig options in Safe Mode the same as those shown in Normal bootup?

I changed some of the options in msconfig (while in normal bootup), most notably of which was changing from a selective startup to normal.. it was after that initial reboot that my problems occurred, but that's not why I'm here.
However, for background/troubleshooting purposes: the other changes should all be just fine (just removed a couple of programs from startup), such as adobe reader. I'm not worried about those, but I am worried the changing of "selective startup" may have directly led to my current situation (again, not why I'm here, but feel free to chip in) -> and that problem is simply: the screen goes dark immediately after the win7 login screen appears (the computer is still running, I can't tell if I can login or not)... I digress..
I just want to know if the configuration values for msconfig are the same between safe mode and when operating normally in windows 7.
Thank you for your time.
The values are the same, but they are not treated the same in safe mode. For example, all the startup applications show up in msconfig in safe mode and normal mode, but they're not loaded in safe mode.

Change compatibility mode/run as using logon script

We have 200+ freshly imaged machines and have learned that in some of them Audacity does not work properly. For some reason, on certain (seemingly random) machines, Audacity needs to be in XPSP3 compatibility mode to run properly and be run as an administrator. Since we have 200+ of these, we are trying to find a way to tell a logon script to change Audacity for us. That way, all we have to do is start the machines and log in. I have looked around and haven't found much. Is this even possible? Thanks
To set these on a system wide basis you just need to push out a reg file like so:
-----------------------------------
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Full\\Path\\To\\File.exe"="WINXPSP3"
-----------------------------------
There are additional options if you need them, manually set some yourself and check this registry key.