I am using PowerShell with the Quest AD cmdlets.
I can use the Get-QADGroupMember cmdlet to get a list of everyone in a given group. So far so good but I would like to get their email alias as well. All that is returned currently is someth开发者_运维百科ing like:
Name      Type  DN
----      ----  --
Jane Doe  User  CN=Jane Doe,OU=Employee,DC=companyname,DC=com
Job Blow  User  CN=Joe Blow,OU=Employee,DC=companyname,DC=com
I tried using get-qaduser with the -includeallproperties flag but I still only get the above fields returned and I don't know how to get at the returned data which the documentation says is cached on the computer.
Any help would be appreciated.
UPDATE
I ended up using "select" similar to below:
$everyone = Get-QADGroupMember "All employees" | select firstname, lastname, email
And that got everything I needed into an array of hashtables. At that point it is easy to do whatever is needed by iterating through everyone with code like:
for ($i=0; $i -le $everyone .length-1; $i++)
{
    write-host $everyone[$i].email
}
Took me forever to find the "." notation for pulling specific values out of the hashtable. I did text parsing and that worked but I knew that couldn't be the right way of doing it and eventually found documentation on the dot notation. I hope documenting that here saves someone else some time!
Are you sure it really doesn't return that information? Have you tried piping the command into Get-Member or Format-List -Force *? PowerShell can be configured to only show a few properties of items and not all which might be the case here.
You can select properties using Select-Object or just select if you konw they are there, even though PowerShell doesn't display them by default:
Some-Command | select Name, Type, DN, SomeOtherProperty
You can see this for example with Get-ChildItem too:
PS Home:\> gci *.ps1
    Directory: C:\Users\Joey
Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        2011-04-27     18:50        169 format.ps1
-a---        2011-04-26     18:36       1064 Untitled1.ps1
-a---        2011-04-27     18:41         69 x.ps1
-a---        2011-04-23     19:58         91 y.ps1
The normal invocation only yields four properties: Mode, LastWriteTime, Length and Name. However, there are plenty more, as Get-Member shows.
PS Home:\> gci *.ps1|gm -MemberType Property
   TypeName: System.IO.FileInfo
Name              MemberType Definition
----              ---------- ----------
Attributes        Property   System.IO.FileAttributes Attributes {get;set;}
CreationTime      Property   System.DateTime CreationTime {get;set;}
CreationTimeUtc   Property   System.DateTime CreationTimeUtc {get;set;}
Directory         Property   System.IO.DirectoryInfo Directory {get;}
DirectoryName     Property   System.String DirectoryName {get;}
Exists            Property   System.Boolean Exists {get;}
Extension         Property   System.String Extension {get;}
FullName          Property   System.String FullName {get;}
IsReadOnly        Property   System.Boolean IsReadOnly {get;set;}
LastAccessTime    Property   System.DateTime LastAccessTime {get;set;}
LastAccessTimeUtc Property   System.DateTime LastAccessTimeUtc {get;set;}
LastWriteTime     Property   System.DateTime LastWriteTime {get;set;}
LastWriteTimeUtc  Property   System.DateTime LastWriteTimeUtc {get;set;}
Length            Property   System.Int64 Length {get;}
Name              Property   System.String Name {get;}
Rememember that select-object strips down the object and generates new ones.
So in this example:
$test = get-qaduser atestuser | select-object name
$test will be a PSCustomObject (System.Object) containing only the name.
What do you want do do with the data? Output to the console...to a file?
I would do something like this:
get-qadgroupmember "domain users" | format-table name, displayname, email
Or
get-qadgroupmember "domain users" | select-object name, displayname, email | Export-Csv c:\acsvfile.csv
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论