Year: 2014

This is a very simple onelner. The problem statement is a more complicated. PSH 3 and 4 treat PSModules in a very funny way. These versions have a default module path, and will return any cmdlet that happens to be in any module that happens to be in any directory in the default module path,…

Get-NetIPSecRule seems a little half-baked. A coworker asked me to come up with a way to only return IPsec rules for a given address. I’m surprised Show-NetIPSecRule natively doesn’t have that, nor does each record have the RemoteAddress property, which would be against which I would filter. I’m not sure I understand the design decisions…

The -replace ‘\..*’, $domain snippet is in case here’s some AD funkiness that returns the FQDN from the external DNS record instead of internal. Some of my labs expose machines to other labs. Dammit, Jim, I’m a lab admin, not the DNS guru. function Get-ComputerNameFromTrustedDomain { if (!(Get-Command -Name Get-ADObject)) { Import-Module ServerManager; Add-WindowsFeature RSAT;…

This is really over-engineering. Azure’s “connect” link sends you a .rdc file to download or open. The registered handler for .rdc files is mstsc.exe, a.k.a. Remote Desktop Connection. The key line in the .rdc file is “Full Address:s:FQDN:PORT”. The ‘s’ column in the colon-delimited value is short for ‘string,’ nothing more. What we want are…

I’ll be honest, I LOATHE namespaces in XML. I haven’t seen a case where I needed to use them to differentiate between identically-named elements in different contexts. So often, the document declares a namespace at the top and never overrides it. In that case, why use it? Why do I hate it? It breaks XPath…

Here’s a one-liner for backing up the BitLocker Recovery Key for every drive attached to the machine: ZgB1AG4AYwB0AGkAbwBuACAAQgBhAGMAawB1AHAALQBCAGkAdABMAG8AYwBrAGUAcgBSAGUAYw… Followed by 9kb of more of the same. It’s an EncodedCommand, so we can toss this into a scheduled task. The actual encoded command is attached (thank goodness!) It outputs a .CLIXML file that contains a scalar…

I loathe BitLocker. In fact, I often let a ‘ch’ phoneme slip in between the first and second vowel. The reason is that it seems to be on some random hair-trigger. Patching will trigger Recovery Mode. Sometimes even having a USB HD or memory stick attached will trigger it. I have a Surface Pro, in…

(Apologies to Istanbul (Not Constantinople) by Jimmy Kennedy and Nat Simon.) We all know about SkyDrive being renamed OneDrive. However, I don’t see a way to determine which is where on what machine. Rather than dive through the registry for that, I decided to normalize my scripts to OneDrive, and to create symlinks from SkyDrive…

For the longest time, I was unable to get $PSBoundParameters to work to detect –Debug, -Verbose, etc. CommonParameters. Here’s a handy page that captures the output of about_CommonParameters. http://technet.microsoft.com/en-us/library/hh847884.aspx

Write-Host is evil. It’s just plain evil. In fact, it’s so evil that I learned to make a proxy function for it. What’s a proxy function? Glad you asked. I’m basing my work on this post by Shay Levy. http://blogs.technet.com/b/heyscriptingguy/archive/2011/03/01/proxy-functions-spice-up-your-powershell-core-cmdlets.aspx You start with getting effectively a prototype of the cmdlet, a skeleton of what the…