martedì 26 luglio 2011

SCCM 2007 - Fill collection from text file (import machine names)

Hi all,
today I was trying to fill a collection in SCCM2007 importing the machines name from a text file I produced manually using Excel due to some manual work on them (filtering, manual check and so on).

I first tried to import them using the "right-click-tool-menu" on the collection itself.
At first it seems the right way to do it but then I noticed this introduced some strange behaviour in the collection as when you want to edit the collection (right click, properties) you notice that some entries are EMPTY!
So you don't know what you are going to remove...

Very bad..
So I tried other ways, also powershell scripts.
But I was not very satisfied.

So at the end I found my way, ok, not the best one probably, but it does the job.

The way is to create a query in the collection where you put the machine list like this:

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System  where  SMS_R_System.Name in   ( "PCNAME001" , "PCNAME002" , "PCNAME003" )

Ok, it works.
The problems now are two from my point of view.

1. it is a little bit boring to write the query manually putting all the machine names when I have it in excel and I could do a copy & paste
2. let's say in the future I need to modify the collection adding or removig some machine... not very easy to do

So I found my way also on this, 15 minutes and I wrote this small but useful application in VB.NET:

I write (paste) the machine list on the left, click the upper button and I obtain the query to paste in SCCM.
If I have to modify an existing collection, I copy and paste the query from SCCM to the right textbox and click the bottom button and on the leftI obtain the machine list, then I can edit it adding and removing, click the upper button again and I have the new query to pase in SCCM

For sure there are other tools/ways around, but for what I have to do, this is a good solution for me :)


1 commento: