Add single computer to multiple collections listed in a file

Good afternoon,
I am trying to figure out how to add a single computer to multiple collections based on the contents of a file. Basically, I have a frontend hta for deployments. On that hta are checkboxes for various bits of software that should be installed, for example
MS Office. When the hta is submitted, if a software checkbox is checked it writes to a text file on the server indicating it was checked. Once the deployment is completed a script is run via a status filter rule. The intent is for that script to read the file
on the server and add the computer that was just imaged to the collections identified by the checked boxes.
Obviously I am not having much luck which is why I am here looking for a bit of help.
Here is the code that I am working with..both the while and foreach version
$file = New-Object System.IO.StreamReader -Arg $path
while ($line = $file.ReadLine()) {
Add-CMDeviceCollectionDirectMembershipRule -CollectionName $line -Resourceid $ClientName
$file.close()
foreach ($line in (Get-Content $path)) {
Add-CMDeviceCollectionDirectMembershipRule -CollectionName $line -Resourceid $ClientName
I have found that if I manually assign a value to $line everything works as expected, but if I try to read from the file and use either a while or foreach loop it fails.
I can enter a quick write-host and see that the value of each line is being returned as I would expect it but the system just returns the following error for each one:
Add-CMDeviceCollectionDirectMembershipRule : No object corresponds to the specified parameters.
I am sure that there are better ways to do this and I am sure there are cleaner ways to code it, but I am not a Powershell guru so please be kind. ;)

"-Resourceid $ClientName" is not correct because ResourceID != Clientname. See
http://technet.microsoft.com/en-us/library/jj850102(v=sc.20).aspx There is no parameter that accepts the name of the client.
Torsten Meringer | http://www.mssccmfaq.de
Thank you for the suggestion, but that is not the issue. As mentioned in the first post, if I manually assign the collection variable value it works without issue. This is to include *without* changing the $Clientname.
Previously in the script, which was not shown is the following:
$Clientname = (Get-CMDevice -Name $Clientname).ResourceID
If I do a Write-Host $Clientname after that line of code I am returned the correct numeric value. That said, part of my troubleshooting *before* I posted here was to hardcode the numeric resource ID of the client which did not change anything unless the
value of the collection variable was manually set or the variable replaced with the collection name.
So, any ideas as to why it is not able to read and process collection names from a text file?

Similar Messages

  • Sharing iTunes on a single computer with multiple users

    Greetings,
    I have been troubleshooting a problem sharing iTunes on a single computer with multiple users that cropped up a few weeks ago and have not had very good luck.
    Several months ago I successfully set up my wife’s G4 Laptop (PowerPC processor) so that we could share iTunes on that computer. I had just gotten her an “My Book” external hard drive (Western Digital). The iTunes Library will go on this new unit because the internal drive was running out of room. I successfully set the privileges, moved the entire library onto a “Share” directory and everything worked fine.
    In this way, when I got a new CD I could add it to iTunes (under my login, administrator privileges) and she could access it (under her login) to listen to while working on the computer or using her iPod. This arrangement went well for quite awhile.
    About a month and a half ago, when I tried to launch iTunes from my login I received this message:
    “The iTunes Library file is locked, on a locked disk, or you do not have write permission for this file.”
    I think the permissions must have changed when there was an update because my wife is pretty careful about what she does on her computer. Updates were the only thing I could think of that had changed since I had set her computer up. I also noticed that some of the iTunes defaults were different from the last time I had used it to add a CD.
    So, I did some reading and went back through the motions of trying to set it up again. I re-formatted the My Book hard drive to Mac OS Extended (Journaled) added the files back to the external, reset permissions on the external hard drive. (Owners: System, Access: read and write - Group: wheel, Access: read and write – Others: read and write).
    When I now launch iTunes under my login I get this message:
    “The operation cannot be completed because you do not have sufficient privileges for some of the items.”
    What gives? I am the original owner and have always had top-level privileges.
    Can someone point me to any articles or clues as to how I need to set-up iTunes on a single computer to be shared by more than one user? Also, I am considering upgrading to the newer system in a few weeks, so if a solution for OS X 10.5 is available, that would work too.
    Tim

    Was your wife logged into the libray at the time you tried to log in? I have had a similar problem and it was because another user was logged into the library when I attempted to. I got the permission denied banner.

  • HT2688 Working on a single computer with multiple users, I have set things up to allow each user to view and listen to the others' music libraries under the "Shared Library" function.  Can you then connect an iPod touch and copy music from a shared librar

    Working on a single computer with multiple users, I have set things up to allow each user to view and listen to the others' music libraries under the "Shared Library" function.  Can you then connect an iPod touch and copy music from a shared library?

    Was your wife logged into the libray at the time you tried to log in? I have had a similar problem and it was because another user was logged into the library when I attempted to. I got the permission denied banner.

  • How do I add one contact to multiple distribution lists?

    I have employees that work on more than one project and therefore need to be on multiple distribution lists. Outlook groups is able to accomplish this but I can not get it to work on my MAC using Mail and Contacts.
    For Example, John needs to be on the following lists:
    Entire Team
    Project A
    Project B
    Problem I am facing is that when I drag and drop the John from main contacts it will only allow him to be in one group and removes him from the one he was previously added to. How do I get around this?
    Thank you!

    Hello,
    Welcome to Apple Discussions.
    1. Make the first event in iCal when and how you want it.
    2. If you are not in month view, switch to it.
    3. Highlight the event in the calendar view and press Cmd-C (copy).
    4. Click on the blank area on a day you want to copy to.
    5. Press Cmd-V (paste).
    6. Repeat steps 4-5 for all needed dates.
    Best wishes
    John M

  • Delete single item form multiple populated list

    Hi,
    please help me to find a solution!!
    I have 2 listboxes. listbox Description is populated by XML.
    When user selects multiple items at the same time from the Description listbox, they are populated in the listbox and are removed from Description listbox. that works fine.
    But the issue is if the user accidently selects one of the multiple selected items at the same time wrong and want to delete a single items, this doesnt work anymore.
    I can not even click on each single item.
    I try to find a way how to enable user to populate multiple items at the same time and be able to delete each single item, which then should return back to the Description listbox.
    I would really appreciate if you could help me on this!!!
    This is my sample: https://acrobat.com/#d=l0mujTOFduSJFele5R5i3g
    Thanks,
    Diana

    Would you not just reverse your code ..instead of populating listbox from the selections in description and deleting the items out of description, remove the items from listbox and update description then remove the items from listbox.
    Or am I missing something?
    Paul

  • ITunes on a single computer for multiple iPods

    Can a single laptop(Windows Vista Home Premium) be used with 2 iPodTouches? If so how does one configure iTunes to synch the 2 iPods with their different libraries?

    Can a single laptop(Windows Vista Home Premium) be used with 2 iPodTouches?
    Yes.
    how does one configure iTunes to synch the 2 iPods with their different libraries?
    Click here for options.
    (47327)

  • Single PC using Multiple Authorizations

    Why can a single computer use multiple authorizations for the Apple ID if I forget to deauthorize iTunes before reinstalling Windows?  Does the Windows version use the MAC address of the motherboard or a combination of the hard drive volume GUID, registry, and other hardware components?

    deauthorize all earlier last year
    Note: You may only use this feature once per year. The Deauthorize All button will not appear if you have fewer than two authorized computers. If you need assistance on using this feature, please contact iTunes Store support via email (http://www.apple.com/support/itunes/store/).
    About iTunes Store authorization and deauthorization

  • Multiple users on single computer mounting same RAID drive

    Hi I'm a newbie:)
    I have multiple users on a single computer which need to mount the same RAID drive on a different networked computer. I have no problem making the mounts, the only thing is that when each user makes its mount the drive appears multiple times when doing an ls /Volumes. Ie, the first user mounts sparkle and it appears as sparkle. The second user mounts sparkle and it appears as sparkle-1. The third user mounts sparkle and it appears as sparkle-2. In the finder they all show up as just plain sparkle, but for running scripts, the hyphen-# screws things up. Does anyone know of a way to have the same drive mounted without the hyphen-#s?
    Many thanks!
    Megan

    What kind of scripts? I don't think there's any way around the naming problem, but you could use regular expressions. I don't see why sparkle* shouldn't do the trick, or add sparkle-[0-9$] to whatever constuct you have.

  • Add single/multiple line of text in a document library

    Hello,
    I was wondering if there is a way to have a document library that gives you the ability to add text based items in the same column as the file you upload through the library, like you can do through lists. For example, I want to be able to have the freedom
    to add text before or after the file that was uploaded, but still keeping everything in the list (so I'm not actually uploading a file everytime).
    Name <--- column
    Text text text text text text text text text text text text
    Text.jpg
    And here's more text... the end.
    Is this possible? I'm not sure how much extra coding I can add to this because my document libraries are apart of custom web part and adding javascript to the library may break up the web part. 

    i dont think their is OOB way to achieve this.
    I am thinking...
     create 3 Columns
    Text Before as Single text or multiple
    Text After as Single text or multiple
    Calculated column
    Now in Calculated column = Text before + Url(Column) + Text after.
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • Add user to multiple mailman lists at once

    I have multiple mailman lists at my organization that employees need to be added to (when hired) or removed from (when terminated). Is there a terminal command or some other way to add and/or remove one or more addresses to multiple Mailman list at one time? This would really helpful!
    Thanks,
    Ben

    I am already familiar with the mass subscribe/unsubscribe admin page for an individual list. That is what I use currently. My question was is there something similar to do that will apply to multiple lists at once? So that I do not have to visit 6 unsubscribe pages, login/logout each time just to remove a single address from those lists when they no longer work for us?

  • Possible to add multiple 'Collections' to a container

    Hello,
    In DB XML, is a 'Container' equivalent to an xquery 'Collection' ? All of the examples that I see, refer to the container when specifying the collection.
    Basically, I would like to create one Container - call in container1.dbxml Within container1, I would like to have multiple collections, collection1, collection2.
    I would then like to be able to run xqueries such as:
    count(/*) - and get a count of all the docs in both collection1 and collection2 or
    collection("collection1")/* - and get all the nodes in collection1 only
    So, bottom line question - can I add multiple collections to a container, or is a container and collection equivalent in DB XML?
    Thanks for your responses.

    IBB
    What you want to do is create a class that extends the Java XmlResolver class, and register that class with the XmlManager. In your extended class you would want to implement the following function:
    public boolean resolveCollection(XmlTransaction txn, XmlManager mgr, String uri, XmlResults result)
    So that the result argument contains all the documents in the collection specified by the uri. You will likely want to do this by querying the container for the documents for the given collection and copying the results returned by the query to the argument.
    Below is an example of an implementation of the function that resolves the collection to a single document.
    public boolean resolveCollection(XmlTransaction txn, XmlManager mgr, String uri, XmlResults result) throws XmlException {
         XmlDocument doc = mgr.createDocument();
         doc.setName(name);
         doc.setContent(content);
         XmlValue val = new XmlValue(doc);
         result.add(val);
         return true;
    Lauren Foutz

  • Can you have multiple itunes accounts on a single computer?  want to open a separate one for our daughter (but we will manage it).

    just got our daughter a new iTouch, but want to try and keep hers separate from our iPhone stuff.  can you have multiple iTunes accounts on a single computer?

    This is all i know but all you can do is just creat a new one for them both and send all the stuff to the one think u can do that i hope it helps

  • Multiple ipods on single computer?

    Can I manage 2 ipods on a single computer? My wife wants one now . . . Are there any gotchas? Things to know before I buy the 2nd one?
    wayne

    That delt with one iPod and multiple computers. Though there are some hints there that might be helpful.
    Anyone using multiple iPods with a single computer/music library?
    wayne
    HP Windows XP

  • Is it possible to set up multiple iTunes accounts on a single computer?

    is it possible to set up multiple iTunes accounts on a single computer?

    If you do it with a single user account, you will receive update notifications for purchase made on both IDs regardless of which one you're using at the time.  That's slightly frustrating as you get the notification BUT you can't actually update!  In any event, separate user accounts on the computer is the cleaner way to go.

  • Multiple Libraries on a single computer

    Is there a command line switch which can be included in the iTunes shortcut to replace using the SHIFT key used to prompt for Creating and/or Selecting from multiple libraries on a single computer?

    Sorry.
    If you just want to have your iTunes content spread across multiple drives, you can just uncheck the Copy to media folder option in iTunes Preferences> Advanced

Maybe you are looking for