Get AD security group members list on email as attachment.
This script will provide members list as csv file. You will get it over email and will be stored in specified location and it will only will keep 30 files latest. #Get-ADGroupMember -Server "bbntech.com" -Identity "G-SE-NTT-MFAEnable" -Recursive | get-aduser -Properties GivenName,Surname,Name,DisplayName,samaccountname,UserPrincipalName,mail,OfficePhone,telephoneNumber,Enabled | Select GivenName,Surname,Name,DisplayName,samaccountname,UserPrincipalName,mail,OfficePhone,telephoneNumber,Enabled | export-csv D:\bbn\G-SE-NTT-MFAEnable_Users.csv -Notypeinformation # BBN Techinfo #Would talk about pre-requisites for importing Active Directory Module at end of post import-module ActiveDirectory #Preparing files to write data and attach to email $file1 = "D:\bbn\MFA_Users\G-SE-NTT-MFAEnable_Users_$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv" ################################################# $path = "D:\bbn\MFA_Users" $files = Get-Chil...