I am attempting to user PowerShell to spit out a csv file with the following columns:
Name,Username,Group name,Enabled

I am almost there, the one step I am missing is how to flag users as enabled or not.
For instance, this works fine:

```
Import-Module ActiveDirectory

$Groups = (Get-AdGroup -filter * | Where {$_.name -like "**"} | select name -ExpandProperty name)

$Table = @()

$Record = @{
  "Group Name" = ""
  "Name" = ""
  "Username" = ""
}

Foreach ($Group in $Groups) {

  $Arrayofmembers = Get-ADGroupMember -identity $Group -recursive | select name,samaccountname

  foreach ($Member in $Arrayofmembers) {
    $Record."Group Name" = $Group
    $Record."Name" = $Member.name
    $Record."UserName" = $Member.samaccountname
    $objRecord = New-Object PSObject -property $Record
    $Table += $objrecord

  }
}

$Table | export-csv "C:\temp\SecurityGroups.csv" -NoTypeInformation

```

If I try to add in a (quite impractical admittedly) extra search per loop to slap in the the users "Enabled" status, that column just remains blank:

```
Import-Module ActiveDirectory

$Groups = (Get-AdGroup -filter * | Where {$_.name -like "**"} | select name -ExpandProperty name)

$Table = @()

$Record = @{
  "Group Name" = ""
  "Name" = ""
  "Username" = ""
  "Enabled" = ""
}

Foreach ($Group in $Groups) {

  $Arrayofmembers = Get-ADGroupMember -identity $Group -recursive | select name,samaccountname

  foreach ($Member in $Arrayofmembers) {
    $Temprecord = Get-ADUser -Filter 'samaccountname -like "$Member.samaccountname"'
    $Record."Enabled" = $Temprecord.Enabled
    $Record."Group Name" = $Group
    $Record."Name" = $Member.name
    $Record."UserName" = $Member.samaccountname
    $objRecord = New-Object PSObject -property $Record
    $Table += $objrecord

  }
}

$Table | export-csv "C:\temp\SecurityGroups.csv" -NoTypeInformation

```

If I had to guess, it is an issue with the line:

```
$Temprecord = Get-ADUser -Filter 'samaccountname -like "$Member.samaccountname"'

```

That like bit must be wrong but am unsure how to resolve.