I have been working with the SCCM 2007 SDK for a week or so now, and using the C# examples haven't had an issue connecting and running the commands I want. Unfortunately, I am trying to run my .Net DLL from within Powershell, and as soon as it gets to the .Connect statement of the WglConnectionManager object, I get an Access Denied error.
I have done quite a bit of research, already enabled PSRemoting on the remote machine, as well as decompiled the wgladmin DLL to ensure that the Authentication is being set to PacketPrivacy. I am sure there is something I am missing, and although I have been using Powershell for almost a year, it has been mostly on local systems.
This connection is after I have already imported the two DLL's needed into the namespace. The error I receive is:
Exception calling "Connect" with "3" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
At C:\Users\cnanda\Documents\WindowsPowerShell\Modules\Sccmpack\SCCMPack.PSM1:15 char:38
+ [void]$connection.Connect <<<< ("", "", "
");
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
SciSessionHandle :
ConnectionScope : System.Management.ManagementScope
QueryProcessor : Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlQueryProcessor
UniqueIdentifier : 4acb728e-1aeb-4493-a0a7-218f68bce2d9
MinVersion : 0
MaxVersion : 0
ExecuteQueryBatchSize : 50
AsyncQueryBatchSize : 50
ResultObjectsBatchSize : 1000
NamedValueDictionary : {}
UserDataObject :
Context :
Here is the Connection Code:
$namedValues = New-Object Microsoft.ConfigurationManagement.ManagementProvider.SmsNamedValuesDictionary
$connection = New-Object Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine.WqlConnectionManager($namedValues)
[void]$connection.Connect("SERVERNAME", "USERNAME", "PASSWORD");