none
A user input script to modify the details of a computer in AD RRS feed

  • Question

  • Hi Scripting Guru's,

    We have recently started using Active Directory as our Actual directory. This means we have computer name listed with Users first name, last name, and Office. The description field has the type of PC in it. eg, (in brackets are the Attribute names where applicable)

    Name First Name (givenName) Last Name(sn) Office(physicalDeliveryOfficeName) Description

    PC-001 Joe Bloggs A01 Optiplex 780

    What I'm looking for is a method for the other members of the team to add, and edit these details when new computers are added to the OU via MDT. It would require them to hunt for the PC name, in one of two OU's (Desktops and Laptops) then be able to manually add the details above for the other fields.

    Thanks in advance,

    D

    Tuesday, April 15, 2014 3:08 PM

Answers

  • All,

    As promised here is the script I used to get the job done. I have omitted the form code as that isn't relevant:

      

    $UpdateBTN_OnClick= 
    {

    Set-ADObject $ADCom -replace @{givenName=$fnTB.Text}
    Set-ADObject $ADCom -replace @{sn=$snTB.Text}
    Set-ADObject $ADCom -replace @{description=$desTB.Text}
    Set-ADObject $ADCom -replace @{physicalDeliveryOfficeName=$offTB.Text}

    [System.Windows.Forms.MessageBox]::Show("Update Complete." , "Update Status")

    }

    $finBTN_OnClick= 


      $computerAttributes.close()
      stop-process -Id $PID

    }

    $SearchBTN_OnClick= 
    {
    $ADCom = Get-ADcomputer -identity $comTB.Text
    $fnTB.Text = Get-ADcomputer $ADCom -Properties givenName -OutVariable data| %{$_.givenName}
    $snTB.Text = Get-ADcomputer $ADCom -Properties sn -OutVariable data| %{$_.sn}
    $desTB.Text = Get-ADcomputer $ADCom -Properties description -OutVariable data| %{$_.description}
    $offTB.Text = Get-ADcomputer $ADCom -Properties physicalDeliveryOfficeName -OutVariable data| %{$_.physicalDeliveryOfficeName}

    }

    Here's how it works:

    When one of the IT team inputs the PC name into the text box labelled $ADCom and clicks the search button, it fills in the other text boxes with the relevant information, if any is present. The IT support user can then make the relevant changes and click update. once the update is complete it pops up with a message box stating such. Closing the box and then clicking the Finish button completes the process by closing the form and the PowerShell window.  

    If anyone has any suggestions on improving the script, I would welcome any feedback. As I've said I'm not professionally trained in PowerShell at all.

    Hope this is of use to someone in the future,

    D


    • Edited by Dazzelin Tuesday, May 13, 2014 11:12 AM
    • Marked as answer by Dazzelin Tuesday, May 13, 2014 12:19 PM
    Tuesday, May 13, 2014 11:09 AM
  • This has noting to do with your original question which was about how to change the description field.

    Why would you do multiple "sets" what you can do it all in one "set".

    Well - you are learning some PowerShell and something about forms so have a good time.

    Try posting mure targeted question in the future.  I think you will find that that will get you a quicker and better answer.

    Here is another hint:
    Don't do multiple requests for the same thing.   Learn how to use PowerShell and objects correctly.

    Example:

    # NOT THS
    $ADCom = Get-ADcomputer -identity $comTB.Text
    $fnTB.Text = Get-ADcomputer $ADCom -Properties givenName -OutVariable data| %{$_.givenName}
    $snTB.Text = Get-ADcomputer $ADCom -Properties sn -OutVariable data| %{$_.sn}
    $desTB.Text = Get-ADcomputer $ADCom -Properties description -OutVariable data| %{$_.description}
    $offTB.Text = Get-ADcomputer $ADCom -Properties physicalDeliveryOfficeName -OutVariable data| %{$_.physicalDeliveryOfficeName}
    
    #Do it this way:
    
    $com=Get-ADcomputer $comTB.Text -Properties physicalDeliveryOfficeName
    $fnTB.Text =$com.givenName
    $snTB.Text =$com.sn
    $desTB.Text=$com.description
    $offTB.Text=$com.physicalDeliveryOfficeName
    
    

    See - much cleaner and much faster.

    It is critical to learn to walk before you try to fly.  Take some time to learn PowerShell and these things will be much easier.


    ¯\_(ツ)_/¯

    • Marked as answer by Dazzelin Tuesday, May 13, 2014 3:11 PM
    Tuesday, May 13, 2014 2:54 PM

All replies

  • For Clarity as my original post spacing seems to have failed!

    Name PC-001

    First Name (givenName) Joe

    Last Name(sn) Bloggs

    Office(physicalDeliveryOfficeName) A01

    Description Optiplex 780

    Tuesday, April 15, 2014 3:12 PM
  • Modifying PC names require administrative privilege. Therefore, running the script requires elevation. Providing administrative privilege in a corporate environment is a concern of security. Therefore, it's better to have the administrators to name the PCs, rather than the users.

    Balaji Kundalam

    Tuesday, April 15, 2014 3:19 PM
  • Thanks for the reply Balaji,

    It will only be other members of the IT support team who will be doing this. They already have administrator access to the AD.

    What I'm looking for is something simpler for them,  then to modify the attribute settings manually (as they are not the most intuitive or obviously named in some cases).

    Also, the PC names will not be modified in any way just the other attributes listed above.

    Thanks,

    D

    Tuesday, April 15, 2014 3:26 PM
  • A computer object in AD does not have those attributes. You would have to alter AD with ADSI Edit to add those attributes.

    Try asking, in plain English, a question that describes what you want to do without trying to specify how you want to do it.  I suspecy you are really asking a different question.


    ¯\_(ツ)_/¯

    Tuesday, April 15, 2014 3:56 PM
  • What I'm looking for is a method for the other members of the team to add, and edit these details when new computers are added to the OU via MDT. It would require them to hunt for the PC name, in one of two OU's (Desktops and Laptops) then be able to manually add the details above for the other fields.

    Hi JRV,

    Thanks for your reply. I have already made the changes in ADSIEDIT adding these attributes. As far as my apparent lack of plain English goes, I think the above question makes perfect sense, however in the interest of clarity, allow me to elaborate:

    A computer is automatically placed in the correct OU during deployment.

    We then have to manually hunt through the Attributes to add the details of users name, office and the type of machine it is.

    What I'm wondering is, if anyone with knowledge could reply to the post with a method of inputting these details without having to hunt through the attributes.

    I hope this clarifies things,

    D

    Wednesday, April 16, 2014 7:54 AM
  • First Name (givenName), Last Name(sn), Office(physicalDeliveryOfficeName) already exist on the user objects.

    Why would you want to replicate these on the computer objects?

    I would recommend creating a relationship between the objects.

    The user objects have custom fields, where you can enter the workstation details and link them that way.

    extensionAttribute1 through extensionAttribute15

    The commands you want to look at are Get-ADUser/Set-ADUser and Get-ADComputer/Set-ADComputer.

    You can use Get-ADUser including the extensionAttribute that you add the computer information in, and then pipe that to Get-ADComputer to get the rest of the information.

    Wednesday, April 16, 2014 10:19 AM
  • Thanks for the reply Newbie Jones,

    A nice idea, but a majority of the 800 or so PC's have already been updated. A change of attributes at this stage would mean re-doing that work. Also, the majority of the office don't know how to use PowerShell and would not be comfortable using it. This is why I'm looking for a script that might pop up a message box allowing them to input the data in a quick and simple way. 

    The decision to use the directory in this way was not mine. However, now that it's here, I'd like to make it as functional and practical as possible.

    Thanks for the suggestion though,

    D

    Wednesday, April 16, 2014 10:31 AM
  • As you can see it is hard to understand what you are asking.

    There is no way to automatically add these items to a computer object.

    Normally we would add the user to the "managedBy" attribute.  Why you want to add the user properties to the computer object is a mystery.

    Look carefully at the "managedBy" attribute.

    http://msdn.microsoft.com/en-us/library/ms676857(v=vs.85).aspx

    If you must use custom attribute you will find that you will need to update them when you assign the user.  A standard user cannot easily update AD.  If you delegate this capability to all users you will have issues which si why you do not see it being done.

    There are management packages that do this when a user is assigned.  I suspect that is how AD got altered.  I haven't seen any companies using these packages for years.

    To update these attributes you would use AD CmdLets like Get-AdUser and Set-AdComputer.  See help for how to add values to custom attributes.


    ¯\_(ツ)_/¯


    • Edited by jrv Wednesday, April 16, 2014 12:15 PM
    Wednesday, April 16, 2014 12:15 PM
  • You are asking for a "message box".  By this I suspect you really mean a Windows Form.  This would be a custom application that you want.  You can use Windows Forms classes to build forms in PowerShell or you could use an HTA. Look in the learning pages for examples on how to build these kinds of scripts.

    http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

    You are not likely to find a script written that does what you are asking for.

    Like many requests what you are asking for sounds easy enough until you look at all of the steps required to accomplish building the application.  Look through the repository for examples of GUI based scripts. You will see what I am referring to when you have reviewed a few.  You may even find on that helps you to see how to build what you are trying to build.


    ¯\_(ツ)_/¯


    • Edited by jrv Wednesday, April 16, 2014 12:24 PM
    Wednesday, April 16, 2014 12:20 PM
  • Hello JRV,

    Please do not misunderstand my tone in this email but I'm slightly frustrated by your response(s). I don't think Newbie Jones misunderstood my request as his suggestion was a good one and along the lines of the end goal I'm trying to accomplish. Due to company restrictions and the amount of work already put into this, however, his suggestion was not something I could use.

    I never asked for any of the input to be automated.

    Your suggestion of the managedBy attribute again means altering a different attribute and again would mean re-doing a large amount of work and is therefore not practical.

    The apparent "Mystery" of my request is really not important here, though I'll humour you with a an example:

    Our Virus protection software alerts us to malware, virus' and the like, by PC name. We could then use AD to find the owner and location of the PC with ease.

    You yet again mention Standard user making these changes so I will repeat as before that only members of our IT support team will be using this.

    You then list some examples of Powershell commands to make these changes and so, once again, I'll mention that my IT colleagues are not able to use PowerShell.

    Finally, your link to the repository is where I'm looking whilst waiting to see if someone had any knowledge of a script that does something similar that I can amend/edit/tweak to suit my needs. I never suggested that it would be easy. If it were, likely I wouldn't be on a forum requesting help for much more experienced professionals.

    In closing, I'm not sure why you posted three times to a question you believe can't be done, though I appreciate you may not understand my request.

    If anyone does have any idea on how I might accomplish this, I would be very grateful. I appreciate that it's unorthodox as stated, this is coming from above. It is not my preferred method.

    Thanks in advance,

    D

    Wednesday, April 16, 2014 1:26 PM
  • I didn't say it can't be done.  I only noted that no one is going to write an application for you.  You are free to write this and post back with questions.

    I have written many GUI (Windows Forms) applications that do what you ask but nor for a computer object.

    When we assign a user to a computer we would normally set the ManagedBy to the user's object.  We can now see all of the attributes that you are trying to copy when we look at the computer object.  Since you have reinvented the wheel you will be forced to create all of the tools to manage the creation. This can be done but it is not a simple thing if you are not a programmer. 

    If you just want a non-GUI script that will copy a users info to the computer fields, that can be done easily with VBScript or PowerShell using either CmdLets or ADSI Net classes.  There are hundreds of examples of this in the repository.

    You say you have a preferred method but you have not stated what that method is.

    Here is what you wrote:  "What I'm looking for is a method for the other members of the team to add, and edit these details when new computers are added to the OU via MDT. It would require them to hunt for the PC name, in one of two OU's (Desktops and Laptops) then be able to manually add the details above for the other fields."

    What is meant by "manually search"?  ADUC is a form of graphical search.  ADSI can easily search by name.

    ([adsisearcher]'samaccountname=pc001$').FindOne()

    This will find a computer named "PC001" in AD.  It can be run on any workstation with PowerShell installed.  Finding a pc by name does not require a GUI or a big script or any special tools. 

    If you need more info on how AD works just ask your Domain Admins.  They can show you how AD is set up and managed globally and how LDAP queries work.  I am sure once you become more familiar with AD that you will be able to see how to design the tools you need.  I don't recommend trying to build GUI tools until you become more skilled with PowerShell although using this as a learning excuse might not be a bad idea.


    ¯\_(ツ)_/¯


    • Edited by jrv Wednesday, April 16, 2014 2:08 PM
    Wednesday, April 16, 2014 2:05 PM
  • JRV,

    I never stated I have a preferred method nor does it mention in the quote you put in your post the phrase "manually search". Please read posts carefully before replying. It would save people having to reply with the same information several times over.

    Thanks for the assistance in "search for a PC name" but at no point did I say that was what I needed.

    I am fully aware of how AD works and I am a domain admin. My statement in an earlier post regarding the changes I made to ADSIEdit should have made that clear.

    "I have written many GUI (Windows Forms) applications that do what you ask but nor for a computer object."

    I find it strange that rather than simply help with my project by showing me some examples of these you choose to miss-quote me, patronize me and supply answers  to questions I haven't asked.

    You are either not understanding me or not reading my posts correctly, but in any case, please feel free not to respond to my posts in future.

    D




    • Edited by Dazzelin Wednesday, April 16, 2014 2:35 PM
    Wednesday, April 16, 2014 2:34 PM
  • What does your script look like so far? What errors are you getting?


    -- Bill Stewart [Bill_Stewart]

    Wednesday, April 16, 2014 2:39 PM
    Moderator
  • Hi Bill,

    I don't  have a complete script as yet though I'm working with a few examples from the repository amending and editing them to work for my needs.

    EDIT:

    I've just found a post to "a script to edit an AD users account" and an answer.

    ChenV looks like he has the script I'm looking for, all be it for the user rather than the computer object.

    His post here looks exactly like what I had in mind. The form is the sort of simple input I'm looking for my colleagues to be able to add/edit the attributes of AD machines.

    I'll hunt the repository for his examples to follow unless anyone happens to have the links

    I appreciate the assistance,

    D


    • Edited by Dazzelin Wednesday, April 16, 2014 2:58 PM
    Wednesday, April 16, 2014 2:57 PM
  • JRV,

    I never stated I have a preferred method nor does it mention in the quote you put in your post the phrase "manually search". Please read posts carefully before replying. It would save people having to reply with the same information several times over.

    Thanks for the assistance in "search for a PC name" but at no point did I say that was what I needed.

    I am fully aware of how AD works and I am a domain admin. My statement in an earlier post regarding the changes I made to ADSIEdit should have made that clear.

    "I have written many GUI (Windows Forms) applications that do what you ask but nor for a computer object."

    I find it strange that rather than simply help with my project by showing me some examples of these you choose to miss-quote me, patronize me and supply answers  to questions I haven't asked.

    You are either not understanding me or not reading my posts correctly, but in any case, please feel free not to respond to my posts in future.

    D




    You wrote: " It would require them to hunt for the PC name"

    Tis implies a manula search.  "hunt" is a synonym for "manual search" as opposed to a targeted query as I have posted.


    ¯\_(ツ)_/¯

    Wednesday, April 16, 2014 3:51 PM
  • I don't  have a complete script as yet though I'm working with a few examples from the repository amending and editing them to work for my needs.
    Great. A forum like this one is much better to suited to answering specific questions. What we recommend is to continue writing your script, and If you run into problems, it is always best to whittle down the code to the bare minimum needed to reproduce the problem. This is to make the problem easy for others to reproduce. Also tell the exact error message(s) you receive, if any.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, April 16, 2014 3:55 PM
    Moderator
  • Hi Bill,

    I don't  have a complete script as yet though I'm working with a few examples from the repository amending and editing them to work for my needs.

    EDIT:

    I've just found a post to "a script to edit an AD users account" and an answer.

    ChenV looks like he has the script I'm looking for, all be it for the user rather than the computer object.

    His post here looks exactly like what I had in mind. The form is the sort of simple input I'm looking for my colleagues to be able to add/edit the attributes of AD machines.

    I'll hunt the repository for his examples to follow unless anyone happens to have the links

    I appreciate the assistance,

    D


    As I posted.  A search of the repository or the web will get you examples.  You will not likely find one that is exactly what you want.  The GUI will takes some learning with PowerShell to get working.

    I cannot tell why you think I am picking on you.  I am just letting you know that there is no script that I know of that does what you want and it is unlikely that anyone will write one to your spec.  Starting with a [possible script is a good way to get started learning PowerShell.  You will still need to master AD Net classes and methods. as well as Windows Forms.  All of this can be done but it may take you a bit of time.

    Here is a site with plenty of info and examples on how to use Forms with PowerShell. http://www.sapien.com/forums/viewforum.php?f=21&sid=b411820f3f1918520344dd3a351a4120

    And here: http://www.sapien.com/blog/topics/user-interface-design-for-administrators/

    There is also a free tool for forms design in PowerShell on that site.


    ¯\_(ツ)_/¯

    Wednesday, April 16, 2014 3:57 PM
  • I know you have updated 800 machines, but one of the main purposes of Powershell is mass operations.

    This isn't a large amount of work to update.

    Basic process would be something like :-

    • Run a report of the current configuration and attributes
    • Clear the current data from the computer objects
    • (At this point, I would revert the AD schema for the computer objects back to what it was)
    • Using the original report, script an update to link the user and computer objects correctly.

    Once this has been done, you can produce a simple instruction or GUI for your support team to update the computer object 'Managed By' field.

    Your support team also need to start learning PowerShell.  It's the future you know :-)


    Wednesday, April 16, 2014 4:09 PM
  • I prefer using ADUC because everything is right there.  We can also add custom scripts to the ADUC menu that will do this.  Jus add a right context item to the users menu that sets the assigned computer.  It should be about a three line script and a registry edit.  No help desk can just assign a user visually.  An inputbox can be used to collect the computer name.


    ¯\_(ツ)_/¯

    Wednesday, April 16, 2014 4:15 PM
  • All,

    Thanks for your suggestions. With help from several separate sources of the repository I think I have it. Once I polish it up and see if I can condense the code a little more, I'll post it back here just in case there are other lunatic management at other companies who want to do this in the future. 

    JRV,

    It is apparently clear now that English is not your first language. Sincerest apologies. Had I have realised this, I would have been a lot more patient in my responses to the misunderstandings. However, I was misled by your original post to me suggesting I need to use plain English. As I have, and you couldn't understand me, perhaps you leave this suggestion out of your future posts? It comes over as patronising and can create confusion.

    D



    • Edited by Dazzelin Thursday, April 17, 2014 9:11 AM
    Thursday, April 17, 2014 9:10 AM
  • , perhaps you leave this suggestion out of your future posts? It comes over as patronising and can create confusion.

    D



    You seem to think that someone disagreeing with your question is somehow an insult. It is clear that you are not sure of what you are asking. You have little or no experience with PowerShell and Active Directory. My statements were intended to get you to rethink your request, use correct technical terminology and to understand, as others here have also pointed out, that your request is too broad and somewhat ambiguous.

    Stop acting like a 6 year old and pretending you have such a sensitive little ego.  If you cannot take criticism and suggestion then you are in the wrong business.

    I recommend spending time learning the tools you are asking others to use for you.  You should also take the time to learn to listen to others with decades more experience tan you.  You might learn something.

    Note that your first major complaints were because I suggested looking in the repository.  Now that is where you are looking.  Bravo!  If you had listened earlier you could have saved yourself a lot of grief.


    ¯\_(ツ)_/¯

    Thursday, April 17, 2014 12:37 PM
  • *sigh*

    My last post as I'm bored of this now.

    "You seem to think that someone disagreeing with your question is somehow an insult."

    Nope. I think someone telling me to use English when they have at best a pigeons grasp of the language is an insult.

    "It is clear that you are not sure of what you are asking"

    Nope. I knew what I needed, you did not.

    "You have little or no experience with PowerShell and Active Directory"

    I never stated I was knowledgeable....that's why I'm here!

    "as others here have also pointed out, that your request is too broad and somewhat ambiguous."

    I don't know where your getting that from.

    "Stop acting like a 6 year old and pretending you have such a sensitive little ego."

    Yes well I'm not the one resorting to name calling am I? Not that you're very good at it.

    "If you cannot take criticism and suggestion then you are in the wrong business."

    And what business is it that I'm in? Do you know? Or do you mean IT support in general is synonymously renowned the world over for its harsh critical environment. Not what I've found in my experience at least. Do you get a lot of criticism?

    "listen to others with decades more experience tan you"

    Again, it's the reason I came here. I would have gladly listened to your advise were it pertinent to the question.

    "Note that your first major complaints were because I suggested looking in the repository.  Now that is where you are looking.  Bravo!  If you had listened earlier you could have saved yourself a lot of grief.."

    Nope. Never complained about that. I was merely stating that that was were I was already searching for information. Below is my quote from post 23 hours ago. I had already spent some time there so not sure how much time you "saved me":

    "Finally, your link to the repository is where I'm looking whilst waiting to see if someone had any knowledge of a script that does something similar that I can amend/edit/tweak to suit my needs. I never suggested that it would be easy. If it were, likely I wouldn't be on a forum requesting help for much more experienced professionals."

    Here again, you see I am quite honest about my lack of ability here. No bruised little 6 year old ego to be seen.

    I thank you for your post though JRV. It has been a blast. I leave you with something that might be of use to you in the future:

    help  [help]  
    verb (used with object)
    1.
    to give or provide what is necessary to accomplish a task or satisfy a need; contribute strength or means to; render assistance to; cooperate effectively with; aid; assist: He planned to help me with my work. Let me help you with those packages.
    2.
    to save; rescue; succor: Help me, I'm falling!
    3.
    to make easier or less difficult; contribute to; facilitate: The exercise of restraint is certain to help the achievement of peace.
    4.
    to be useful or profitable to: Her quick mind helped her career.
    5.
    to refrain from; avoid (usually preceded by can  or cannot  ): He can't help doing it.


    D


    • Edited by Dazzelin Thursday, April 17, 2014 1:21 PM
    Thursday, April 17, 2014 1:02 PM
  • I really wish you were paying attention and had some experience.

    The phrase "use plain English" means don't attempt to use technical language when describing a problem. When people attempt to use technical terms incorrectly itmakesunderstanding what is being asked much more difficult.

    When we are taking requirements for software from non-technical people it is normal for some to attempt to describe what they want and mix in tech terms they do not really understand.  This can make understanding the requirement very difficult.  Read any book on requirements gathering and analysis and you will see the instruction "use plain English"  or "use plain language" repeated.

    If you could learn to ask questions correctly then this would no happen. You are convinced that you know what you are saying but your use of technical terms shows that you are not formally trained in this area of systems.

    The take-away here is that you need to do a little more homework.  Of course you will not take that as a constructive suggestion but I leave you with it.  Think about it for a few days before throwing out the suggestions.


    ¯\_(ツ)_/¯

    Thursday, April 17, 2014 1:52 PM
  • Please understand that we get a lot of "write a custom script for me" questions, but that's not the purpose of this forum. For best results, please ask a single, specific question. Giving a general design specification for something you want to do isn't the right kind of question because you're basically asking someone to write custom code for you. Remember that the help here is free and we're volunteers.


    -- Bill Stewart [Bill_Stewart]

    Thursday, April 17, 2014 2:19 PM
    Moderator
  • All,

    As promised here is the script I used to get the job done. I have omitted the form code as that isn't relevant:

      

    $UpdateBTN_OnClick= 
    {

    Set-ADObject $ADCom -replace @{givenName=$fnTB.Text}
    Set-ADObject $ADCom -replace @{sn=$snTB.Text}
    Set-ADObject $ADCom -replace @{description=$desTB.Text}
    Set-ADObject $ADCom -replace @{physicalDeliveryOfficeName=$offTB.Text}

    [System.Windows.Forms.MessageBox]::Show("Update Complete." , "Update Status")

    }

    $finBTN_OnClick= 


      $computerAttributes.close()
      stop-process -Id $PID

    }

    $SearchBTN_OnClick= 
    {
    $ADCom = Get-ADcomputer -identity $comTB.Text
    $fnTB.Text = Get-ADcomputer $ADCom -Properties givenName -OutVariable data| %{$_.givenName}
    $snTB.Text = Get-ADcomputer $ADCom -Properties sn -OutVariable data| %{$_.sn}
    $desTB.Text = Get-ADcomputer $ADCom -Properties description -OutVariable data| %{$_.description}
    $offTB.Text = Get-ADcomputer $ADCom -Properties physicalDeliveryOfficeName -OutVariable data| %{$_.physicalDeliveryOfficeName}

    }

    Here's how it works:

    When one of the IT team inputs the PC name into the text box labelled $ADCom and clicks the search button, it fills in the other text boxes with the relevant information, if any is present. The IT support user can then make the relevant changes and click update. once the update is complete it pops up with a message box stating such. Closing the box and then clicking the Finish button completes the process by closing the form and the PowerShell window.  

    If anyone has any suggestions on improving the script, I would welcome any feedback. As I've said I'm not professionally trained in PowerShell at all.

    Hope this is of use to someone in the future,

    D


    • Edited by Dazzelin Tuesday, May 13, 2014 11:12 AM
    • Marked as answer by Dazzelin Tuesday, May 13, 2014 12:19 PM
    Tuesday, May 13, 2014 11:09 AM
  • And here's the finished product. 

    I have blocked out the company name in the top corner.

    I intend to add a second tab that will be used to amend attributes for Users including the locking and unlocking of accounts. should make life much easier for us all.

    Thanks,

    D


    • Edited by Dazzelin Tuesday, May 13, 2014 11:29 AM
    Tuesday, May 13, 2014 11:26 AM
  • This has noting to do with your original question which was about how to change the description field.

    Why would you do multiple "sets" what you can do it all in one "set".

    Well - you are learning some PowerShell and something about forms so have a good time.

    Try posting mure targeted question in the future.  I think you will find that that will get you a quicker and better answer.

    Here is another hint:
    Don't do multiple requests for the same thing.   Learn how to use PowerShell and objects correctly.

    Example:

    # NOT THS
    $ADCom = Get-ADcomputer -identity $comTB.Text
    $fnTB.Text = Get-ADcomputer $ADCom -Properties givenName -OutVariable data| %{$_.givenName}
    $snTB.Text = Get-ADcomputer $ADCom -Properties sn -OutVariable data| %{$_.sn}
    $desTB.Text = Get-ADcomputer $ADCom -Properties description -OutVariable data| %{$_.description}
    $offTB.Text = Get-ADcomputer $ADCom -Properties physicalDeliveryOfficeName -OutVariable data| %{$_.physicalDeliveryOfficeName}
    
    #Do it this way:
    
    $com=Get-ADcomputer $comTB.Text -Properties physicalDeliveryOfficeName
    $fnTB.Text =$com.givenName
    $snTB.Text =$com.sn
    $desTB.Text=$com.description
    $offTB.Text=$com.physicalDeliveryOfficeName
    
    

    See - much cleaner and much faster.

    It is critical to learn to walk before you try to fly.  Take some time to learn PowerShell and these things will be much easier.


    ¯\_(ツ)_/¯

    • Marked as answer by Dazzelin Tuesday, May 13, 2014 3:11 PM
    Tuesday, May 13, 2014 2:54 PM
  • Hello my old friend JRV I hope you've been well. :)

    This has noting to do with your original question which was about how to change the description field.

    Please see original post where I state:

    Name First Name (givenName)

    Last Name(sn)

    Office(physicalDeliveryOfficeName

    Description

    PC-001 Joe  Bloggs A01  Optiplex 780

    What I'm looking for is a method for the other members of the team to add, and edit these details when new computers are added to the OU via MDT

    It was all the details I needed not just the description.

    I'll skip past the condescension in your post and instead jump to the best bit of your post:

    # NOT THS
    $ADCom = Get-ADcomputer -identity $comTB.Text
    $fnTB.Text = Get-ADcomputer $ADCom -Properties givenName -OutVariable data| %{$_.givenName}
    $snTB.Text = Get-ADcomputer $ADCom -Properties sn -OutVariable data| %{$_.sn}
    $desTB.Text = Get-ADcomputer $ADCom -Properties description -OutVariable data| %{$_.description}
    $offTB.Text = Get-ADcomputer $ADCom -Properties physicalDeliveryOfficeName -OutVariable data| %{$_.physicalDeliveryOfficeName}
    
    #Do it this way:
    
    $com=Get-ADcomputer $comTB.Text -Properties physicalDeliveryOfficeName
    $fnTB.Text =$com.givenName
    $snTB.Text =$com.sn
    $desTB.Text=$com.description
    $offTB.Text=$com.physicalDeliveryOfficeName

    Brilliant. Thanks for the feedback I'll apply this now. This is the reason I came here in the first place. Suggestions from professionals with more experience than me.

    Thanks JRV.

    Be well.

    D


    • Edited by Dazzelin Tuesday, May 13, 2014 3:04 PM
    Tuesday, May 13, 2014 3:03 PM
  • Yes - you are right.  I was thinking -about another thread.

    Ok.  Just try to not do   so many queries when one will get you all you need.  Both "get" and "set" commands can do all in one call.  You will also need to trap errors to prevent updates from damaging the objects.

    A bigger suggestion is to spend time learning the basics.  It will save you a lot of issues and time.  YOu are makingmistakes that indicate a lack of knowledge of the very basic ideas of PowerShell.

    Good Luck with your new form.


    ¯\_(ツ)_/¯

    Tuesday, May 13, 2014 3:18 PM