*****Warning. This is from a preview release******
When using a hashtable in PowerShell v2 the insertion order is not preserved. So I might be slightly OCD, but this bugs me:
$HashTableOld = @{a=1; b=2; c=3; d=4} $HashTableOld If you consider the type of the object you will see that it is of .NET type System.Collections.Hashtable
$HashTableOld | Get-Member In PowerShell v3 it is now possible to create an ordered hashtable using the [ordered] syntax
*****Warning. This is from a preview release******
PowerShell v2 brought the ability to create a custom object via the following method:
$CustomObject1 = New-Object psobject -Property @{a=1; b=2; c=3; d=4} $CustomObject1 | Format-List PowerShell v3 brings the possibility to create a custom object via
[pscustomobject]
$CustomObject2 = \[pscustomobject\]@{a=1; b=2; c=3; d=4} $CustomObject2 | Format-List Note: both methods create a PSCustomObject with NoteProperties, not a hashtable object
$CustomObject1 | Get-Member $CustomObject2 | Get-Member So, why would you want to do it this way?
*****Warning. This is from a preview release******
In Windows Server 2008 R2 there were a number of modules included for managing typical server roles such as Active Directory, Failover Clustering etc. However, there were some noteable absentees, such as DHCP server.
You may ask why am I highlighting PowerShell cmdlets for DHCP, well:
Fellow London VMUG regular Julian Wood commented on my PowerShell v3 First Look Post asking if there were DHCP cmdlets this time.
*****Warning. This is from a preview release******
Not everybody uses the PowerShell ISE as their primary script editor. However, if you do, or if you are using it to quickly edit a script not on your primary workstation then you will be pleased to see that in v3 it now has IntelliSense. In both the Input pane and the Script Editor.
From the Input pane:
This also works for commands in modules not loaded yet, such as Get-NetIPaddress.
A preview (emphasis on the preview) of PowerShell v3 was made available in the early hours of this morning following the announcement at the Build conference. Apparently they are also planning to ship something with it called Windows 8. You can download the Windows Developer preview from MSDN to get an early look at it.
Well we know for sure that it is new:
and it is version 3:
Some good friends of mine and fellow PowerShell MVPs have been working very hard over the last few months to put together an exciting new venture, http://www.powershellmagazine.com . They launched the site today and there is already some excellent content up there. I encourage you to go check it out and add to your RSS reader since I know there is plenty of great content upcoming for the site. I’m hoping to be able to contribute some articles of my own as soon as possible.
I have really enjoyed my time at my current employer, there are some amazingly talented people who work / have worked there during the time I have spent there. However, for various reasons I have decided that it is time to move on and try something different by going freelance contracting. So while I work out my notice period I will be looking for a contract as my next opportunity.
The PowerCLI team publish very handy reference posters that will sit nicely by your desk and usually release a new version to accompany each product release. vSphere 5 is no different and if you weren’t lucky enough to attend the recent VMworld and collect a tangible copy then you can now download one to print out yourself.
In PowerShell it is possible to use custom properties for an object if the one you need does not exist by default - these are known as calculated properties.
For instance, in PowerCLI by default there is no ToolsVersion property for a VM, however we can create a calculated property named ToolsVersion and submit an expression to retrieve that data:
Get-VM TEST01 | Select-Object Name,@{Name="ToolsVersion";Expression={$\_.ExtensionData.Config.Tools.ToolsVersion}} However, the ToolsVersion property does not persist after running this command, so if I now try:
VMware vExpert and general virtualisation legend Tom Howarth has very kindly decided to give away an additional copy of VMware vSphere PowerCLI Reference that he has spare. All you need to do to be in with a chance of winning is submit a PowerShell based script via Tom’s site and I will pick a winner to receive the book. Full details from Planet VM:
-———————————————————————————————————————————————-
I’ve received a copy of VMware vSphere PowerCLI Reference as a review copy, but I have already purchased one.