I am trying to run the following script which is a PS1 file and I need to direct the output to a CSV file -
Get-ADUser-SearchBase"OU=Name,OU=Name,OU=Name,DC=DOMAIN,DC=com"-Filter*|foreach-object { write-host"User:"$_.Name-foregroundgreen Get-ADPrincipalGroupMembership$_.SamAccountName|foreach-object { write-host"Member Of:"$_.name } }
I am trying to get this out for a report to filter users by group.
Not sure where the output is required as I have tried several things but no luck.
Thanks,
Chris