How to run Powershell scripts with a Service Account to access ConfigMgr 2012 SP1

Error connecting to the Primary Site
Error connecting to the Primary Site

When using a service account to run for instance my “cleaning ConfigMgr” Powershell script you may run in to an error. When trying to access the Windows PowerShell drive that is mapped to your Primary Site you will receive the following error: “set-location : Cannot find drive. A drive with the name <primary site> does not exist.” (see figure on the left) I see the same behavior when for instance running a Powershell script from System Center Orchestrator 2012 to change settings in Configuration Manager 2012 SP1.

After some troubleshooting I found out that for some reason the mapping does not exist when using the service account. In my case the service account had sufficient permissions on the Primary Site Server and within the Configuration Manager 2012 Primary Site. So that couldn’t be an issue but to be sure I started the Configuration Manager 2012 Console with the permissions of the service account.

Run the console as a different user (Service Account)
Run the console as a different user (Service Account)

Steps to workaround this issue:

  1. Create a brand new service account
  2. Give the Service Account the permissions you want in Configuration Manager 2012
  3. Use Run As Different User with the Service Account when starting the Configuration Manager 2012 Console
  4. Close the console
  5. Run the script using the service account permissions


Connecting to the Primary Site using the Service Account
Connecting to the Primary Site using the Service Account


I requested more information about this issue, so I will keep you posted.


  1. That’s a great info but how about if service account doesn’t have local login permissions ?(Run as doesn’t work for console launch)
    And this works only in case you are executing script on the same site server and connecting to the same site server.
    But how about if I want to connect to different site server?
    If I have multiple site servers that I connect using a script am I suppose to connect to each site server by launching console to each site server ?

    1. Just in case anyone else has this issue.

      Create a new scheduled task and set the user to the service account and the action to run the configuration manager console.

      Location for me was the below, you may need to change the drive if you have installed it elsewhere.
      “C:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\Microsoft.ConfigurationManagement.exe”

      Run the task and wait for it to finish then attempt to run your original scheduled task again.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

New version of Cleanup devices in ConfigMgr 2012 script released

Next Post

“Query builder Values box can’t display large item list”-fix works for ConfigMgr 2012

Related Posts