Lessons Learned

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

July, 2014

Posts
  • Lessons Learned

    One-Liner: PowerShell Tools for Visual Studio 2013

    • 0 Comments
    Unsure if I posted this already, and sorry if I did. http://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597 Adam Driscoll posted Visual Studio extension that allows it to edit PSH. It’s not as feature-rich (IMPO) as PowerShell...
  • Lessons Learned

    Starting Elevated PowerShell Windows

    • 0 Comments
    There are a few commands I have to run from Elevated PowerShell windows (such as suspending Bitlocker prior to patching).  It’s not that hard to right-click on my pinned-to-taskbar PowerShell icon and select “Run as Administrator”, but I wanted to...
  • Lessons Learned

    Creating Local Users

    • 0 Comments
    I’m helping some of our test teams more and more.  In one case, we need to create local users in bulk. I’m surprised PSH doesn’t have something for this.  function New-LocalUser { <# .syopsis Creates a local user account .parameter...
  • Lessons Learned

    Querying WMI with a Timeout

    • 0 Comments
    This is thanks to my coworker Keith Munson, who is at least as passionate and adept at PSH as I am:   function Get-WmiObjectWithTimeout {     <#     Credit to Keith Munson for this.     #>  ...
  • Lessons Learned

    Storing SecureStrings Machine-Independently

    • 0 Comments
    As part of a brown bag, I extracted out the logic CredLocker uses to store credentials.  Here’s the guts of the code. The short form is unchanged from the Credlocker post, but I’ve cleaned it up. - It prompts the user for a password if $Host.CredentialStoreCredential...
  • Lessons Learned

    Comparing Performance Counters

    • 0 Comments
    A common TSG step is to look at some perf counter, wait n minutes, then look at it again. When we’re talking about pools, it gets a little more involved.  PerfMon.exe isn’t the most easy to automate (you can save the counterset to an .msc, then copy...
  • Lessons Learned

    One-Liner: Symlinks and Windows

    • 0 Comments
    Windows 7 and above support symbolic links, but the OS needs to be updated to recognize them: fsutil behavior set SymlinkEvaluation R2R:1
  • Lessons Learned

    One-Liner: Fun with Multi-line Blocktext and –Split/.Split()

    • 0 Comments
    The title is an oxymoron: I’m going to show a one-liner on how to deal with multi-line blocktext.  To start with, I’m using ‘blocktext’ to mean: $blocktext = @" This is an example using @" .. "@ "@; which is known...
  • Lessons Learned

    Getting SRV Records with PowerShell

    • 0 Comments
    PowerShell leverages .NET, and .NET exposes the System.Net.Dns class, so all should be happy, no?  Evidently not if it comes to SRV records.  Someone asked me how to do it, and I said, “That’s easy.  I’ll get back to you in a few.” A few...
  • Lessons Learned

    One-Liner: Valid PSH Verbs

    • 0 Comments
    I try to use proper PowerShell verbs, but I’m not always sure what they are (or what they do, which is another matter).  Here’s a quick one-liner to dump those verbs out as a [string[]]$array: Get-Command -CommandType cmdlet | Select-Object -ExpandProperty...
  • Lessons Learned

    MSSQL Server Error Logs

    • 0 Comments
    MSSQL Server error logs exist in the same folder that contains the installed server bits.  They’re text files.  Easy-as-pie to read, right? No. MSSQL is often installed on a dedicated drive.  You can’t assume it will be in C:\Program Files...
  • Lessons Learned

    One-Liner: Padding a Number with Leading Zeroes

    • 0 Comments
    I’m putting this here only because I’m tired of searching for it.  How to pad an integer with leading zeroes is trivial.  1..16 | % { "{0:D2}" -f $_ } And padding a float with trailing zeroes is more of the same: $i = 2; (1..10) |...
Page 1 of 1 (12 items)