If you have been following me in twitter, then most likely you already know that the Move-CMObject cmdlet is broken in 1604 release.

Here is one quick examples that shows the error message.

image

Microsoft already knows this issue and hopefully they can fix it quickly but meanwhile we need to find a workaround or do something else:

1. Uninstall 1604 cmdlets and go back to older version

2. Replace Move-CMObject with your own custom function – http://cm12sdk.net/?p=1006

3. NEW! Use Invoke-CMWmiMethod

 

In this blog post I will show one example how to use Invoke-CMWmiMethod cmdlet. In this example Im going to move SUM – RING2 Device Collection to Software Updates folder.

 

$Collection = Get-CMCollection -Name ‘SUM – RING1’ -CollectionType Device
$TargetFolder = Get-Item ‘CTP:\DeviceCollection\Software Updates’

$Parameters = @{
ContainerNodeID = 0;
InstanceKeys = @($Collection.CollectionID)
ObjectType = $TargetFolder.ObjectType;
TargetContainerNodeID = $TargetFolder.ContainerNodeID
}

Invoke-CMWmiMethod `
-ClassName SMS_objectContainerItem `
-MethodName MoveMembers `
-Parameter $Parameters

 

After the code execution my Device Collection ended up in Software Updates folder.

image

 

Have fun!