1

I am looking for all users on AD who are not in a group "all users" the output file shows all the fields I would like it to be just the Name field.

The script is:

Get-ADUser -Filter * -properties memberof | Where-Object {!($
_.memberof -like "*all email*")} | out-file c:\users\worta\desktop\users.csv

It shows in the txt file as

`DistinguishedName : CN=Administrator,CN=Users,DC=Inside,DC=John-Henderson,DC=co
                    ,DC=uk
Enabled           : True
GivenName         : 
MemberOf          : {CN=Fax Users,CN=Users,DC=Inside,DC=John-Henderson,DC=co,DC
                    =uk, CN=Organization Management,OU=Microsoft Exchange Secur
                    ity Groups,DC=Inside,DC=John-Henderson,DC=co,DC=uk, CN=HFS 
                    Terminal Services,CN=Users,DC=Inside,DC=John-Henderson,DC=c
                    o,DC=uk, CN=Internet Users,CN=Users,DC=Inside,DC=John-Hende
                    rson,DC=co,DC=uk...}
**Name              : Administrator**
ObjectClass       : user
ObjectGUID        : 840790d7-fe4e-46ea-9781-e64269543ce8
SamAccountName    : Administrator
SID               : S-1-5-21-2809677999-1344825738-4163663879-500
Surname           : 
UserPrincipalName : [email protected]

` I would like just an output of the field Name highlighted

Thank you for your help.

1 Answer 1

3

If you are outputting to a CSV I would recommend using Export-Csv over Out-File. Also, you can use Select-Object to pick off the properties you are interested in:

Get-ADUser -Filter * -properties memberof | 
    Where-Object {!($_.memberof -like "*all email*")} | 
    Select-Object Name |
    Export-Csv c:\users\worta\desktop\users.csv -NoTypeInfo
Sign up to request clarification or add additional context in comments.

1 Comment

Worked perfect (-NoTypeInfo got an error but simply took this out and worked fine) Thank You

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.