Pregunta

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 : administrator@Inside.John-Henderson.co.uk

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

Thank you for your help.

¿Fue útil?

Solución

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top