Data collector stop issue

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #39224
    Profile photo of Ravi DS
    Ravi DS
    Participant

    The below code snippet is throwing error as
    Exception calling "Stop" with "1" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
    Performance Log users group has access Log on as batch job in the sec policy.
    please help
    clear-host
    try
    {
    $dcset= new-object -COM Pla.DataCollectorSet;
    $name="User Defined\sql_2016";
    $dcset.Query($name,"server1");
    $dcset.Stop($false);
    }
    catch
    {
    Write-host "Couldn't stop the Data collector"
    $ErrorMessage=$_.Exception.Message
    Write-host "Error: " $ErrorMessage
    }

    #39470
    Profile photo of Don Jones
    Don Jones
    Keymaster

    It's definitely an "access denied" problem. Either the user you've specified doesn't have the necessary permission (and I'm not that knowledgeable on SQL Server data collectors, so I'm not going to be of any help there), or the COM object isn't marshalling correctly through .NET Interop.

    Sorry – I know that's not helpful to you, but this isn't really a PowerShell thing. You're using a COM object that messes with SQL Server – while you're using PowerShell to do it, none of my PowerShell experience helps me understand SQL or COM :).

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

You must be logged in to reply to this topic.