Recently, I was looking for the difference between the Get-ChildItem cmdlet in Version 2 and Version 3 of Windows PowerShell.
Although you can Bing “PowerShell Get-ChildItem v3” and get an accurate listing of the new parameters from TechNet, that’s not true for all cmdlets, so I wrote a quick little script to find the information.
Along with the required Name parameter, the script takes several optional Switch parameters to modify the output.
1. You can list parameters that the cmdlet shares between versions with the parameter “Common”.
2. You can list parameters that existed in version 2, but which are not in version 3 with the parameter “Removed”.
3. You can list the new parameter names and type with the parameter “Detailed”.
With no optional parameters, the script just lists new parameter names.
If the cmdlet is new to PowerShell version 3, the script will report that, and show the parameter names.
I use a custom view to present the information requested.
The script and custom view are a little too long to post here, so I will post them in the TechNet Gallery.
Pick up a copy of the script here.
I will however, explain myself a little J
First, a few examples:
Here we will show the new parameters for the cmdlet Get-ChildItem, along with their types:
► .\Compare-Command.ps1 Get-ChildItem –Detailed
Cmdlet New Parameter Type
Get-ChildItem Attributes FlagsExpression`1
Get-ChildItem Directory SwitchParameter
Get-ChildItem File SwitchParameter
Get-ChildItem Hidden SwitchParameter
Get-ChildItem ReadOnly SwitchParameter
Get-ChildItem System SwitchParameter
Here, we show the new and removed parameters for the cmdlet Restart-Computer, and once again output their types:
► .\Compare-Command.ps1 -Name Restart-Computer -Detailed –Removed
Cmdlet New Parameter Removed Parameter Type
Restart-Computer DcomAuthentication AuthenticationLevel
Restart-Computer WsmanAuthentication String
Restart-Computer Protocol String
Restart-Computer Wait SwitchParameter
Restart-Computer Timeout Int32
Restart-Computer For WaitForServiceTypes
Restart-Computer Delay Int16
Restart-Computer Authentication AuthenticationLevel
Finally, we show that ConvertTo-Json is a new cmdlet, and we show the parameters for the cmdlet:
► .\Compare-Command.ps1 -name ConvertTo-Json
Cmdlet New Parameter
ConvertTo-Json (New Cmdlet) Input Object
ConvertTo-Json (New Cmdlet) Depth
ConvertTo-Json (New Cmdlet) Compress
ConvertTo-Json (New Cmdlet) Verbose
ConvertTo-Json (New Cmdlet) Debug
ConvertTo-Json (New Cmdlet) ErrorAction
ConvertTo-Json (New Cmdlet) WarningAction
ConvertTo-Json (New Cmdlet) ErrorVariable
ConvertTo-Json (New Cmdlet) WarningVariable
ConvertTo-Json (New Cmdlet) OutVariable
ConvertTo-Json (New Cmdlet) OutBuffer
As mentioned in the title of the post, this is only a quick comparison of the cmdlets between Version 2 and Version 3 of Windows PowerShell.
I purposely don’t add details such as which parameters are positional, which are parts of parameter sets, and etcetera.
All of these details can be retrieved with the excellent built in help.
My purpose is only to highlight the differences in versions, to get you (and me) quickly up to speed on the proper parameters for all the cmdlets.
I’m also working on a list of new and removed cmdlets in the Exchange 2013 Management Shell – look for that article soon.