Lessons Learned

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

Posts
  • Lessons Learned

    Stupid Microsoft Word Trick: Multilevel Numbered Headings

    • 7 Comments

    1. Heading 1

    1.1 Heading 2

    1.1.1 Heading 3

    1.2 Heading 2

    Ever wonder how to do that?  Well, it's a lot harder than it should be!

    ...
  • Lessons Learned

    Securely Storing a Password

    • 5 Comments
    Here's the scenario: You have a script that needs to access a static password which has to be stored in a file, but you do not want the password readable. Here is a way to encrypt the password so that only you can read it. Anyone else running the same...
  • Lessons Learned

    Lenovo W530 and the Context Menu Key

    • 4 Comments

    Newer-model Lenovo laptops have done away with the context menu key (a.k.a. the "right click" key) in favour of the Print Screen key.  For those who use and miss the context menu key, here's a way to remap it back. 

    ...
  • Lessons Learned

    Converting PsCustomObject To/From Hashtables

    • 3 Comments

    Functions to converting Hashtables to PsCustomObjects and vice versa (losing all PsCustomObject class members that are not properties such as noteproperty).

    ...
  • Lessons Learned

    Number of Processors vs. Number of Cores

    • 3 Comments
    In this day of multicore, multiprocessor systemboards, licensing becomes a little more complicated. Some packages are licensed per core, others per processor. Still others are licensed per n cores per processor. At any rate, Win32_Processor doesn't return...
  • Lessons Learned

    Is .Net 3.5 Installed?

    • 2 Comments
    A quick-and-dirty way to determine if .NET 3.5SP1 is installed. $path = "\\$myComputer\c$\windows\Microsoft.NET\Framework\v3.5\csc.exe"; if((Get-WmiObject -ComputerName $myComputer -Query "select * from Win32_OperatingSystem").OsArchitecture -eq '64...
  • Lessons Learned

    Is Oracle WebLogic10 Installed?

    • 2 Comments
    We have a handful of boxes running WebLogic10 so it's not part of the base image. Here's a quick way to determine if it's installed. $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $myComputer); $subKey= "SOFTWARE\Microsoft...
  • Lessons Learned

    PowerShell for Non-N00bs: How Much is That Character in the Window? (Or, How to Change Your Password Without Really Trying)

    • 2 Comments
    To review, we learned a few things: 1) How to inspect a non-printing character that is fouling things up. 2) How to use cmdkey.exe to update cached credentials for Remote Desktop. 3) [byte][char] is a long way to say ord(). 4) When the PowerShell team said, "Saving the world, one one-liner at a time," they didn't limit themselves to 80 characters....
  • Lessons Learned

    Tech Tips: Command Prompt++ - the console.exe tool

    • 2 Comments
    Enter console.exe, found at http://sourceforge.net/projects/console/. To be accurate, the project is actually named 'Console 2.0', explicitly called out here for search engine indexing. It provides a modern terminal interface, and allows other shells to be hosted, such as cmd.exe (default), PowerShell, and CygWin *sh....
  • Lessons Learned

    PowerShell One-Liner: Decrypt-SecureString

    • 2 Comments
    PSH> [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($securestring)) ...
  • Lessons Learned

    One-Liner: Setting Default Web Proxy for Windows Server 2003 and 2008

    • 2 Comments
    CMD> proxycfg.exe proxy.fqdn *.first.excluded.domain;*.second.excluded.domain;*.and.so.forth CMD> netsh.exe winhttp set proxy proxy-server="proxy.fqdn" bypass-list="*.first.excluded.domain;*.second.excluded.domain;*.and.so.forth" ...
  • Lessons Learned

    One-Liner: GetDateTimeFormats

    • 2 Comments
    DateTime objects are amazing. They come with a boatload formats pre-defined. But which is which?...
  • Lessons Learned

    RDCman Config Files (*.rdg)

    • 2 Comments
    RDCMan is a godsend if you have to jump on multiple machines. It's a wrapper for mstsc.exe, the venerable Remote Desktop Protocol client. It allows you to create trees of server groups (though groups and servers cannot branch from the same node, be warned...
  • Lessons Learned

    AppWiz.cpl in PowerShell

    • 2 Comments

    Querying the registry for installed programs remotely

    ...
  • Lessons Learned

    Meatball Surgery, the Taskbar, Toolbars, and You

    • 2 Comments
    It takes me a while, but when I get used to something, I hate to change.  Windows 7 introduced the new Taskbar, and I hate it.  I hate having to click or hover over a ‘stack’ PSH windows to select one. I prefer the old XP (rest in peace) way...
  • Lessons Learned

    Drive-by: PowerGUI Visual Studio Extension

    • 1 Comments

    Use Adam Driscoll's PowerGUI Visual Studio Extension with VS2013.

    ...
  • Lessons Learned

    I Never MetaCharacter (I Didn’t Like)

    • 1 Comments
    Lame title jokes aside, a metacharacter is a character that describes other characters. Put together, they form Regular Expressions. Regular expressions are used for string matching, which is a less threatening way of saying parsing . Basically, with...
  • Lessons Learned

    Function Skeleton for Invoke-Command –AsJob

    • 1 Comments
    PSRemoting jobs are quite amazing. While they are a little complicated to grasp at first, they’re quite powerful. However, with great power usually comes great responsibility. We know we can spawn a gazillion jobs, but how about managing them? How...
  • Lessons Learned

    Scripting Best Practices, or Write-Host Considered Harmful

    • 1 Comments
    Disclaimer: this is going to sound like I actually know what I’m doing.  Let’s be honest – I work in Microsoft, home to the people who created PSH, .NET, and the native internals that people invoke with Add-Type and other arcane arts.  There...
  • Lessons Learned

    Something I Should Have Done a While Ago: $continue

    • 1 Comments
    $ErrorActionPreference is your friend.  However, ‘SilentlyContine’ isn’t, especially when it’s misspelled as is this case.  If we could Tab-complete it, that’d be great. Hey…. I’ve added this to my $PROFILE (actually my CommonFunctionLibrary...
  • Lessons Learned

    Remotely Logging off RDP Sessions

    • 1 Comments
    In our lab, we don't have Terminal Services Licensing set up. This means our servers have only 2 logon sessions per host. We have a GPO in place to log off non-console sessions after 24 hours of idle time, but we also have tradition of playfully chiding...
  • Lessons Learned

    PSH V1 or V2?

    • 1 Comments
    My lab has some machines that are only running PSH v1 (for reasons outside the scope of this article.) The easiest way is to try to run something that exists on V2, such as "import-module". However, the progamatic way is to get the ProductVersion property...
  • Lessons Learned

    Getting Objects Out of AD

    • 1 Comments
    This is dsquery.exe computer -name <foo> function Get-ComputerObjects { param ( [string] $name = "*" ); $directorySearcher = new-object DirectoryServices.DirectorySearcher([ADSI] "LDAP://$env:userDnsDomain" ); $directorySearcher .PageSize...
  • Lessons Learned

    Importing and Removing Certificates

    • 1 Comments
    We knew it had to come to this. All these posts about examining .cer files, scanning for certificates being served on :443, and auditing the LocalComputer\My certificate store. We knew there had to come a time when we programmatically import and remove...
  • Lessons Learned

    Sanity-Checking RDG Files

    • 1 Comments
    Remote Desktop Connection Manager is a must-have tool. However, it too easily falls out of date. Depending on your environment, you might be spinning up new machines regularly, especially if you’re in a virtualized environment. Here’s a quick...
Page 1 of 8 (199 items) 12345»