Recently I have been building a lot of Windows Servers in different environments - one of the things I used to love to install as a system administrator was BGINFO. This helped me keep track of which server I was on. BGINFO was a stable tool for any system I built and administered for quite a while
It would, as you expect, put information on the desktop image - this was very useful - made me less prone to mistakes. Mistakes make GrumpyAdmin very grumpy, and in my company, if people make a stupid mistake - they are Pizza Fined, which means they have to buy Pizza for the team! There is a reason; I am poor, overweight and looking at needing a heart bypass in the near future!!!
BGINFO helped ground an administrator into which system/server they were on!
However, BGINFO, an attack vector for particular environments, was banned and removed. MS has resolved the issues and is now safe and part of the Powertoys from Microsoft - However, it has now been delisted in most workplaces and environments I deal with.
So as you can see, there are lots of capabilities to manipulate graphics - looking at the table of classes - there is something we can use to achieve our aim!
Now that I know that, I can start to create a function that will open an image file and then write the strings from the variables on the image.
After some trial and error work, I developed the following code.
Wow, that works! Amazing!
This proves the concept will work! So the next step is to get the code to write every variable on the desktop image!
Typically when dealing with Powershell and variables - it is much better to create what they call a HashMap
So here is a simple HashMap for my variables
Then we need to loop through the Hashmap and put them on JPG image.
So this part of the problem is sorted - we can generate a JPG image with our variable information printed on it!
The next thing to do is to set that as the active background image.
Here is a quick Google, and I find some sample code that does the trick - why reinvent the wheel? Grumpy Admin does something very common: Swipping with Pride - I am not the smartest of the best in the world, why trouble myself with writing and figuring stuff out when you can Google and swipe with pride? :)
The main thing is that as long as you understand what the code you steal does and that you don't violate any licences, you are golden!
Combine the whole thing, and I have a working prototype PowerShell code! Yippy!
Now as always, I have a working code example. It is time to turn that into a total production standard code!
There are many function templates, and the standard is well documented - so if you are doing POSH code much, you should know this. I am going to call this function - using the standard verb method.
So variables are extracted, and a CmdLetBinding is created for each.
I used If statements used to toggle elements of the code on or off Added comments to the code at various structural points