Powershell and Register-WMIEvent for blocked process report Issue

  • Hi All

    Im trying to follow

    http://shellyourexperience.com/2011/09/14/powershell-and-sql-server-eventsblocked-process-report-and-sp_whoisactive/ in order to capture blocked processes using powershell

    All is fine until I try and run:(I have replaced MSSQLSERVER with VINS001 for my named instance)

    $query = "select * from BLOCKED_PROCESS_REPORT where duration > 50000"

    Register-WMIEvent -Namespace 'root\Microsoft\SqlServer\ServerEvents\VINS001' $query -Action {ipmo functions ; Get-ProcessBlockedInfo $Event.SourceEventArgs.NewEvent}

    I get the error:

    Register-WMIEvent : Could not register for event. The class name is invalid. Valid class names consist of letters, digits and the underscore character.

    At line:3 char:1

    + Register-WMIEvent -Namespace 'root\Microsoft\SqlServer\ServerEvents\VINS001' $q ...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo : InvalidArgument: (:) [Register-WmiEvent], ArgumentException

    + FullyQualifiedErrorId : INVALID_QUERY_IDENTIFIER,Microsoft.PowerShell.Commands.RegisterWmiEventCommand

    However the following produces output:

    Get-WmiObject -Namespace "root\Microsoft\SqlServer\ServerEvents\VINS001" โ€“List

    I have tried \\.\root.... as well but I get the same error

    Anyone run into this before?

    thanks

    Chris

  • Nobody run into this?

  • Stick it in double quotes if you run into this ๐Ÿ™‚

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply