Skip to main content

Posts

Showing posts from June, 2015

PowerShell Code That Write’s it’s Own Code

I know, sounds a bit out there, but it is possible. My PowerShell Class this week took a question from PowerShell.com. I do this every once and a while so we can apply our newly acquired skill sets to real life situations. This time around we helped out an IT Pro who was importing a CSV file to modify user objects using the Set-ADUser cmdlet of the Active Directory Module for Windows PowerShell. The problem that he was having is that the database that generated this CSV file would occasionally place a NULL value in one of the properties. If you hard code Set-ADUser with a parameter, but then feed it a NULL value, it errors. The same thing happens if you pipe in a NULL value. He needed help trying to fix this. So, we went into action. And generated the cmdlet below. The cool part about this code is that we did not hard code anything with regards to sending data to Set-ADUser. We utilized Invoke-Expression to execute commands that the code generates live. We also did not know if the C

Use Group Policy Preferences to Disable the Windows 8 Initial Logon Animation

So in my Windows class this week, I was asked if it is possible to disable the initial logon animation on Windows 8. You know, that one where you have to connect to the Windows App Store and then have to move the mouse around. By some strange coincidence, I actually hade the Windows 8.1 GPO Registry spreadsheet up. I did a quick internet search to find the correct registry setting, but did not find it as a GPO setting. Next up GPO preferences. Normally I would throw PowerShell into the mix, but this is one of those cases where I feel that a GPO is the better choice. You see, with PowerShell, I would have to contact the computer when it is convenient for both of us. In other words, when I am running the script and the client is online. With a GPO Preference, I make this change and the domain tells the client what to do when the client comes online. The registry setting is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System The key is a DWORD of EnableFirstLogon

Use PowerShell to get coordinates from BING.

As I am continuing to build my module to support Bing using PowerShell, I needed a way to send Bing a location and get its coordinates back.  I had to do some research and I found Kevin Pelgrim’s code to do just that.  I also wanted the geographic rectangle of the selected address so I did some re-coding and also changed the code to match my programming style.  Here is the end result. Check out the help file for details.  You may notice some word wrapping going on.  Especially in the items in purple.  You may need to remove carriage returns if you copy and paste this code from those lines.  The items in green are the start of those lines. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 7