Condividi tramite


Lessons Learned

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

Hash to Arrayof Objects

As an old-time Perl user, I love hashes. In Perl, hashes are the answer, no matter what the question...

Author: timdunn Date: 10/31/2011

Propagating Default Options

Let's say I have a function that takes parameters, which all well-written ones should. And they have...

Author: timdunn Date: 10/18/2011

No Reply All

Short form: Go here https://research.microsoft.com/en-us/projects/researchdesktop/noreplyall.aspx...

Author: timdunn Date: 10/11/2011

Heavyweight Help in V1

Again, in V1 PSH, this is what I use for nicely formatted help. If you're on V2, by all means, use...

Author: timdunn Date: 10/10/2011

Quick and Dirty Help

I like writing help text for my scripts. Yes, PSH V2 allows Get-Help to parse the inline help in...

Author: timdunn Date: 10/06/2011

Getting Remote Event Logs

Here's a quick-and dirty script to save event logs via LogParser. function Get-RemoteEventLog { ##...

Author: timdunn Date: 10/06/2011

Why Use Semi-colons

I get asked from time to time why I still put semi-colons at the end of each statement. Part of it...

Author: timdunn Date: 07/28/2011

Abbreviated Key Names in Synthetic Properties

The title is almost longer than the post. From Chris Dent's...

Author: timdunn Date: 07/27/2011

A Loop of One

Of late, I've been seeing some of my scripts do this: if (!(Test-Path file1)) { Write-Warning "File1...

Author: timdunn Date: 07/26/2011

PowerShell and IIS Logs

This is more of a pointer than an actual article. Chris Dent at www.intended.co.uk has a great post...

Author: timdunn Date: 07/25/2011

Getting Objects Out of AD

This is dsquery.exe computer -name <foo> function Get-ComputerObjects { param(...

Author: timdunn Date: 07/22/2011

PSH V1 or V2?

My lab has some machines that are only running PSH v1 (for reasons outside the scope of this...

Author: timdunn Date: 07/21/2011

XPath and attribute value strings

Quick note for my future reference - XPath1.0 evidently doesn't support wildcards nor regular...

Author: timdunn Date: 07/20/2011

Scanning for Binaries and Version

I need to list the binaries installed to a folder and below for the software I’m testing. I...

Author: timdunn Date: 07/19/2011

Testing a Port

Load blancers are great, but we don't get iAdmin access to them, so the only way we know if a host...

Author: timdunn Date: 07/18/2011

Ignoring SSL Certificate Errors with WebClient

First off, credit where credit's due. The incomparable Lee Holmes first tackled this in his blog:...

Author: timdunn Date: 07/15/2011

"Manage Your Server" Welcome Screen

Yeah, I'm still running 2003. In fact, I'm still asking the lab admins to build out new 2003 boxes....

Author: timdunn Date: 07/14/2011

Remotely Logging off RDP Sessions

In our lab, we don't have Terminal Services Licensing set up. This means our servers have only 2...

Author: timdunn Date: 07/13/2011

Don't Do This: PSExec'ing a Batch Script Containing a PowerShell Script

This is just broken, but broken times call for broken measures. I'm stuck on PSH V1 for reasons best...

Author: timdunn Date: 07/11/2011

PowerShell for Unix's "data | sort | uniq -c" and "sort -u"

Sometimes we need a list of data values and their frequency. Other times, we need a unique listing...

Author: timdunn Date: 07/08/2011

Number of Processors vs. Number of Cores

In this day of multicore, multiprocessor systemboards, licensing becomes a little more complicated....

Author: timdunn Date: 07/07/2011

Is Oracle WebLogic10 Installed?

We have a handful of boxes running WebLogic10 so it's not part of the base image. Here's a quick way...

Author: timdunn Date: 07/06/2011

Test if IIS6 installed and .NET 2.0 Registered?

Easier question first: is IIS installed? $reg =...

Author: timdunn Date: 07/05/2011

Is East Asian Langauges Pack Installed?

(Note: This is relevant only for XP and prior, which our lab still has.) If we test for...

Author: timdunn Date: 07/01/2011

Is .Net 3.5 Installed?

A quick-and-dirty way to determine if .NET 3.5SP1 is installed. $path =...

Author: timdunn Date: 06/30/2011

Is NetBIOS over TCP/IP Enabled?

As anyone who has typed 'ipconfig /all' knows, Windows has a lot of pesudo- and otherwise irrelevant...

Author: timdunn Date: 06/29/2011

System Variables on Remote Machine

To get the $env:PATH system variable value on a remote machine. $path = Get-WmiObject -computerName...

Author: timdunn Date: 06/28/2011

Stupid PSH Trick: Diffing Lists

I have two lists of strings. One contains values that must be in the output. The other is the actual...

Author: timdunn Date: 06/27/2011

My Way of Logging Problems: Log-Problem

Write-Error is fine, but there's no way to capture it in redirect. This means that a script peppered...

Author: timdunn Date: 06/24/2011

Playing with Window Size

$host isn't just for EnterNestedPrompt(). $host.UI.RawUI has some intresting data. For example,...

Author: timdunn Date: 06/23/2011

User Names, SIDs and Active Directory

Let's go backwards. We figured out how to get a user name out of a SID earlier:...

Author: timdunn Date: 06/22/2011

Auditing Forefront Endpoint Protection 2010's Exclusion List

Disclaimer: I can't be sure this works for all exclusion scenarios. My lab machines are set up to...

Author: timdunn Date: 06/21/2011

Getting Web Proxy Settings

We have a lab of hosts that have proxy exclusion lists set at various times in the lifecycle of the...

Author: timdunn Date: 06/20/2011

Stupid Tricks with REG_BINARY Registry Data

This is one of those 'duh' moments. [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('HIVE',...

Author: timdunn Date: 06/17/2011

SID, User Names, and Active Directory

More of a snippet for me to refer to later, but here's a quick way to convert a SID (Security...

Author: timdunn Date: 06/16/2011

Nicely Wrapping a Line of text to STDOUT

In case you didn't know, $host gives data about the scripting host, including the window containing...

Author: timdunn Date: 06/07/2011

PowerShell, Downloaded Scripts, and Alternate Data Streams

First off, here are the sources for this article:...

Author: timdunn Date: 06/06/2011

Pinging a Hostname with Timeout

Well, that's simple: $ping = New-Object...

Author: timdunn Date: 06/03/2011

One-Liner: GetDateTimeFormats

DateTime objects are amazing. You can format them in so many different ways, but they also come with...

Author: timdunn Date: 05/15/2010

PowerShell for Non-N00bs: LiveMeeting XML API and You

I work with Microsoft LiveMeeting regularly, and have found PowerShell's ability to interact with...

Author: timdunn Date: 05/09/2010

PowerShell for Non-N00bs: Creating Shortcuts

$shell = new-object -com wscript.shell if($name)#create shortcut in same directory { $shortcut =...

Author: timdunn Date: 05/05/2010

PowerShell Gotchas: Looping with $null

For some obscene reason, PSHv1 will gladly iterate with a $null as an array element in Foreach....

Author: timdunn Date: 03/17/2010

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

Our labs run a mix of Windows Server 2003 and 2008. Setting a proxy in Windows Server 2003 is as...

Author: timdunn Date: 10/31/2009

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...

Author: timdunn Date: 10/28/2009

PowerShell for Non-N00bs: Formatting Time With RegEx

So, last episode we learned how to format the output of a LastBootUpTime property from the...

Author: timdunn Date: 10/26/2009

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...

Author: timdunn Date: 10/24/2009

PowerShell for Non-N00bs: Adding a User to a Group (with Script)

Here's the one-liner:...

Author: timdunn Date: 10/22/2009

One-Liner: Getting This Computer's Serial Number

The computer's serial number can be very useful. Among other things, many manufactuers' support...

Author: timdunn Date: 10/19/2009

<Previous Next>