cmdlet-series

PowerShell 2.0: One Cmdlet at a Time 67 Remove-EventLog

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-EventLog cmdlet. What can I do with it? Remove an Event Log. Example: Remove the Event Log named App1 on the remote computer Test01. Confirm it has been removed with Get-EventLog. Remove-EventLog -LogName App1 -ComputerName Test01 Get-EventLog -List -ComputerName Test01 Confirmation that the App1 Event Log has been removed. Note: To perform this task remotely you will need to ensure that Remote Event Log Management has been added as an Exception in Windows Firewall.

PowerShell 2.0: One Cmdlet at a Time 68 Show-EventLog

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Show-EventLog cmdlet. What can I do with it? Open Event Viewer on a local or remote computer. Example: Open Event Viewer on the remote computer Test01. Show-EventLog -ComputerName Test01 You will see that Event Viewer on the remote computer Test01 opens on the local machine. How could I have done this in PowerShell 1.

PowerShell 2.0: One Cmdlet at a Time 66 Limit-EventLog

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Limit-EventLog cmdlet. What can I do with it? Set the size and age properties of an Event Log. Example: Set the following properties on the Application Log on the remote computer Test01: Maximum Size = 5MB OverflowAction = DoNotOverWrite Limit-EventLog -ComputerName Test01 -LogName Application -MaximumSize 5MB -OverflowAction DoNotOverWrite Before: After: How could I have done this in PowerShell 1.

PowerShell 2.0: One Cmdlet at a Time 65 New-EventLog

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the New-EventLog cmdlet. What can I do with it? Create a custom Event Log. Example: Create a custom Event Log named App1 with an event source of AppEvent. Use the Get-EventLog cmdlet to confirm it has been created. Tip: New-EventLog requires a PowerShell session with elevated privileges. New-EventLog -LogName App1 -Source AppEvent Get-EventLog -List

PowerShell 2.0: One Cmdlet at a Time 63 Remove-PSBreakpoint

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-PSBreakpoint cmdlet. What can I do with it? Remove debugging breakpoints that have been set with Set-PSBreakpoint. Examples: Check existing breakpoints and remove the breakpoint with ID 0. Get-PSBreakpoint Remove-PSBreakpoint -Id 0 Confirmation that breakpoint with ID 0 has been removed. Check existing breakpoints and remove all of them. Get-PSBreakpoint Get-PSBreakpoint | Remove-PSBreakpoint

PowerShell 2.0: One Cmdlet at a Time 64 Clear-History

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Clear-History cmdlet. What can I do with it? Remove commands from the history of those entered in the current session. PowerShell has two places where a history of the commands you have entered are kept. Within the console you can use F7 to view them and Alt-F7 to clear that list. There are also some cmdlets for managing PowerShell history, such as Get-History and the new Clear-History.

PowerShell 2.0: One Cmdlet at a Time 61 Disable-PSBreakpoint

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Disable-PSBreakpoint cmdlet. What can I do with it? Disable debugging breakpoints that have been set with Set-PSBreakpoint. Example: Disable the breakpoint with ID 0 and then check its properties to confirm it has been disabled. Disable-PSBreakpoint -id 0 Get-PSBreakpoint -id 0 | Format-List * You will notice that the Enabled property is set to False.

PowerShell 2.0: One Cmdlet at a Time 62 Enable-PSBreakpoint

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Enable-PSBreakpoint cmdlet. What can I do with it? Re-enable debugging breakpoints that have been disabled with Disable-PSBreakpoint. Example: Re-enable breakpoint with ID 0 and then check its properties to confirm it has been enabled. Enable-PSBreakpoint -id 0 Get-PSBreakpoint -id 0 | Format-List * You will notice that the Enabled property is set to True.

PowerShell 2.0: One Cmdlet at a Time 60 Get-PSBreakpoint

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Get-PSBreakpoint cmdlet. What can I do with it? Retrieve debugging breakpoints that have been set with Set-PSBreakpoint. Examples: Retrieve all current breakpoints. Get-PSBreakpoint Notice the different options which have been set on the breakpoints. Retieve only breakpoints which have been set using the Variable parameter. Get-PSBreakpoint -Type Variable Notice only one breakpoint is returned this time.

PowerShell 2.0: One Cmdlet at a Time 59 Set-PSBreakpoint

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Set-PSBreakPoint cmdlet. What can I do with it? Carry out debugging by setting a breakpoint based on a condition such as line number, command or variable. Examples: Set a breakpoint at line 3 in the script C:\Bowling.ps1 (This is an example script taken from the 2008 Scripting Games. During the execution of the script the variable $iPoints is frequently incremented to a new value) Then run the script to utilise the breakpoint.