Getting the computer host name?

Welcome Forums General PowerShell Q&A Getting the computer host name?

Viewing 2 reply threads
  • Author
    Posts
    • #272680
      Participant
      Topics: 2
      Replies: 1
      Points: 28
      Rank: Member

      Trying to export a file that has the computer name and description for all workstations on our company’s AD list.

      That’s the code I have so far, which works great, except that I have no idea what to put in that ??? space to get the computer name. I’ve tried everything I could think of, but nothing has worked. Help?

      • This topic was modified 2 weeks ago by amay012704.
    • #272701
      Participant
      Topics: 2
      Replies: 382
      Points: 523
      Helping Hand
      Rank: Major Contributor

      The User object does not have have an attribute for the user’s computer.  There are methods for updating one of the other attributes to store this information using, for example, one of the ExtensionAttributes.

      If you know that your organisation stores this data in the User object, you’ll have to identify which attribute you’re using yourself.  The easiest way to do this is to find a user that you know has that attribute set then run:

      You can then identify from all the displayed properties which attribute(s) you’re using to store this data.

      • #272974
        Participant
        Topics: 2
        Replies: 1
        Points: 28
        Rank: Member

        I see what you mean, but trying to do anything with <username> with literally any username only gets me RedirectionNotSupported errors.

    • #273001
      Participant
      Topics: 2
      Replies: 382
      Points: 523
      Helping Hand
      Rank: Major Contributor

      <username> is a placeholder, you should replace it with the username of a user in your organisation.  I used it to demonstrate that you want to get the attributes of a single user, not all users (-filter *) as you were doing previously.

       

      Edit: to be clear, you should replace the whole thing, including the ‘<>‘ with the username.  As <> are redirection operators.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.