Logging script execution

Welcome Forums General PowerShell Q&A Logging script execution

This topic contains 2 replies, has 3 voices, and was last updated by

9 months, 3 weeks ago.

  • Author
  • #101924

    Points: 1
    Rank: Member


    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	
  • #101927

    Points: 1,171
    Helping Hand
    Rank: Community Hero

    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.

  • #101932

    Points: 77
    Rank: Member

The topic ‘Logging script execution’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort