Lessons Learned

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

Browse by Tags

Tagged Content List
  • Blog Post: Send-Keys

    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--etc-wind/ Specifically, it now tests the current...
  • Blog Post: Querying WMI with a Timeout

    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.     #>       param (        ...
  • Blog Post: Reinventing the Wheel: Get-WmiChildNamespace and Get-WmiChildPropertyData

    I love and hate WMI.  I love how it offers the ability to access so many parts of the OS that PowerShell has not (yet) exposed via cmdlet.  I hate how the taxonomy is so deep, how you need to know what you’re looking for to find it. Also, I’ve been having a hard time differentiating between...
  • Blog Post: PowerShell One-Liner: Getting This Computer's Asset Tag Number

    Here's a gem from an internal email: CMD> wmic SystemEnclosure get SMBIOSAssetTag 5551212 If the system has asset tag data added to the BIOS, this is a way to collect it.
  • Blog Post: PowerShell for Non-N00bs: System Uptime Via WMI

    Getting the last time a system was rebooting is pretty easy from WMI. From this half-decade old post , we get the two key bits: the LastBootUptTimem property of the Win32_OperatingSystem WMI class. In PowerShell, it looks like this: PSH> (Get-WmiObject -Query 'SELECT LastBootUpTime FROM Win32_OperatingSystem...
  • Blog Post: One-Liner: Getting This Computer's Serial Number

    The computer's serial number can be very useful. Among other things, many manufactuers' support sites keep record of their machine's serial numbers to serve the right drivers for downloads. CMD> wmic bios get serialnumber SerialNumber ABCDEF12345 Wmic is the command line executable for performing...
  • Blog Post: PowerShell One-Liner: Hardware SKU

    Someone asked me what kind of server I was running in the lab. Uh, I don't have lab access, and even if I do, how the heck would I find it? PS> Get-WmiObject Win32_ComputerSystem | fl Domain : testlab Manufacturer : HP Model : ProLiant DL380 G4 Name : testlab1234 PrimaryOwnerName : TotalPhysicalMemory...
Page 1 of 1 (7 items)