Congratulations 2012 Microsoft MVP

Sunday, July 1, 2012

I’ve just received THE email from Microsoft… I’m a PowerShell MVP for another year! I am very honored! This is my 5th renewal and I would like to take this opportunity and say thank you to Microsoft and to all the people who supported me.

Deprecation of cmdlets

Monday, April 30, 2012

Until PowerShell 3.0, if you shipped a cmdlet there was no good way to deprecate it. Cmdlet developers can use the .NET ObsoleteAttribute now to let users know that they should not use a cmdlet anymore. In the following example, the cmdlet can run but it will issue a warning that another cmdlet should be used from now on. This gives the user time to prepare for the change and fix any scripts dependent on old commands. $code = @' using System; using System.Management.Automation; namespace ObsoleteCmdlet { ...

Creating objects with a cast in PowerShell 3.0

Thursday, April 19, 2012

Starting with PowerShell 3.0, we now have another cool way to create new objects. We can create them by calling the default constructor of the type and initializing its properties with a cast: @{X=1;Y=2} We put the type in square brackets and assign it a hash table containing the properties we want to initialize. Looking at this example got me thinking, how can I know the properties I can set for a specific class/type? As a learning tool, I wrote the Get-HashType function. Give it a type name and it will tell you the properties...

How to protect your PowerShell Functions

Tuesday, April 17, 2012

Creating functions in PowerShell is relatively a simple operation. You declare the function’s name and value, press the Enter key and you’re good to go. It is also very simple to override the function just by re-creating it; that’s all it takes, simple and easy. What if you need to prevent that from happening? You don’t want to allow someone or something from overriding your functions? PowerShell gives us the option to do that via a dynamic parameter. Dynamic parameters are cmdlet parameters that are added by a Windows PowerShell provider and are available only when...
one comment

Custom objects default display in PowerShell 3.0

Friday, April 13, 2012

In PowerShell 3.0 we can now create new custom objects using a hash table. PS> @{ One = 1 Two = 2 Three = 3 Four = 4 Five = 5 } One : 1 Two : 2 Three : 3 Four : 4 Five : 5 Behind the scenes, PowerShell creates a hash table and wraps it a PSCustomObject. It is way faster than using the New-Object cmdlet and it also provides consistency, while maintaining backwards compatibility. Another benefit of using...

Add-Member enhancements in PowerShell 3.0

Wednesday, April 11, 2012

PowerShell 3.0 offers new ways to add Note properties to objects. In PowerShell 2.0, a typical command to do that would look like: PS> New-Object -TypeName PSObject | Add-Member -MemberType NoteProperty -Name One -Value 1 -PassThru One --- 1   And when adding multiple note properties: PS> New-Object -TypeName PSObject | Add-Member -MemberType NoteProperty -Name One -Value 1 -PassThru | Add-Member -MemberType NoteProperty -Name Two -Value 2 -PassThru | Add-Member -MemberType NoteProperty -Name Three -Value 3 -PassThru One Two Three --- --- ----- 1 ...

Measuring objects in PowerShell 3.0

Monday, April 9, 2012

The Measure-Object cmdlet gives us a great way to find minimum and maximum values in a collection of objects. For example, if we want to know the smallest and largest size of a file in the current directory: PS> Get-ChildItem | Measure-Object -Property Length -Minimum -Maximum Count : 2751 Average : Sum : Maximum : 56297240 Minimum : 35 Property : Length In PowerShell 2.0 it only worked with numeric properties (integers), we couldn't use it to compare properties like LastWriteTime (DateTime). In PowerShell 3.0 we can now use...
one comment

Leveraging Proxy Functions in PowerShell

Friday, March 30, 2012

@DSotnikov just released the video recording of the session from the PowerShell Deep Dive in Frankfurt (last year). In this video, MVP Kirk Munro (poshoholic) and I demoed a project we've been working on that let's you create proxy functions. Here's a reminder of the session abstract. In this session as they take a deep dive into proxy functions in PowerShell. Shay and Kirk have been working together on PowerShell Proxy Extensions, a powerful module that leverages proxy functions and makes it easier than ever to create these powerful extensions to PowerShell. They will demonstrate what proxy functions...

Auto reconnect to a server you just rebooted with PowerShell 3.0

Sunday, January 8, 2012

Yesterday I saw a tweet that caught my eye: Sounds familiar? What do you usually do to reconnect to your server once it is back online? How do you monitor it’s availability? In this post, Justin shares a great function (115 lines) that restarts a server, waits for it to come back online and then starts a remote desktop connection to it. Now, what if I told you that in PowerShell 3.0 you can replace that function with only two lines of code? In PowerShell 3.0, the Restart-Computer cmdlet got improved (mainly to support Workflow scenarios) and it now supports...

PSRR – Remote Registry PowerShell 3.0 Module

Wednesday, November 2, 2011

var addthis_config = {"data_track_clickback":true}; One of the new improvements in the .NET Framework version 4 is the Microsoft.Win32.RegistryView enumeration. On the 64-bit version of Windows, portions of the registry are stored separately for 32-bit and 64-bit applications. There is a 32-bit view for 32-bit applications and a 64-bit view for 64-bit applications. Many of the 32-bit keys have the same names as their 64-bit counterparts, and vice versa. In the 64-bit version of Registry Editor, 32-bit keys are displayed under the following registry key: HKEY_LOCAL_MACHINE\Software\WOW6432Node. I’m pleased to announce that the PSRemoteRegistry module has...