Solved

How to move multiple systems to a collection in SCCM 2012

Posted on 2014-09-22
11
345 Views
Last Modified: 2014-09-23
I'm trying to follow this link to move systems to a collection: http://henryhazot.wordpress.com/2013/10/31/sccm-2012-sp1-powershell-3-adding-computers-to-collection-from-file/ 

But I'm having trouble understanding where I put in my source & target collection.

I have hundreds of system to move and would to use a txt file with systems names to pull them out and put into another collection.

Could anyone please help?
0
Comment
Question by:rdefino
  • 6
  • 5
11 Comments
 
LVL 12

Expert Comment

by:Vaseem Mohammed
ID: 40338864
Any specific reason to use text file? does these systems in text file has some kind of similarity? like same OS or Placed in a seperate OU in AD, same Subnet?
You can easily create a Query Rule collection based on some kind of criteria and more over this Query rule will be dynamic, you don't need to keep maintaining the collection everytime you add new system to network.
0
 

Author Comment

by:rdefino
ID: 40338980
No similarity at all. I have a specific list of systems that need to be moved. Seems the only way is a text or csv file.

Seems it can be done using this code from the web link, but I;m just having issues understanding it.
0
 
LVL 12

Accepted Solution

by:
Vaseem Mohammed earned 500 total points
ID: 40339040
$ErrorActionPreference= 'silentlycontinue'
$CollectionName = "URDeviceCollectiom"

$Computers = get-content C:\URComputersList.txt

Foreach ($Computer in $Computers)
{
add-cmdevicecollectiondirectmembershiprule -collectionname $CollectionName -resourceid (Get-CMDevice -name $Computer).ResourceID
}

Open in new window


This is what you need to use and the computers must be present in database.
0
 

Author Comment

by:rdefino
ID: 40339045
Where do I put the source and destination collection name, and what is the format of the txt file.

This is what has been confusing me?

thanks
0
 
LVL 12

Expert Comment

by:Vaseem Mohammed
ID: 40339057
There is only destination collection the source is txt file with each computer name specified one by one in its own line.
Srv001
Srv002
Srv003
.
.
.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:rdefino
ID: 40339063
Is this were the destination collection name goes?

-collectionname $Mycollectionname -resourceid
0
 
LVL 12

Expert Comment

by:Vaseem Mohammed
ID: 40339091
$CollectionName is a place holder for collection name
Refer to the code I posted before.
URDeviceCollection should be replaced with whatever collection name you have to import into.
Supply the location of txt file.
You need to do only these changes rest of the script will do its work
0
 

Author Comment

by:rdefino
ID: 40339186
I change the error action to see what was happening and I get this error:

Get-CMDevice : This command cannot be run from the current drive. To run this command you must first connect to a
Configuration Manager drive.

I did cd <sitename>

Then I change to the drive and folder the ps1 is stored. then I get the error.
0
 
LVL 12

Expert Comment

by:Vaseem Mohammed
ID: 40339227
Did you start powershell from the config mgr console? The error does not seems to be coming from the script
0
 

Author Comment

by:rdefino
ID: 40339242
Yes id id. They I had to run "Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass"  to turn of sign security error.

Then I changed to the e: drive, change into the folder and ran the ps1. I git the same error.
0
 

Author Comment

by:rdefino
ID: 40339262
I got it to work. I changed to cd sitename:
Then called the ps1 from there instead of changing to the drive.

Thanks for the help!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now