If you have been following my blog for a while you will know that between November 2009 and July 2010 I ran a available for download as a PDF.
You’ll be pleased to know I have spent many hours tidying it up, making links to other cmdlets internal to the document throughout and it has also been thoroughly reviewed by fellow PowerShell MVPs Thomas Lee , Richard Siddaway and Aleksandar Nikolic - I am most appreciative of their efforts in reviewing and the feedback given!
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.
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.
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:
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.
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:
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.
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.
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.
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.