# powershell issues with export

**URL:** <https://forums.powershell.org/t/powershell-issues-with-export/14319>\
**Category:** PowerShell Help\
**Created:** [May 4, 2020, 2:20pm UTC](https://forums.powershell.org/t/powershell-issues-with-export/14319 "2020-05-04T14:20:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthew-moore](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/matthew-moore/32/106_2.png) [@matthew-moore](https://forums.powershell.org/u/matthew-moore)\
**Post date:** [May 4, 2020, 2:20pm UTC](https://forums.powershell.org/t/powershell-issues-with-export/14319/1 "2020-05-04T14:20:42Z")

</div>

```auto
$users = get-content "C:\Users\Public\bulk AD creation\users.txt"

foreach ($user in $users) {

$domain = "@xxx.org"

$finalusernew = $user + $domain

$FinalUser = Get-ADUser -Server "domain_server" -Filter {UserPrincipalName -eq $finalusernew} | select UserPrincipalName

#if (!$FinalUser) { Write-Host "$finalusernew is Missing" } Else { }

if (!$FinalUser) { Write-Host "$finalusernew is Missing" } Else { Write-Host User Does exist $finalusernew } #$FinalUser} }

```

&nbsp;

&nbsp;

i am not sure how to get the results to csv file.

&nbsp;

here is the screen output

&nbsp;

[lindsey.alexander@xxx.org](mailto:lindsey.alexander@xxx.org) is Missing  
User Does exist [haley.arose@xxx.org](mailto:haley.arose@xxx.org)  
User Does exist [brian.blevins@xxx.org](mailto:brian.blevins@xxx.org)  
User Does exist [amanda.bond@xxx.org](mailto:amanda.bond@xxx.org)  
User Does exist [rachelle.bowen@xxx.org](mailto:rachelle.bowen@xxx.org)

I have tried using export-csv and other methods and have failed.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 4, 2020, 2:54pm UTC](https://forums.powershell.org/t/powershell-issues-with-export/14319/2 "2020-05-04T14:54:45Z")

</div>

Using Write-Host turns rich and powerfull objects into stupid pixels on the screen. Do not use it until you’re really sure you need it.

```
$users = get-content “C:\Users\Public\bulk AD creation\users.txt”
$result = foreach ($user in $users) {
$domain = “@xxx.org”
$finalusernew = $user + $domain
$FinalUser = Get-ADUser -Server “domain_server” -Filter { UserPrincipalName -eq $finalusernew }
[PSCustomObject]@{
Username = $finalusernew
IsPresent = if ($FinalUser) { $true }else { $false }
}
}
$result
```
  
You can pipe $result to Export-Csv.

---

<div class="post-metadata">

**Author:** ![matthew-moore](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/matthew-moore/32/106_2.png) [@matthew-moore](https://forums.powershell.org/u/matthew-moore)\
**Post date:** [May 4, 2020, 3:06pm UTC](https://forums.powershell.org/t/powershell-issues-with-export/14319/3 "2020-05-04T15:06:42Z")

</div>

thank you olaf. Is there any way to get the words in place of true or false. I have helpdesk people that are going to look for those words . True / False they might not understand even though i do.

write host was there so i could see the script working. But thanks for the heads up

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 4, 2020, 3:13pm UTC](https://forums.powershell.org/t/powershell-issues-with-export/14319/4 "2020-05-04T15:13:42Z")

</div>

Wow … helpdesk people do not understand true and false? Really? They might look for a better fitting job. 😉 😃

You can see where the $true or $false is set, right? Just change it to whatever your helpdesk people can understand … maybe a simple “yes” and “no” or “there” and “gone”? 😉

---

<div class="post-metadata">

**Author:** ![matthew-moore](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/matthew-moore/32/106_2.png) [@matthew-moore](https://forums.powershell.org/u/matthew-moore)\
**Post date:** [May 4, 2020, 3:39pm UTC](https://forums.powershell.org/t/powershell-issues-with-export/14319/5 "2020-05-04T15:39:13Z")

</div>

we call them the helpless desk … thank you so much .

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 4, 2020, 3:50pm UTC](https://forums.powershell.org/t/powershell-issues-with-export/14319/6 "2020-05-04T15:50:28Z")

</div>

> [@](#):
>
> we call them the helpless desk … thank you so much .

lol … that was new for me … I will memorize this and use it when it fits … thanks 😉 😃

---

<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:29pm UTC](https://forums.powershell.org/t/powershell-issues-with-export/14319/7 "2024-05-16T20:29:46Z")

</div>


