Windows 7 What’s New Guide




Download 129.34 Kb.
bet101/104
Sana01.04.2021
Hajmi129.34 Kb.
#13818
1   ...   96   97   98   99   100   101   102   103   104

Windows PowerShell 2.0


Windows PowerShell 2.0 is compatible with Windows PowerShell 1.0; however, existing scripts and applications need to be updated to accommodate the following changes:

 The value of the PowerShellVersion registry entry in HKLM\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine is changed to 2.0.

 New cmdlets and variables have been added that might conflict with variables and functions in profiles and scripts.

 The -ieq operator performs a case insensitive comparison on characters.

 The Get-Command cmdlet gets functions by default, in addition to cmdlets.

 Native commands that generate a user interface cannot be piped to the Out-Host cmdlet.

 The new Begin, Process, End, and Dynamic Param language keywords might conflict with similar words that are used in scripts and functions. Parsing errors may occur if these words are interpreted as language keywords.

 Cmdlet name resolution has changed. Windows PowerShell 1.0 generated a runtime error when two Windows PowerShell snap-ins exported cmdlets with the same name. In Windows PowerShell 2.0, the last cmdlet that is added to the session runs when you type the command name. To run a command that does not run by default, qualify the cmdlet name with the name of the snap-in or module in which it originated.

 A function name followed by -? gets the Help topic for the function, if one is included in the function.

 Parameter resolution for Microsoft .NET Framework methods have changed. In Windows PowerShell 1.0, if you called an overloaded .NET method with more than one best-fit syntax, no error was reported. In Windows PowerShell 2.0, an ambiguity error is reported. In addition, in Windows PowerShell 2.0, the algorithm for choosing the best fit method has been revised significantly to minimize the number of ambiguities.

 If you are enumerating a collection in the pipeline, and you try to modify the collection, Windows PowerShell 2.0 throws an exception. For example, the following commands would work in Windows PowerShell 1.0, but they would fail after the first pipeline iteration in Windows PowerShell 2.0:

$h = @{Name="Hello"; Value="Test"}

$h.keys | foreach-object {$h.remove($_)}

To avoid this error, create a subexpression for the enumerator by using the $() characters as follows:

$($h.keys) | foreach-object {$h.remove($_)}



Download 129.34 Kb.
1   ...   96   97   98   99   100   101   102   103   104




Download 129.34 Kb.