По шедулеру создаем группу для рассылки
#by me
import-module activedirectory -EA SilentlyContinue
$distrgroup = "(СР) ТАКАЯ ВОТ РАССЫЛКА"
$template = "*ЧАСТЬ НАЗВАНИЯ*"
$groupmembers = Get-ADGroupMember -Identity $($distrgroup)
foreach ($member in $groupmembers){
if([boolean]((get-aduser $member -properties memberof).memberof -like $($template)) -eq $false){
Remove-ADGroupMember -Identity $($distrgroup) -Members $member -cf:$false -EA SilentlyContinue
}
}
$users = get-aduser -filter {enabled -eq $true} -properties memberof | where{$_.memberof -like $($template)}
foreach($user in $users){
trap {continue} Add-ADGroupMember -Identity $($distrgroup) -members $user -EA SilentlyContinue
}
#by me
import-module activedirectory -EA SilentlyContinue
$distrgroup = "(СР) ТАКАЯ ВОТ РАССЫЛКА"
$template = "*ЧАСТЬ НАЗВАНИЯ*"
$groupmembers = Get-ADGroupMember -Identity $($distrgroup)
foreach ($member in $groupmembers){
if([boolean]((get-aduser $member -properties memberof).memberof -like $($template)) -eq $false){
Remove-ADGroupMember -Identity $($distrgroup) -Members $member -cf:$false -EA SilentlyContinue
}
}
$users = get-aduser -filter {enabled -eq $true} -properties memberof | where{$_.memberof -like $($template)}
foreach($user in $users){
trap {continue} Add-ADGroupMember -Identity $($distrgroup) -members $user -EA SilentlyContinue
}
Комментариев нет:
Отправить комментарий