Author Posts

June 6, 2018 at 3:00 pm

Greetings.

I'm trying to log the results of the following script.
The script runs successfully & the Out-File is created, however it is blank. What am I doing wrong?

#first, let's get the DistinguishedName of the group
$grp = get-ADGroup "MI_Exchange_O365"
$grpDN = $grp.DistinguishedName

#Now let's read in the list of users display names.
$list = get-content "C:\AD group remove\userlist.txt"

#Now we can read through the list, find each user's DistinguishedName
foreach ($item in $list)
{
	add-ADGroupMember -identity $grpDN -Members $item -Confirm:$false | Out-File "C:\AD group remove\Add_log.txt" -Append	
}

June 6, 2018 at 3:12 pm

When you carefully study the help for the cmdlet Add-ADGroupMember you will see that it does not output anything by default. You have to provide the parameter -PassThru.