powershell

Get-Task: ID Parameter is Case Sensitive

There aren’t many occasions when you trip up in PowerShell because of something being case sensitive, it generally doesn’t happen since most things are typically not like that. I was working with the PowerCLI cmdlet Get-Task and in particular the ID parameter to do something like: Get-Task -Id 'task-task-2035' I had originally found the ID via: Get-Task | Format-Table Name,ID -AutoSize However, I received the error that no tasks of that ID were found :

PowerCLI is now a Module!

We’ve been waiting for this a long time, but with the 6.0 release PowerCLI is now available as a module. Microsoft changed the way itself and third-parties should deliver PowerShell functionality back in PowerShell version 2 by offering modules. Previously in PowerShell version 1 additional functionality was available via snap-ins. It’s not fully there yet, but some of the functionality is now available in a module. 6.0 will be a hybrid release, with the rest to follow later.

How To Make Use Of Functions in PowerShell

Over the last few weeks I’ve had a number of comments on posts essentially asking the same question: “How do I use the functions that you publish on your blog?”. So I thought it worth making a post to refer people to, rather than trying to respond in kind to each comment. There are a number of ways it can be done depending on your requirements and they are listed below.

Improving the PowerShell ISE Experience with ISESteroids 2

For a long time I’ve used the built-in to Windows, PowerShell ISE for my PowerShell scripting experience. Most people tend to have a particular favourite editor for their coding, usually after trialling out a few different ones. For pretty much everything else I’ve settled on Sublime Text, but for PowerShell I use the ISE since I really like the integration with the PowerShell console. The ISE was introduced in PowerShell 2.

Automating Disk Zeroing on VM Deletion

A requirement for a project I had was to zero the VMDK of all VM disks at the time of VM removal. One consideration was to SSH into the host where the VM was located and use vmkfstools like the below on each vmdk to zero the disk. vmkfstools –w /vmfs/volumes/<…>.vmdk Looking for alternatives I found that the PowerCLI cmdlet Set-HardDisk has a ZeroOut parameter. Note the text from the help (version 5.

Calling PowerShell.exe -Command ScriptName and Parameters with Commas

Bit of an obscure one this, but I hit it recently and wasted some time on it so I thought it might be useful for someone, somewhere, someday. If you need to call a PowerShell script via a command line style prompt (maybe in a scheduled task or an external system like vCenter Orchestrator) there are a number of different options. I was troubleshooting a problem where an existing system was failing with a command along the lines of this:

Start-Transcript Now Available in the PowerShell ISE in PowerShell v5

*Warning. This article was written using the September 2014 PowerShell v5 Preview* Prior to PowerShell v5 it was not possible to use Start-Transcript in the PowerShell ISE, it could only be used in the standard PowerShell console. You would receive the error: Start-Transcript : This host does not support transcription. (There were alternatives to get round it , and here) Now in PowerShell v5 it can be used natively: Start-Transcript -Path C:\\Test\\Transcript.

Getting Zippy with PowerShell v5

*Warning. This article was written using the September 2014 PowerShell v5 Preview* (OK, I was really looking for an excuse to use the below picture in a blog post) One of the most popular and long standing requests for PowerShell is native support for working with Zip files. With PowerShell v5 we get two new cmdlets Compress-Archive and and Expand-Archive. Here’s a couple of examples of how they work. Compress-Archive

Setting Static Routes with PowerShell when connecting to a PPTP VPN

Sometimes as a consultant I have a need to connect to customer or client networks to carry out some of the work. This typically involves a myriad of different remote connection and VPN style systems. Some are better than others and while it’s possible to use different VMs to connect to them, that’s not always practical. Typically I only want traffic destined for the remote system(s) to go down the VPN, not all of my Internet traffic.

Automating vCAC Tenant Creation with vCO: Part 3 Install the vCAC plugin for vCO

In this series we will see how to automate the creation of a tenant in vCAC using vCO. There are multiple tasks to provision a tenant in vCAC, so even though it is an automation product itself, there’s no reason why you shouldn’t look at automating parts of it too. In part 3 we look at installing the vCAC plugin for vCO Navigate to the Configuration webpage, in my case https://localhost:8283/