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.