Hi,
Please advise on howto run remote powershell scripts to an SCCM 2012 SP1-server.
Locally importing the module (on sccm 2012) works fine, but not remotely. It tells I should run from x86 console, but I am!
Please advise.
J.
Technology Tips and News
Hi,
Please advise on howto run remote powershell scripts to an SCCM 2012 SP1-server.
Locally importing the module (on sccm 2012) works fine, but not remotely. It tells I should run from x86 console, but I am!
Please advise.
J.
You are running 32-bit PowerShell locally, but by default the remote PowerShell session you are launching is 64-bit.
When you create the remote session, use the -ConfigurationName parameter:
Enter-PSSession -ComputerName sccm2012 -ConfigurationName Microsoft.PowerShell32
You should then be able to load the module.
Then again, on a different remote machine, it does NOT work. Loading modules works fine, get-command -module configuration manager shows all the commands, but I cannot switch to the SCCM-site (MS1:).
Could you advise? Thanks!
---command executed---
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
[SCCM2012]: PS C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin> Get-Command -Module Configuration
Manager
CommandType Name
ModuleName
----------- ----
----------
Cmdlet Add-CMApplicationCatalogWebServicePoint ConfigurationManager
Cmdlet Add-CMApplicationCatalogWebsitePoint ConfigurationManager
Cmdlet Add-CMAssetIntelligenceSynchronizationPoint ConfigurationManager
Cmdlet Add-CMBoundaryToGroup
ConfigurationManager
Cmdlet Add-CMDeploymentType
ConfigurationManager
Cmdlet Add-CMDeviceAffinityToUser ConfigurationManager
Cmdlet Add-CMDeviceCollectionDirectMembershipRule ConfigurationManager
Cmdlet Add-CMDeviceCollectionExcludeMembershipRule ConfigurationManager
Cmdlet Add-CMDeviceCollectionIncludeMembershipRule ConfigurationManager
Cmdlet Add-CMDeviceCollectionQueryMembershipRule ConfigurationManager
Cmdlet Add-CMDeviceCollectionToAdministrativeUser ConfigurationManager
Cmdlet Add-CMDeviceCollectionToDistributionPointGroup ConfigurationManager
...
>
[SCCM2012]: PS C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin> cd MS1:
cd : Cannot find drive. A drive with the name 'MS1' does not exist.
+ CategoryInfo : ObjectNotFound: (MS1:String) [Set-Location], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
[SCCM2012]: PS C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin> get-psdrive
Name Used (GB) Free (GB) Provider Root
CurrentLocation
---- --------- --------- -------- ----
---------------
A FileSystem A:\
Alias Alias
C 33,86 27,14 FileSystem C:\
...on Manager\AdminConsole\bin
Cert Certificate \
D FileSystem D:\
E 24,09 35,91 FileSystem E:\
Env Environment
F FileSystem F:\
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
Variable Variable
WSMan WSMan
Hi.
Any news on this. I have the same problem that I cant find the PSDrive for my site.
Hi Jan,
Your get-psdrive output does not show SCCM site name. Can you try to re-connect to the SCCM server using the following command? Also ensure that PowerShell version 3 installed on the client machine. Use Run As Administator to open PowerShell command window.
PS C:\> Enter-PSSession -computername YourSCCMServerName -ConfigurationName Microsoft.Powershell32
Name Used (GB) Free (GB) Provider Root
CurrentLocation
---- --------- --------- -------- ----
---------------
ABC CMSite YourSCCMServerName.domain.root
In this example, ABC is the site name.
Once you are able to see the site name try the following command to connect to the CMSite.
PS C:\> $SMSDRV = Get-PSDrive -PSProvider CMSite
PS C:\> cd "$($SMSDRV):"
I think that there is some bug in the .NET \ PS specific to the 2012 Configuration Manager cmdlets . But the above command must work in any case.
Hi,
I'm facing a similar problem. When I try to execute a Powershell command trough status filter rules, the CMSite drive doesn't load. I've figured out that the execution of the Powershell is done by the system account (NT Authority\SYSTEM).
To try to find out what was wrong, I started the "Configuration Manager Console" as the system account and got an error that he could not connect to the site. An critical application event log has also been generated with ID 1 and following text:
Transport error; failed to connect, message: 'The user account running the Configuration Manager console has insufficient permissions to read information from the Configuration Manager site database. The account must belong to a security role in Configuration Manager. The account must also have the Windows Server Distributed Component Object Model (DCOM) Remote Activation permission for the computer running the Configuration Manager site server and the SMS Provider.'\r\nMicrosoft.ConfigurationManagement.ManagementProvider.SmsConnectionWithDetailException\r\nThe user account running the Configuration Manager console has insufficient permissions to read information from the Configuration Manager site database. The account must belong to a security role in Configuration Manager. The account must also have the Windows Server Distributed Component Object Model (DCOM) Remote Activation permission for the computer running the Configuration Manager site server and the SMS Provider.\r\n at Microsoft.ConfigurationManagement.AdminConsole.SmsSiteConnectionNode.ValidateConnectionParameters(ConnectionManagerBase connection)
at Microsoft.ConfigurationManagement.AdminConsole.SmsSiteConnectionNode.GetConnectionManagerInstance(String connectionManagerInstance)\r\nNo details are available for this error.\r\n
I've checked the DB access, security role and DCOM Remote Activation permission for the precense of the AD computer account or SYSTEM account. I've also checked the certificate in the Local Machine store. All seems correct, but still no access to the drive.
Can someone help me?
hi,
did you get the solution. if yes, pls send it to me.
hi,
I am having the same Issue
I entered PS Session as mentioned above, imported the CM module but not able to change PS Drive to Site.
Also, on doing Get-PSDrive, the Site name is not coming. If anyone has found the solution, then pls suggest.
thanks
hi,
did you get the solution. if yes, pls send it to me. i am having the same issue.
thanks.
Start the SCCM Console and start Powershell from there. (left-top "Connect via Windows Powershell")
This will register the CM PSDrive for the user who started the console.
Start the SCCM Console and start Powershell from there. (left-top "Connect via Windows Powershell")
This will register the CM PSDrive for the user who started the console.
The PSDrive will not be available to a PowerShell IDE or another editor. However in looking at this, it shows that it's loading "Microsoft.ConfigurationManagement.PowerShell.Types.ps1xml". So I tried the following:
Update-TypeData -PrependPath ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\Microsoft.ConfigurationManagement.PowerShell.Types.ps1xml')
That seems to load the correct datatype. However I still get an error doing the following command (example):New-PSDrive -Name "CAS" -PSProvider CMSite -Root "ServerUNC"
Error:
New-PSDrive : Object reference not set to an instance of an object.
Hopefully someone knows more about TypeData...
-Ken
Probably because of this:
It's because the CM12 Powershell cmdlets are digitally signed and your account probably never before installed that certificate.
In order to solve your problem, follow this: http://blogs.technet.com/b/microsoft_denmark_premier_field_engineering_config_manager_blog/archive/2013/01/30/running-configuration-manager-2012-powershell-scripts-as-a-service-account-or-local-system.aspx
Have you tried running the Configuration Manager Console under that user on that client?
I have found that you are unable to connect via Powershell until the console has been opened at least once. Not sure exactly what's going on in the backend, but opening the console has resolved this for me.