# Getting the computer host name?

**URL:** <https://forums.powershell.org/t/getting-the-computer-host-name/15256>\
**Category:** PowerShell Help\
**Created:** [November 19, 2020, 7:26am UTC](https://forums.powershell.org/t/getting-the-computer-host-name/15256 "2020-11-19T07:26:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amay0127](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@amay0127](https://forums.powershell.org/u/amay0127)\
**Post date:** [November 19, 2020, 7:26am UTC](https://forums.powershell.org/t/getting-the-computer-host-name/15256/1 "2020-11-19T07:26:08Z")

</div>

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

```
Import-module ActiveDirectory
get-aduser -filter * -Properties ???,description |
select ???,description |
export-csv "c:\temp\workstations.csv" -NoTypeInformation
```

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?

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [November 19, 2020, 7:35am UTC](https://forums.powershell.org/t/getting-the-computer-host-name/15256/2 "2020-11-19T07:35:15Z")

</div>

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:

```
Get-ADUser <username> -properties * | Select *
```

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

---

<div class="post-metadata">

**Author:** ![amay0127](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@amay0127](https://forums.powershell.org/u/amay0127)\
**Post date:** [November 20, 2020, 4:02am UTC](https://forums.powershell.org/t/getting-the-computer-host-name/15256/3 "2020-11-20T04:02:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [November 20, 2020, 4:49am UTC](https://forums.powershell.org/t/getting-the-computer-host-name/15256/4 "2020-11-20T04:49:29Z")

</div>

\<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.

&nbsp;

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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:28pm UTC](https://forums.powershell.org/t/getting-the-computer-host-name/15256/5 "2024-05-16T20:28:16Z")

</div>


