I am trying to run CD to SCCM site folder after Import-Module ConfigurationManager.psd1 on a remote computer as a Non-Admin user. However I am gettting the following error:
PS C:\windows\system32> Enter-PSSession -ComputerName somecomputer -Credential Sccm\u6
[somecomputer]: PS C:\Users\u6\Documents> Import-Module ConfigurationManager.psd1
[somecomputer]: PS C:\Users\u6\Documents> cd 1SA:
cd : Cannot find drive. A drive with the name '1SA' does not exist.
+ CategoryInfo : ObjectNotFound: (1SA:String) [Set-Location], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
I can get around this issue by following the documentation given on this link: http://benef-it.blogspot.in/2013/04/solve-ps-drive-problem-with-sccm2012.html
But how can I do this programmatically from within powershell?
Ok found the solution to this
New-PSDrive -Name $sitecode -PSProvider "AdminUI.PS.Provider\CMSite" -Root "$ENV:ComputerName" -Description "SCCM Site"
Running the above command creates the drive which you can subsequently use.