VB Script to show users and the groups they are in within an OU

TriCountyIT
TriCountyIT used Ask the Experts™
on
I was wondering if there was a vp script I can user to make a txt file that shows all the users of an OU and also what groups those users are in.  Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Architect
Distinguished Expert 2017
Commented:
I know that you asked for VBScript, but you can achive this also with PowerShell script:
$users = Get-ADUser -SearchBase "OU=Users,DC=domain,DC=com" -Filter * -Properties *
foreach ($user in $users)
	{
	foreach ($member in $user.MemberOf) 
		{ 
		Write-Output "$($user.DisplayName) - $($member.Substring(3, $member.IndexOf(",") - 3))" | Out-File -FilePath "test.txt" 
		}
	}

Open in new window

Author

Commented:
Thanks they both worked.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial