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.
Steps to workaround this issue:
- Create a brand new service account
- Give the Service Account the permissions you want in Configuration Manager 2012
- Use Run As Different User with the Service Account when starting the Configuration Manager 2012 Console
- Close the console
- Run the script using the service account permissions
I requested more information about this issue, so I will keep you posted.
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 ?
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.