The most exiting new product Microsoft made in recent years is Windows Powershell. Yesterday they released version 2.0 as part of the
Windows Management Framework
While Microsoft positions it as the Windows management tool every administrator must know, I find it equally useful in software development. As soon as you start using it and write Powershell scripts you’ll never go back to batch files. But besides the great scripting the shell itself make day-to-day work of a developer much easier. I often see colleagues doing this to stop a service:
- Navigate through Windows start menu to find the Services mmc snapin
- Make the MMC window bigger, because the default size is always too small
- Sroll through the services list to find the service
- Select the service
- Click the Stop button in the toolbar to stop the service.
Even if you have the services snapin already open, this is tedious. Using an already running Powershell window you just type
spsv myService
and hit enter. To work with SwyxWare services I wrote a small Powershell function returning all installed SwyxWare services called get-swyxsvc, gave it alias gsw and now can do things like this:
Stop all SwyxWare services:
gsw| spsv –force
or list all SwyxWare service with the current state
gsw | ft name, status
or list all running SwyxWare services
gsw | ? { $.state –eq “running”}
I also have scripts to update SwyxIt and SwyxWare Administration installed on my PC to the newest daily build. It does not show the usual setup wizard, but installs both without user interaction.
If you run a SwyxWare v7.0 setup MSI, you have a setup package which got built using a combination of Windows Installer XML, some old batch files and a lot of new Powershell scripts.
I just wish I had the time to build Powershell cmdlets for managing SwyxWare. Wouldn’t it be great being able doing things like this:
get-swyxwareuser | where { $_.internalnumbers –contains 4711 }
or
100 .. 199 | foreach-object { $u = new-SwyxWareUser; $u.Name = “User $_”; $u.InternalNumbers.Add($_); $u.Save() }
or
200 .. 210 | foreach-object { $u = get-swyxwareUser | where { $_.InternalNumber –contains $_}; $u.FaxNumbers.Add($_ + 100); $u.Save() }
or
get-SwyxWareTrunk –computer MySwyxServer | format-table Name, usedChannels, MaxChannels