Lessons Learned

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

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

    Out-Error, the User-friendlier Write-Error

    • 0 Comments
    Write-Error is a pretty daunting cmdlet. It dumps some pretty useful information to screen. Useful, that is, for the scripter. For the non-PowerShell-guru end user, it can be pretty intimidating. Write-Host -ForegroundColor Red might be a better...
  • Lessons Learned

    One-Liner: Dotting in vs. Running a Script

    • 0 Comments
    PowerShell scripts are a collection of functions and procedural code, right? So often, I find myself wishing I had a function defined in a script in my interactive session, but the script doesn't lend itself to being dotted into the environment. if...
  • Lessons Learned

    Getting OCS 2007 Certs through WMI

    • 0 Comments
    We recently had an interesting adventure where we needed to do an audit of the certificates used by various OCS servers. In this case, scanning the computer's cert store wasn't sufficient - we needed to see which cert was bound to what interface. The...
  • Lessons Learned

    Creating a Multi-Host Cert MMC

    • 0 Comments
    MMCs are a mixed blessing at best. The saved .msc files aren't human-editable (read: not XML) so I don't have an easy way to create them. In this case, I need to perform a cert audit on all the machine certs in a lab. PowerShell eschews 'parsing by prayer...
  • Lessons Learned

    Dumping ILO (and Other DHCP Addresses)

    • 0 Comments
    Here's a quick-n-dirty script that dumps ILO address from the DHCP server. function Get-Ilo { param ( [ string ] $computer = $env:COMPUTERNAME ); $scope = (netsh.exe dhcp server \\$computer show scope | Select-String 'ilo' ) -replace "\s+-.*" -replace...
  • Lessons Learned

    RSA Authentication Manager User Auditing

    • 0 Comments

    RSA Authentication Manager exports the list of users and SecurID fobs in a text format with multiline records.  Moreover, if the user does not have a SecurID, the number of fields displayed is truncated.  Fortunately, .CSV will gladly accept 'short' records.  Here is a way to convert the User.DMP file that lists all users in the RSA Authentication Manager DB, and their fobs if present.

    ...
  • Lessons Learned

    Clock Skew and You

    • 0 Comments
    We had an issue where the clocks on various hosts got offset beyond the margin allowed by an application we were testing. Here's a way to scan hosts for their clock skew relative to a known good server: function Get-RemoteTime { param ( [ String [...
  • Lessons Learned

    Set-ExecutionPolicy Fun

    • 0 Comments
    Hm, I'm surprised this isn't included Out-Of-The-Box. Let's say I have a new deployment of machines and I need to set the ExecutionPolicy for each of them. Now, assuming I'm a domain admin, I should be able to do it remotely: Function Enable-PowerShell...
  • Lessons Learned

    Accessing Performance Counter (for OCS A/V Edge Servers)

    • 0 Comments
    OCS A/V Edge servers are somewhat wierd critters. One interface is load balanced, the other is accessed only by the trusted server list. The Load Balancer should be able to display the number of connections, but what about the internal interface? Say...
  • Lessons Learned

    Batch-Unzipping Files

    • 0 Comments
    Thanks to http://serverfault.com/questions/18872/how-to-zip-unzip-files-in-powershell/201604#201604 for the core code. Here's a function to unzip files, with rudimentary error handling, and ability to specify source and destination from the command...
  • Lessons Learned

    Displaying an OCS Proxy Server's List of Trusted Servers

    • 0 Comments
    Yesterday, we covered how to dump an OCS Edge Server's list of trusted servers, including using PSExec.exe as a workaround to it not exposing the list over remote WMI calls. It turns out the OCS Proxy Server uses a different WMI path, but it can be...
  • Lessons Learned

    Displaying an OCS Access Edge Server's List of Trusted Servers

    • 0 Comments
    Office Communications Server's Access Edge Servers and MediaRelay roles have a list of hosts they allow to connect on the internal interface. This is managed by the an administrative GUI accessed under ComputerManagement. GUIs are great for discoverability...
  • Lessons Learned

    Certificates Owned by a Service

    • 0 Comments
    PowerShell gives you access to certificates in many ways. You can read it in from a file, or look at it via the certificate: PsProvider, or, use .NET to open [System.Microsoft.Win32.RegistryKey] object. However, these don't tell the whole story. It turns...
  • Lessons Learned

    Hash to Arrayof Objects

    • 0 Comments
    As an old-time Perl user, I love hashes. In Perl, hashes are the answer, no matter what the question is. (No, not really, but they solve a lot of problems.) In PowerShell, hashes are cool, but you can't do things like "Sort-Object -property value". ...
  • Lessons Learned

    Propagating Default Options

    • 0 Comments
    Let's say I have a function that takes parameters, which all well-written ones should. And they have intelligent defaults, again as well-written ones should. The outer script exposes those parameters via the outer param() statement, but how do I pass...
  • Lessons Learned

    No Reply All

    • 0 Comments
    Short form: Go here http://research.microsoft.com/en-us/projects/researchdesktop/noreplyall.aspx Longer form: Outlook/Exchange, like so many other products, has some 'undocumented features', including a one-bit flag that allows reply-all or not. This...
  • Lessons Learned

    Heavyweight Help in V1

    • 0 Comments
    Again, in V1 PSH, this is what I use for nicely formatted help. If you're on V2, by all means, use the inline help, PLEASE! function Break-Line { # synopsis:: # [-help] # # Description:: # Inserts linefeeds into strings read from STDIN so they wrap...
  • Lessons Learned

    Getting Remote Event Logs

    • 1 Comments

    Quick and dirty wrapper for LogParser to download Event Logs

    ...
Page 6 of 9 (222 items) «45678»