Lessons Learned

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

Posts
  • Lessons Learned

    Getting OCS 2007 Certs through WMI Revisited

    • 0 Comments
    Back in August 2012 , I posted about getting certificates bound to Office Communication Server 2007 interfaces using PSExec.  As much as I respect MarkRuss and SysInternals, PSExec is quite fiddly.  We have PSH V2 in our lab (finally!), so a...
  • Lessons Learned

    Number of Processors vs. Number of Cores Revisited

    • 0 Comments
    Back in July 2011, I posted about getting the number of processors and cores and gave passing mention of the fact that there’s a known issue with PSH and some versions of Windows.  Well, PSH V3 now has the NumberOfLogicalProcessors property in the...
  • Lessons Learned

    Certificate Chains

    • 0 Comments
    I seem to spend a lot of time typing about SSL certificates, don’t I? Well, I seem to spend a lot of time auditing certificates at work. In this case, we’re updating certs because we’re migrating from one Root CA to another. Why? I have...
  • Lessons Learned

    Hack(saw)ing the Surface Pro

    • 0 Comments
    I'm taking a break from PowerShell goodness to brag about my new MS Surface Pro. It's an amazing piece of engineering. It's small, it's light, it's ... It's very steal-able. Sadly, Microsoft (disclaimer: I work for them, but that's pretty much a...
  • 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

    Futzing With System Variables

    • 0 Comments
    $Env:PATH is a common bane - you have a hundred machines, and you end up with fifty different $Env:PATH values.  Here's a quick way to audit them, and to set them remotely.  But be careful: just like with superpowers, this comes with great responsibility...
  • Lessons Learned

    Stopping Services Remotely and Recursively (But Without Recursion)

    • 0 Comments
    This one is actually fun because it reminded me of my Comp Sci. 101 days (the actual course number was 53A, but the point is the same: basic algorithms.)  Here, I have an n -deep tree that I must consume leaf-first.  Specifically, I want to...
  • Lessons Learned

    Adding a Timestamp to a Pipeline of Strings

    • 0 Comments

    If I'm doing something long-running, and I want it to know when various lines of output are generated, assuming they are being sent to STDOUT (something PSH is NOT good at), here's a quick way to preface the output with a timestamp.

    ...
  • Lessons Learned

    Batch-Getting BIOS Serial Numbers

    • 0 Comments
    Our lab maps hosts to KVM Ports based on, not hostname, not IP address, but the BIOS Serial Number. Like the last post, this is probably overkill on (Get-WmiObject -ComputerName $ComputerName Win32_BIOS).SerialNumber, but it's probably useful.  Possibly...
  • Lessons Learned

    Batch-Getting IP Addresses

    • 0 Comments
    Let's say you have a list of hostnames and need IP addresses for them. "You have a list of hostnames..." Very funny.  This is probably overkill on what is simply [System.Net.Dns]::GetHostEntry($ComputerName).AddressList.  Still, it...
  • Lessons Learned

    When Were These Computers Last Rebooted?

    • 0 Comments
    Here's a short one.  We want to know when this box was last rebooted.  Sure, it's in the SCOM DB, but this is probably faster. The Win32_OperatingSystem WMI object contains the LastBootupTime attribute.  Beyond that, it's a simple matter...
  • Lessons Learned

    Removing Monitoring Agents (Not Really)

    • 0 Comments
    Thanks to my coworker Keith Munson for the core logic. This post is written around the task of removing SCOM and MOM monitoring agents, but those rely on knowing the agent’s MSI installer’s GUID. The easiest way to get that is to...
  • Lessons Learned

    Getting Computer Memory Usage

    • 0 Comments
    Here’s a quick spot-check on the memory usage on remote computer (or a few dozen computers).  It uses WMI objects – Win32_ComputerSystem for the TotalPhysicalMemory and Win32_OperatingSystem for FreePhysicalMemory, TotalVirtualMemorySize (why did...
  • Lessons Learned

    Fun with PSCredentials

    • 0 Comments
    Back in October of 2012, I posted Securely Storing a Password , which showed the key commands to capture a password and store it as a SecureString in a file. However, this doesn’t address using that password as a PSCredential. Let’s remedy...
  • 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

    AppWiz.cpl in PowerShell

    • 2 Comments

    Querying the registry for installed programs remotely

    ...
  • Lessons Learned

    PSH V1 Get-Tail

    • 0 Comments
    In PSH V2, Get-Content –Tail 10 –Wait will display the last 10 lines of a file, then poll it every second and display any additions to it. In PSH V1, Get-Content didn’t have a –Tail flag, so if you wanted to do the equivalent of...
  • Lessons Learned

    Get-FileVersion

    • 0 Comments
    With an endless stream of daily builds, it is essential that a test lab run the latest version.  PS C:\Users\timdunn> dir C:\Windows\System32\*.dll | Get-FileVersion | more Path                                                       ...
  • Lessons Learned

    Getting An SSL Web Page’s Certificate

    • 0 Comments

    When it comes time to rolling SSL certificates on web servers, nothing beats checking the server to see what is actually being served.

    ...
  • Lessons Learned

    SQL Fun(ctions)

    • 0 Comments

    To start with, a disclaimer: I’m not a SQL person.  No, not at all.  I just find myself supporting services that use MSSQL as a backend.  Here are a few functions I’ve recently written to help keep my sanity.

    ...
  • Lessons Learned

    Removing Null Values

    • 0 Comments
    How many times have you gotten a WMI-Object and had to scroll through screens of null values? Here's a quick way to generate a new PSCustomObject that has those values removed. Note that this is NOT the same object type as the input object, and it does...
  • Lessons Learned

    Another Way to Create NoteProperty Entries

    • 0 Comments
    We've seen the Select-Object synthetic property method and the Add-Member -name AddNoteProperty method, but here's probably the most straightforward way to output object data. $object = $true | Select ComputerName, Path, ContentCount; $object.ComputerName...
  • 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

    Why Semi-Colons?

    • 0 Comments
    Sorry, no code here. Just a quick thought. Q: Why should I put semi-colons at the end of lines? PowerShell is smart enough to parse EOL as command terminators. A: Because some blogs are stupid and strip linefeeds. That means you get a single line...
  • Lessons Learned

    Laziness and XML: New-XmlElement

    • 0 Comments
    I love structured data. I love how orderly it is, how logical. However, I do not like the repetition. Get the OwnerDoc. Create an Element. Loop over a bunch of AddAttribute calls, AppendChild it someplace. 90% of the time, this is how I build my XML structure...
Page 5 of 9 (215 items) «34567»