Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Exporting Null fields with Get-ADUser command

$
0
0

I have the following command:

Import-Module ActiveDirectory Get-ADUser -Filter 'EmailAddress -ge 0' -Properties EmailAddress, Surname | Select-Object EmailAddress,Surname | Export-Csv -Path C:tempusers.csv 

that exports users in Active Directory to a csv file. I have an issue where if a Surname is NULL, the csv file ends at the first occurrence of a NULL.

Is there a way to place a ” ” where a NULL is found in the Surname field?

For example, if i have 3 users in Active Directory:

Email Address | Surname joe@domain.local | mama mary@domain.local | bob@domain.local | mamadune 

My csv file will only contain:

Email Address | Surname joe@domain.local | mama mary@domain.local | 

I can’t figure out a way to replace nulls with something like “{no last name}”

submitted by /u/scoobydoobiedoodoo
[link] [comments]

The post Exporting Null fields with Get-ADUser command appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles