The following error message appears when I run this simple script: Out-File cannot bind argument to parameter 'Filepath' because it is null. I believe I need to enter $file in the out-file section, but am not sure where to place it.
Import-module ActiveDirectory
$date = get-date -Format "MMddyyyymm"
$file = "C:\Temp\Grp_mbrs_$date.csv"
Import-csv "c:\temp\grps.csv" | ForEach Object {
$GName = $_.samaccountname
$group = get-adgroup $Gname
$group.name | out-file $memberlist -encoding unicode -append
}
THe grps.csv file contains the following:
samaccountname
grp1
grp2
grp3
mamadukes