Data collector stop issue

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
$dcset= new-object -COM Pla.DataCollectorSet;
$name=“User Defined\sql_2016”;
Write-host “Couldn’t stop the Data collector”
Write-host "Error: " $ErrorMessage

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