PowerShell 0

vCO PowerShell Plugin: Import-CliXml fails with System.Security.Cryptography.CryptographicException

When using the PowerShell plugin for vCenter Orchestrator (vCO) you might receive a ‘System.Security.Cryptography.CryptographicException’ exception when using ‘Import-CliXml’ with a PSCredential object. Furthermore, you might get the message: ‘The requested operation cannot be completed. The computer must be trusted for delegation and the current user account must be configured to allow delegation’. The reason behind this seems that the security […]

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