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.

Comments

 
Comments

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 ?

Trackbacks for this post

Leave a Reply


six + = 13