PowerShell
VI Toolkit 1.5 Released
Jan 28th
Just as I was getting to grips with PowerShell and the VI Toolkit 1.0, out pops a new version.
Don’t get me wrong, I’m not complaining – I’m downloading!
See the release blog entry here.
Draw your VI in Visio with vDiagram
Jan 26th
Alan Renouf is a busy man and always seems to be one step ahead of the game. This is certainly true of his latest creation – vDiagram.
Many of you may be familiar with the Active Directory Topology Diagrammer (ADTD), a tool available from Microsoft that pulls information from Active Directory and draws it in a Visio diagram. The diagrams that it produces can save a lot of effort in technical documentation and the same sort of thing has been missing for Virtual Infrasructure for some time.
Alan’s PowerShell script requires only PowerShell and Microsoft Visio 2003+ to produce a nice Visio diagram of your VI. Head on over to Alan’s site to download it and try it out.
Remote Shutdown with PowerShell
Jan 13th
Here’s the scenario: You’ve just hit shut down in your remote desktop session. You’re logged off Windows Server 2003 and your RDP session is closed. You wait a while and try to login again. Surely the server must have rebooted by now. But try as you might, you cannot get back in. Port 3389 shows as open and the IP is pingable.
So the options are:
1. Dig out iLO credentials (assuming that it is installed / setup) and force a reboot from a remote console.
2. Walk over to the server and force a reboot (the most recent time this has happenned to me, the server was in another building and it was raining heavily).
3. Use conventional Windows management tools to shut the server down remotely.
4. Use PowerShell.
This last option is the one that we’re going to opt for. We’re going to use the Win32_OperatingSystem WMI class to do this. Specifically we’ll be using the Win32Shutdown method.
The method takes a single flag value to determine exactly what should be done.
0 = Log off
4 = Forced log off
1 = Shutdown
5 = Forced shutdown
2 = Reboot
6 = Forced reboot
8 = Power off
12 = Forced power off
The full code for invoking the method is:
(Get-WmiObject -Class Win32_OperatingSystem -ComputerName MyComputer).InvokeMethod("Win32Shutdown",0)
From now on I’ll use aliases. Here are a couple of examples:
Log off the local computer:
(gwmi Win32_OperatingSystem).Win32Shutdown(0)
Restart a remote computer:
(gwmi win32_operatingsystem -ComputerName MyComputer).Win32Shutdown(6)
Restart a remote computer using alternate credentials:
(gwmi win32_operatingsystem -ComputerName MyComputer -cred (get-credential)).Win32Shutdown(6)
