Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
if ($isUser -ne $null) {
$isUser = $isUser.TrimEnd(",")
if ($isGroup -ne $null) {
$isGroup = $isGroup.TrimEnd(",")
$usrCount = 0
foreach ($grp in $isGroup.split(",")) {
$grpUsers = (Get-ADGroupMember $grp | select samaccountname).samaccountname
foreach ($usr in $isUser.split(",")) {
if ($grpUsers -contains $usr) {
$xaapp = $app.browsername.ToString()
write-warning "$usr is already a member of $grp. REMOVE from $xaapp"
add-content $outputfile -value "$usr should be removed from $xaapp"
$usrCount++;
}
}
}
if ($usrCount -eq 0) {
$xaapp = $app.browsername.ToString()
write-warning "$isuser is/are NOT a member of any '$xaapp' groups."
add-content $outputfile -value "$isuser should be added to new CTX-$xaapp group"
if ($addADGroupList) {add-content $adgroupfile -value "CTX-$xaapp"}
}
} else {
$xaapp = $app.browsername.ToString()
Write-warning "$xaapp needs an AD Group. For example --- CTX-$xaapp ---"
add-content $outputfile -value "$xaapp needs an AD Group. For example --- CTX-$xaapp ---"
if ($addADGroupList) {add-content $adgroupfile -value "CTX-$xaapp"}
}
} else {
if ($isGroup -ne $null) {
$isGroup = $isGroup.TrimEnd(",")
if ($isGroup.count -ge 1) {
$xaapp = $app.browsername.ToString()
Write-warning "$xaapp needs a single AD Group. For example --- CTX-$xaapp ---"
add-content $outputfile -value "$xaapp needs an AD Group. For example --- CTX-$xaapp ---"
if ($addADGroupList) {add-content $adgroupfile -value "CTX-$xaapp"}
}
} else {
$xaapp = $app.browsername.ToString()
Write-warning "$xaapp has no users or groups assigned. It needs an AD Group. For example --- CTX-$xaapp ---"
add-content $outputfile -value "$xaapp needs an AD Group. For example --- CTX-$xaapp ---"
if ($addADGroupList) {add-content $adgroupfile -value "CTX-$xaapp"}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment