Hi!
I just added the requested content above (members of a group). If you also need to see the dependencies (Member of section of groups) let me know.
If it helps, please accept the answer and upvote.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi all,
Can you please provide me a script to get all users information with all attributes from Active directory and wants to save it in CSV file.
Also need to get information about OUs and Groups memberships.
thanks
Regards
Hi!
I just added the requested content above (members of a group). If you also need to see the dependencies (Member of section of groups) let me know.
If it helps, please accept the answer and upvote.
Hi
Setting group list
$groupslist = Get-adgroup -Filter * -SearchBase "DC=test,DC=local" -Properties SamAccountName, whenCreated, ObjectClass | select SamAccountName, whenCreated, ObjectClass
It will also extract the group members and group memberships? If not, then what parameters will be used in this script?
Regards
Hi!
I wrote this just now, you could look into the OU using the parameter Distinguished name, I am not sure of the right cmdlet to extract the details (filtered through) to solely get the OU's
$mainpath = "C:\temp\"
$usersexportpath = "$mainpath\userslist.csv"
$groupsexportpath = "$mainpath\groupslist.csv"
$groupmemberexportpath = "$mainpath\groupmembers.csv"
$userslist = Get-ADUser -Filter * -SearchBase "DC=test,DC=local" -Properties SamAccountName,DisplayName,givenName,LastLogonDate,mail,Enabled,whenCreated, ObjectClass | select SamAccountName,DisplayName,givenName,UserPrincipalName,ProxyAddress,LastLogonDate,mail,Enabled,whenCreated, ObjectClass
$groupslist = Get-adgroup -Filter * -SearchBase "DC=test,DC=local" -Properties SamAccountName, whenCreated, ObjectClass | select SamAccountName, whenCreated, ObjectClass
$groupslist = Get-adgroup -Filter * -SearchBase "DC=test,DC=local"
$groupmember= foreach($group in $grouplist){
Get-adgroup $group | get-adgroupmember
}
$groupmember | Export-Csv $groupmemberexportpath -encoding "unicode" -NoTypeInformation
if($userslist.objectclass -eq "user"){
$userslist | Export-Csv $usersexportpath -encoding "unicode" -NoTypeInformation
}
else{
write-host "Something went wrong"
}
if($groupslist.objectclass -eq "group"){
$groupslist | Export-Csv $groupsexportpath -encoding "unicode" -NoTypeInformation
}
else{
write-host "Something went wrong"
}
Hope it helps!
(If it does feel free to accept the answer and upvote ;) )
I m already using this script:
Get-ADUser -Filter * -SearchBase "DC=test,DC=local" -Properties SamAccountName,DisplayName,givenName,LastLogonDate,mail,Enabled,whenCreated | select SamAccountName,DisplayName,givenName,UserPrincipalName,ProxyAddress,LastLogonDate,mail,Enabled,whenCreated | Export-Csv "C:\temp\Users.csv" -encoding "unicode" -NoTypeInformation
This is working fine But this scripts does not retrieve the OU and group informaion. I am not femilier with Powershell. Anybody can modify it according to my requirement.
Thanks in Advance.
Regards