Hi,
We are using SCCM 2012 R2 which isn't compatible with vRealize 6.2, but I need to be able to add a machine to a collection via Orchestrator. I can do this using the command:
Add-CMDeviceCollectionDirectMembershipRule -CollectionName "mycollection" -ResourceId $(get-cmdevice -name "mymachine").ResourceID from a host with the conosle enabled, but I cant seem to run it from VCO.
I have tried two methods:
1. Remote Powershell commands running from the Powershell Host:
$sess = New-PSSession -ComputerName mySCCMhost -ConfigurationName Microsoft.Powershell32 -Authentication Kerberos -Credential $cred
Invoke-Command -Session $sess -ScriptBlock {$env.computername; Import-Module "D:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"; Add-CMDeviceCollectionDirectMembershipRule -CollectionName "myCollection" -ResourceId $(get-cmdevice -name "myVM").ResourceID}
2. Running a script on the Powershell host:
Import-Module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1')
CD MySiteDrive:\
Add-CMDeviceCollectionDirectMembershipRule -CollectionName "myCollection" -ResourceId $(get-cmdevice -name "myVM").ResourceID
Neither work, I believe its something to do with the ConfigurationManager module not being able to be called remotely.
Both methods add the module successfully but cant connect to the SCCM site drive with the error "Cannot find drive. A drive with the name 'DPS' does not exist."
I have verified that I have remote access to the SCCM server by doing invoking the command to get the hostname or the runnign services, which is successful, so I have ruled out auth issues.
Has anyone got any ideas how I can call this command?