I’m trying to check against a list of group names (with associated text in secondary column) against a users group memberships
input file would be 2 columns name,output
ad group name in the first column, and some output text in the second.
i can-not get -compare to work, it doesn’t return anything.
if i chang my list to put * before and after the group name in the input file i can use -like but this isn’t very nice.
what am i doing wrong with -contains
$sam = Read-Host 'SamAccountName to check app groups?'
$applist = $path + "\applist.csv"
$user = Get-ADUser $sam -Properties memberof|select -expand memberof
$csv = import-csv $applist
foreach($app in $csv)
{
if ($user -contains $app.name)
{
Write-Host "$($app.output) is the action"
}
}