PowerShell 2.0: One Cmdlet at a Time 107 Add-Type

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Add-Type cmdlet. What can I do with it? Imbed code from modern programming languages into your PowerShell session or scripts. The list of valid languages are: C#, C# 3.0, VisualBasic and JScript - C# is the default. Use the Language parameter to specify one if it is not C#. Example: Within a PowerShell session use some C# code to create a TakeAway class and create a static method Minus.

PowerShell 2.0: One Cmdlet at a Time 106 Import-LocalizedData

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Import-LocalizedData cmdlet. What can I do with it? Enable text in scripts displayed to users to be presented in their own language. The cmdlet uses the automatic variable $PSUICulture to determine the language to use and alternate text is stored within .psd1 files in subdirectories of the folder that the script is stored.

ESXi 4.0 Slow Boot Times When Hosting Passive MSCS Nodes With RDM LUNs

During the initial stages of an upgrade of a number of VMware hosts from ESX 3.5 U5 to ESXi 4.0 U2 the boot times rose from the normal few mins (most of which is Dell Hardware checks) to around 12 mins. In particular it was appearing to hang for 5 mins, whilst on the screen the below was displayed: Loading module multiextent This would only happen after the install was completed and the host connected back to the fibre channel SAN, otherwise boot times were normal.

PowerShell 2.0: One Cmdlet at a Time 105 Set-StrictMode

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Set-StrictMode cmdlet. What can I do with it? Configure strict mode for the current scope. An error will be generated when the content of an expression, script or script block violates coding rules. Note: it is possible to use the Version parameter to pick which coding rules to use. The PowerShell help lists the current possible options as:

PowerShell 2.0: One Cmdlet at a Time 103 Update-List

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Update-List cmdlet. What can I do with it? Add, Remove or Replace items from a property value of an object. This cmdlet can only update a property when it supports the IList interface. So far this does not include any of the core Windows PowerShell cmdlets - however it does include some of the cmdlets that ship with Exchange 2007 and later.

PowerShell 2.0: One Cmdlet at a Time 104 Trace-Command

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Trace-Command cmdlet. What can I do with it? Begin a trace of a command or expression. Example: Examine debug info for Parameter Binding when piping a string through to Get-Service. Trace-Command -Name ParameterBinding -Option All -Expression {‘winmgmt’ | Get-Service} -PSHost You will see it is possible to work through the debug info to find out what is happening:

PowerShell 2.0: One Cmdlet at a Time 102 Disable-PSRemoting

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Disable-PSRemoting function. Note: This is a proxy command which calls the Disable-PSSessionConfiguration cmdlet. What can I do with it? Disable PowerShell remoting on a computer that has previously been enabled for remoting. Note: This command must be run from a PowerShell session with administrative privileges. Example: Retrieve the current PSSessionConfiguration settings. Disable PowerShell remoting, then retrieve the PSSessionConfiguration settings again to compare.

PowerShell 2.0: One Cmdlet at a Time 101 Wait-Process

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Wait-Process cmdlet. What can I do with it? Wait for a process to stop before proceeding further. Example: Open an instance of Notepad. Use Wait-Process to pause the console session until Notepad is closed. Notepad Wait-Process -Name Notepad You will notice that the console pauses whilst Notepad is open Once Notepad is closed, control of the session is returned to the user.

PowerShell 2.0: One Cmdlet at a Time 100 Remove-Event

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-Event cmdlet. What can I do with it? Delete an event from the current session. Note: to unsubscribe from an event you will need to use Unregister-Event. Example: Retrive current events in the queue with Get-Event, use Remove-Event to clear the event with the SourceIdentifier of Timer, then Get-Event again to confirm that it has been removed.

PowerShell 2.0: One Cmdlet at a Time 99 Unregister-Event

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Unregister-Event cmdlet. What can I do with it? Clear an event subscription. Example: Use Get-EventSubscriber to retrive details of current events. Clear the event with subscription id 1 and Get-EventSubscriber again to confirm that it has been removed. Get-EventSubscriber Unregister-Event -SubscriptionId 1 Get-EventSubscriber You will see that the event subscription has been cleared.