powershell

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.

PowerShell 2.0: One Cmdlet at a Time 98 Wait-Event

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Wait-Event cmdlet. What can I do with it? Pause a running script or session and wait for an event to occur before continuing. Example: The built-in PowerShell help has a great example for New-Event. It uses New-Event to create a custom event based on a reaction to another event. Use Wait-Event to make the current session pause until a new process has been opened.

PowerShell 2.0: One Cmdlet at a Time 97 Get-Event

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Get-Event cmdlet. What can I do with it? Retrieve events from the event queue. Example: The built-in PowerShell help has a great example for New-Event. It uses New-Event to create a custom event based on a reaction to another event. Once the event has been created Get-Event can be used to examine details of that event and any others currently in the queue.

PowerShell 2.0: One Cmdlet at a Time 96 New-Event

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the New-Event cmdlet. What can I do with it? Create a custom event. Example: The built-in PowerShell help has a great example for New-Event. It uses New-Event to create a custom event based on a reaction to another event. function Enable-ProcessCreationEvent { $query = New-Object System.Management.WqlEventQuery “__InstanceCreationEvent”, (New-Object TimeSpan 0,0,1), “TargetInstance isa ‘Win32_Process’” $processWatcher = New-Object System.

PowerShell 2.0: One Cmdlet at a Time 95 Register-EngineEvent

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Register-EngineEvent cmdlet. What can I do with it? Subscribe to events generated by the PowerShell engine or the New-Event cmdlet. Example: Subscribe to an event when the PowerShell session exits, and save information including the date and time out to a log file. Register-EngineEvent PowerShell.Exiting -Action {“PowerShell exited at " + (Get-Date) | Out-File c:\log.

PowerShell 2.0: One Cmdlet at a Time 94 Get-EventSubscriber

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Get-EventSubscriber cmdlet. What can I do with it? Retrieve event subscribers from the current session. Example: Use the Register-ObjectEvent cmdlet to register for an event to check for new processes, use the ManagementEventWatcher .NET object to form the basis of the object to monitor and save information including the date and time out to a log file.

New Simple-Talk Article: New Remoting Features in PowerShell 2.0

Remoting is one of the big new features in PowerShell 2.0 so I thought I would check it out more for an article for Simple-Talk; you can see the results here. It certainly is cool stuff and will be great for administrators to take advantage of. If you want to find out more I’d also recommend ‘The Administrators Guide to PowerShell Remoting’ over on PowerShell.com - you can hear two of the authors, Dr Tobias Weltner and Aleksandar Nikolic, talk about it on the latest episode of the Get-Scripting podcast.

PowerShell 2.0: One Cmdlet at a Time 93 Register-ObjectEvent

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Register-ObjectEvent cmdlet. What can I do with it? Subscribe to an event on a local or remote computer generated by a .NET Framework object and carry out actions based on the event. Example: Register for an event to check for new processes, use the ManagementEventWatcher .NET object to form the basis of the object to monitor and save information including the date and time out to a log file.

PowerShell 2.0: One Cmdlet at a Time 92 Register-WmiEvent

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Register-WMIEvent cmdlet. What can I do with it? Subscribe to a WMI event on a local or remote computer and carry out actions based on the event. Example: Register for a WMI which checks every 10 seconds for any new processes which have started, call it Check for New Processes and save information including the date and time out to a log file.