PowerCLI: Adding New PortGroups

I’m sure that someone somewhere has written a script exactly like this in the past but I wanted to write my own for a number of reasons. While I’ll probably never be a PowerCLI hero, it really doesn’t hurt to keep in practice and hone your skills.

Let’s start with what I want to accomplish. I’m working with an ESX 3.5 web hosting environment and there’s a new project in the pipelines. A brace of new servers are required and they’ll be on a new VLAN. The VLAN has been created and configured on the various switches that the ESX hosts connect to but now of course a corresponding PortGroup is required. (Actually two are needed – complex project.) Now we’re not talking about a huge number of hosts here. It would probably only take 10 minutes to do it by hand using the VI client. It’ll take me longer to write this post! However, it is something that happens relatively often in this environment so it’s worth taking the time to write a script. (more…)

Read More

Which VMs are in which Port Groups

This took me a little while to get sorted as I had a gap in my PowerShell knowledge around the handling and formating of nested objects. A bit of exploration with get-member and I came up witha working script. It’s based on a post by Hugo Peeters and lists the VMs that are connected to (or belong to) a particular Port Group.

I wanted to know this as I was producing some infrastructure diagrams for a customer and wanted to know the names of VMs in a cluster for each Port Group without having to visit each ESX server. (more…)

Read More

Remote Shutdown with PowerShell

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 […]

Read More