Data collector stop issue

Welcome Forums General PowerShell Q&A Data collector stop issue

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
2 years, 6 months ago.

  • Author
    Posts
  • #39224

    Participant
    Points: 0
    Rank: Member

    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

    Keymaster
    Points: 1,673
    Helping HandTeam Member
    Rank: Community Hero

    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 :).

The topic ‘Data collector stop issue’ is closed to new replies.