0

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");
  • Just to make sure this is evident. The c# code connects and can create a collection on the remote SCCM server. So I am sure this is an issue with powershell permissions. – Chris Nanda Dec 16 '12 at 20:32
  • Some additional details I have found: This is indeed caused by credentials errors. If I end up not passing credentials to the Connect object, it defaults to using the current users credentials which then allow me to connect to SCCM and do what I need. But if I pass the domain credentials, it borks. Fortunately, for my need this will work, I would still like to know if I am incorrectly passing the username/password or how that is supposed to be formatted. I have tried just (username, password) I have tried (domain\username, password), not sure what other options there are. – Chris Nanda Dec 21 '12 at 20:49

0 Answers0