The other day I came across a PowerShell question on StackOverflow about testing if a service was running on a group of machines.This sparked an idea for a tool to “ping” a service, in much the same way we ping a computer to see if it is up and running, or at least reachable. It…
Tag: Scripting
Export and Import Hash Tables
I use hash tables quite a bit and with the impending arrival of PowerShell 3.0 I expect even more so. PowerShell v3 allows you to define a hash table of default parameter values. I’m not going to to cover that feature specifically, but it made me realize I needed a better way to export a…
Maximizing the PowerShell Console Title Bar
A few days ago Boe Prox posted some very nifty PowerShell modules for using the title bar as a ticker for RSS feeds like the weather. I thought this was an awesome idea and an easy way to take advantage of what would otherwise be unused screen space. I was especially intrigued with his use…
Friday Fun Get Content Words
Recently I was tracking down a bug in script for a client. The problem turned out to be a simple typo. I could have easily avoided that by using Set-StrictMode, which I do now, but that’s not what this is about. What I realized I wanted was a way to look at all the for…
Using Types with Imported CSV Data in PowerShell
The Import-CSV cmdlet in PowerShell is incredibly useful. You can take any CSV file and pump objects to the pipeline. The cmdlet uses the CSV header as properties for the custom object. PS S:\> import-csv .\testdata.csv Date : 1/18/2012 6:45:30 AM Name : Data_1 Service : ALG Key : 1 Size : 25 Date :…
Convert Text to Object Updated
I’ve had a few comments and emails lately about my post and script on converting text to objects. I decided the function needed a little more lovin’ so today I have an updated version, complete with comment based help. Function Convert-TextToObject { tasklist /s server01 /fo list | where {$_} | convert-texttoobject -group 5 Take…
The PowerShell Morning Report
I love how easy it is to manage computers with Windows PowerShell. It is a great reporting tool, but often I find people getting locked into one approach. I’m a big believer in flexibility and re-use and using objects in the pipeline wherever I can. So I put together a PowerShell script that I can…
Add WhatIf Support to Your PowerShell Scripts
In one of my recent articles for SMB IT, I included a PowerShell module. In the article I referenced that I included support for -Whatif in one of the functions. I was asked on Twitter to explain what I meant and how it works. So here goes.
Friday Fun – Get Number Object
You most likely know that I’m all about the object and the PowerShell pipeline. Everything in PowerShell is an object. Pipe something to Get-Member and you can discover all of the object’s properties and methods (ie its members). Some objects, like strings, have many methods but very few properties. Some objects, like numbers have very…
Turning IPConfig DNSCache into PowerShell
Lately I’ve been writing about techniques to turn command line tools into PowerShell tools. Although I suppose the more accurate description is turning command line output into PowerShell pipelined output. The goal is to run a command line tool and write objects to the PowerShell pipeline so I can do other operations with them. Today…
ForEach or ForEach-Object
I came across a post the other day that explained differences when using the ForEach enumerator and the ForEach-Object cmdlet. They both essentially do the same thing but as the post mentions there are potential performance differences. One other difference I want to highlight is that the ForEach enumerator doesn’t write to the pipeline at…
Ping IP Range
Last week I came across a post on using PowerShell, or more specifically a .NET Framework class, to ping a range of computers in an IP subnet. The original post by Thomas Maurer is here. I added a comment. And after looking at this again I decided to take the ball and run with it…
Export Registry Printer Information I came…
Export Registry Printer Information I came across this post http://www.oncallpros.com/2011/11/02/powershell-export-your-print-configuration-from-registry/ on exporting printer information from the registry in PowerShell. I wanted to offer some constructive suggestions but could find no way to comment so I'll do so here. First, the article introduces some good PowerShell concepts. I like that he is using Test-Path. Although I'd…
Convert Text to Object
Today I have another tool in my new battle regarding turning command line tools into PowerShell tools. The bottom line is we want to have objects written to the pipeline. At the PowerShell Deep Dive in Frankfurt there was a suggestion about providing tools to help with the transformation from CLI to PowerShell and this…