So I have not been able to really work with Powershell much in my new job. A recent project had me involved with getting Windows 2008 R2 domain controllers into our infrastructure. All of that was pretty standard. There is one little setting that seems to get our security guys into interrogation mode. That little icon on Windows 2008R2 and Windows 7 that shows if you have internet connectivity or not… It can be turned off via Group Policy easy enough but there is not much Powershell going on in this office so…
First example I showed was how to use the CLI to make the change the value locally using:
set-itemproperty hklm:\system\currentcontrolset\services\nlasvc\parameters\internet -Name 'EnableActiveProbing' -value 0 -type dword
I then wrote a script that when logged onto a server we could run to check the current setting and update it if necessay.
This of course led to a challenge “can you show what all of our 2008R2 servers are set for”… As I said before there is not much Powershell in this shop so Remoting is not an option. That is when I rediscovered a module that I had not used in over a year… PSRemoteRegistry I was quickly able to give a brief instruction on powershell modules and then show a quick example of how to remotely check the value and then set it appropriately if necessary:
get-regdword -Computer computername -Hive LocalMachine -Key system\currentcontrolset\services\nlasvc\parameters\internet -Value EnableActiveProbing
set-regdword -Computer computername -Hive LocalMachine -Key system\currentcontrolset\services\nlasvc\parameters\internet -Value EnableActiveProbing -Data 0
Wala… Now the computer just needs to be rebooted and the Security folks won’t see these machines trying to test for internet connectivity. Now I did have one machine that was my test machine that was not cooperative, matter of fact a valid set-itemproperty statement would actually cause it to duplicate the key but there was another issue on that machine at the time and I didn’t take the time to resolve what appeared to be a one-off case.
I have to preface this with I truly respect the idea and the gentleman who initiated ScriptCop. That said it sort of brings up a sore point that struck me during the last Scripting games.
I am all for beautiful functioning code but Powershell seems to have brought a large amount of developer oriented folks into the community and the mix with System Administrators becomes interesting. When I first started with Powershell I was doing lots of vbscript so I was able to focus on code and listening to the great minds who were not just teaching the powerful language but to optimize it.
I would love to sit and perfect my code, but as my new job dictates, there isn’t time to write beautiful code. And that is just one issue I have with the critiquing. Granted I think that an employer who wants you to apply Powershell technology but doesn’t think you should spend time doing it right is problematic but, that is how it is. Additionally when I write code, I have to think about it’s readability, and readability amongst a varied expertise. Things like long concise pipelines. They look very cool and are normally very proficient, but think about the SysAdmin who might have to perform an after hours support call when it isn’t functioning correctly. Despite the huge powershell community, my day to day experience indicates there are more Windows System Administrators that are not even looking at Powershell and most never progressed beyond batch files. Breaking a pipeline into separate steps is just a more debuggable format in my opinion.
I do think ScriptCop is a great idea but maybe applied more towards a uniform way to apply approved standards to a library of scripts.
So, this post is more about personal loyalties than Powershell itself. The recent changes with PowerGUI have me contemplating changing my default editor. I have found PowerGUI to be great, but part of the greatness was the Product Manager. The product is great, especially the editor. I did buy the pro version and quite frankly in my environment it didn’t give me anything I could use but it seemed right to support the product as I as endorsing it to everyone I worked with.
At this point I am considering going back to PowershellPlus but after I played with the most recent beta I miss the original version. I still use Sapien for when I have to work with vbscript code but I find it way too bloated when comparing it PowerGUI. When it’s all said and done I think I will be deciding between the ISE and the free PowerGUI.