Lessons Learned

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

Posts
  • 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

    ...
  • Lessons Learned

    Quick and Dirty Help

    • 0 Comments
    I like writing help text for my scripts. Yes, PSH V2 allows Get-Help to parse the inline help in scripts, but I'm stuck in V1 for my production environment. For quick-and-dirty scripts where I don't want to implement a 'real' help subsystem, I use the...
  • Lessons Learned

    Why Use Semi-colons

    • 0 Comments
    I get asked from time to time why I still put semi-colons at the end of each statement. Part of it is force of habit. Part of it is trying to make sure my script source is useful no matter how the web server, post edtior, and user's brower decide to display...
  • Lessons Learned

    Abbreviated Key Names in Synthetic Properties

    • 0 Comments
    The title is almost longer than the post. From Chris Dent's http://www.indented.co.uk/index.php/2010/01/12/powershell-iis-and-log-settings/ , I see that he's generating synthetic properties with Select-Object -Property @{n = 'name'; e = { "this...
  • Lessons Learned

    A Loop of One

    • 0 Comments
    Of late, I've been seeing some of my scripts do this: if (!(Test-Path file1)) { Write-Warning "File1 not found."; } else { do-something if (!(Test-Something)) { Write-Warning "Test-Something failed"; } else { do-something -part 2 if (!(Test-Something...
  • Lessons Learned

    PowerShell and IIS Logs

    • 0 Comments
    This is more of a pointer than an actual article. Chris Dent at www.intended.co.uk has a great post on getting IIS log settings from hosts here: http://www.indented.co.uk/index.php/2010/01/12/powershell-iis-and-log-settings/ The best part is how...
  • 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

    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

    XPath and attribute value strings

    • 0 Comments
    Quick note for my future reference - XPath1.0 evidently doesn't support wildcards nor regular expressions, but does have functions such as 'starts-with', 'contains', etc. $xml.SelectNodes("//nodeName[contains(@attribute, 'substring')]"); http:/...
  • Lessons Learned

    Scanning for Binaries and Version

    • 0 Comments
    I need to list the binaries installed to a folder and below for the software I’m testing. I can do that with Get-Command on each one, but this allows me to do it recursively and automagically. function Get-LocalBinaries { param ( [string[]] ...
  • Lessons Learned

    Testing a Port

    • 0 Comments
    Load blancers are great, but we don't get iAdmin access to them, so the only way we know if a host is down is to visually scan the web UI. And for whichever EIEIO security standard, we have two-factor auth which times out after a very aggressive interval...
Page 6 of 9 (212 items) «45678»