Lessons Learned

My drop-site for interesting snippets and tips. If it's useful to you as well, great!

  • Lessons Learned

    Active Directory - Creating Install From Media dump

    • 1 Comments
    function Backup-ActiveDirectoryIFM { param ( [string] $IFMPath , [switch] $NoDefrag ) $errorAction = 'stop' $minimumFreeSpace = 0.5TB $Mode = 'Full' if (! $IFMPath ) { $driveObject = Get-PSDrive | ? { $_ .Free } | Sort...
  • Lessons Learned

    Converting Whitespace-Indented Output to XML

    • 0 Comments
    Example of taking output delimited by indents and trying to beat it into XML. 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...
  • Lessons Learned

    Moving Computer AD Objects

    • 0 Comments
    I'm just going to toss code up here from now own. Too busy to write nicely-formatted posts. Apologies.! 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 ...
  • Lessons Learned

    IE, ADFS, and Overkill

    • 0 Comments
    I do some testing that requires I not use Active Directory Federation Services (ADFS), which is an otherwise-convenient way to authenticate me against web sites via my Active Directory token.  I used to start IE in Private Mode to do that, but it...
  • Lessons Learned

    Backing Up BitLocker Keys to OneDrive as a Scheduled Task

    • 0 Comments
    While I can’t say I love Bitlocker, I do understand it as a requirement for any machine with corporate data.  That said, it seems quite capricious when the BitLocker gremlin decides to require the 48-digit recovery key.   I’ve taken to...
  • Lessons Learned

    Configuring the ISE

    • 0 Comments
    I tend to flatten my laptop about once a season. Among the other things I lose is my PowerShell_ISE customizations. They’re not many, but I miss them when I have to live without them. Fortunately, they’re all captured in my Microsoft.PowerShellISE_profile...
  • Lessons Learned

    Left-Padding a String

    • 5 Comments
    I’ll be honest; .NET has more methods and classes and properties than I can shake an idiom at. In my previous blog post, I needed to left-pad a string with zeroes in order to treat it as a 32-bit binary value to [Array]::Reverse() . I also had to do the...
  • Lessons Learned

    Pass the CIDR, Will You?

    • 0 Comments
    Classless Inter-Domain Routing (e.g. 192.168.1.0/24) replaces dotted-notation netmasks (e.g. 192.168.1.0 with a subnet mask of 255.255.255.0) to do the same thing: what IP addresses are considered on-subnet (and therefore do not need to go through the...
  • Lessons Learned

    One-Liner: Left-Padding a String with Zeroes

    • 0 Comments
    Yesterday’s post had a little bit of sleight-of-hand involved.  For the IPv4 address to UInt64 conversion to work, each octet had to be converted into an 8-character string of ones and zeroes.  However, [convert]::ToString($int, 2) doesn’t zero...
  • Lessons Learned

    IPv4 Addresses and CIDR Fun

    • 0 Comments
    Classless Inter-Domain Routing is the current way to define a subnet.  An example entry would be “192.168.1.0/24”.  What this means is that the first 24 bits of the 32 bit IPv4 address are considered ‘off the subnet.’  The last octet is...
  • Lessons Learned

    PowerShell ISE Environment Keyboard Shortcuts, Part 2

    • 2 Comments
    A coworker asked how many of these shortcuts I knew. Given that I had to go looking for a shortcut that was explicitly displayed in the Edit menu, I guess you know the answer. Then, he said he wished he could learn them. That gave me an idea… ...
  • Lessons Learned

    PowerShell ISE Environment Keyboard Shortcuts

    • 0 Comments
    It started with a simple question: is there a shortcut to go to the Console Pane in the ISE?  A few web pages gave lists of shortcuts, but then this guy went the extra … parsec. http://www.powershellmagazine.com/2013/01/29/the-complete-list-of-powershell...
  • Lessons Learned

    $PSModuleAutoLoadingPreference and You

    • 0 Comments
    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...
  • Lessons Learned

    Filtering Show-NetIPSec Rules based on IP Address

    • 0 Comments
    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...
  • Lessons Learned

    Getting Trusted Domain Computer Names

    • 0 Comments
    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...
  • Lessons Learned

    Importing Azure RDC Files into RDCMan.exe’s RDG

    • 0 Comments
    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...
  • Lessons Learned

    Namespaces, Why Does It Always Have To Be Namespaces?

    • 0 Comments
    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...
  • Lessons Learned

    Backing Up BitLocker Recover Key (Strikes Again!)

    • 0 Comments
    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...
  • Lessons Learned

    BitLocker and Voice

    • 0 Comments
    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...
  • Lessons Learned

    SkyDrive, OneDrive, Let’s Call the Whole Thing Off

    • 0 Comments
    (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...
  • Lessons Learned

    $PSBoundParameters and CommonParameters (-WhatIf, -Debug, etc.)

    • 0 Comments
    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...
  • Lessons Learned

    I Hate Write-Host So Much…

    • 0 Comments
    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...
  • Lessons Learned

    YOMER Yet One More Error Reporting (Method)

    • 0 Comments
    I wrote about creating an Out-Error function before to avoid outputting the stack dump that a normal Write-Error displays.  Many newcomers to PSH take one look at the huge blob of angry red text and throw up their hands in frustration. Write-Error...
  • Lessons Learned

    Subshells (by the Seashore?)

    • 0 Comments
    Yesterday’s post detailed some frustration I encountered running PowerShell in a subshell.  Why was I running it in a subshell in the first place? I’m glad you asked. It all started a long time ago (well, a few years, but it felt like a long time...
  • Lessons Learned

    Send-Keys

    • 2 Comments
    Firstly, I am standing on the shoulders of giants.  As the comments below state, the essential first function, Set-WindowState, is only slightly modified from the original form at http://www.snip2code.com/Snippet/50118/Hide--Show--Minimize--Maximize...
Page 1 of 10 (227 items) 12345»