Skip to content

Tag: PowerShell

Microsoft PowerShell

PowerShell 0

Invoke-WebRequest uses id attribute of input element as field name in form fields collection

As already described on elsewhere on the Internet and on Microsoft Connect, the new Invoke-WebRequest Cmdlet, that comes with PowerShell v3, handles form fields incorrectly. Instead of referring to the name attributes of input elements within a form the Fields Collection stores the ids of the attributes under the ‘key’ property. As in the following example you see the text […]

PowerShell 0

Creating a WebClient Request from an HTTP payload

The other day I was using Fiddler to examine some web traffic to automate some tasks. I then stumbled upon a cool Fiddler extension called Request to Code (by Chad Sowald), which takes any HTTP(s) request and converts it to C# code using the System.Net.WebRequest and System.Net.WebResponse classes. Unfortunately, the extension does not support PowerShell. As I am using the […]

PowerShell 1

[Array] becomes [ArrayList] when imported via Import-CliXml

Serialising and Deserialising data structures is pretty easy when using Export-CliXml/Import-CliXml. However, there are some gotchas. In addition to the already described bug when using [ordered] hashtable in PowerShell v3 with Import-CliXml there is another error when importing [Array] with Import-CliXml: an [Array] becomes an [ArrayList]. The following code shows the problem: Again, this error seems to occur when you do […]

PowerShell 3

Get Disk Capacity of a Virtual Machine in vCloud Director via PowerCLI

With the advent of PowerCLI for vCloud Director the reasons for using vCenter Orchestrator (vCO) blur even more. VMware provides us several CmdLets that we can all find in the “VMware.VimAutomation.Cloud” snapin (“Get-Command -Module VMware.VimAutomation.Cloud”). Sure this library is by far not perfect, there is quite some functionality. However, when using the “Get-CiVm” CmdLet you will probably find out quickly […]

PowerShell 1

[ordered] hashtable becomes hashtable when imported via Import-CliXml

The new powershell feature “ordered” hashtable (a new PowerShell feature in v3. See OrderedDictionary Class) becomes an ordinary hashtable when it is imported via Import-CliXml. There is a “active” bug on Microsoft Connect OrderedDictionary becomes Hashtable when exported to and imported from clixml but no action for a couple of months. As a workaround do not use ordered hashtables but […]

PowerShell 0

Design and Coding Considerations for PowerShell

Here a few coding considerations that might make you life easer when dealing with PowerShell (but may also hold true for other programming languages): Hide unwanted return information in your code In PowerShell your functions and CmdLets return everything that is output within the function – even if you use an explicit return statement. To avoid unwanted returns from there […]

PowerShell 2

Module: biz.dfch.PS.Storebox.Api

[UPDATE 2014-11-16] The module is now available on NuGet. See below for download link. [UPDATE 2014-10-13] I split the module into separate PS1 files (one per cmdlet/function) and created a manifest for it. Now you can use a prefix and change the name of the cmdlets (the default prefix is ‘Ctera’). Here you find the PowerShell module that you can […]

PowerShell 2

Module: biz.dfch.PS.System.Logging

[UPDATE 2015-12-22] The module is now available on PowerShell Gallery. [UPDATE 2014-11-15] The module is now available on NuGet. This module allows you to have a unified logging in PowerShell and all your scripts. It depends on log4net and thus provides great flexibility on how and where you log. Basic usage is as follows: Main configuration is defined in the […]