ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Bulk Add Active Directory Group Members with PowerShell

Автор: InfoAlias

Загружено: 2023-02-11

Просмотров: 2472

Описание: This PowerShell script imports the Active Directory module, reads a list of users and groups from a CSV file, and then loops through each user in the CSV. For each user, it checks if the user is enabled in Active Directory using the Get-ADUser cmdlet. If the user is enabled, it then checks if the user is already a member of the group specified in the CSV using the Get-ADGroupMember cmdlet. If the user is already a member of the group, it outputs a message and skips the user. If the user is not already a member of the group, it adds the user to the group using the Add-ADGroupMember cmdlet. If the user is disabled in Active Directory, it outputs a message and skips the user. The script uses Write-Host to output messages to the console.

Note that this script assumes that the CSV file contains a column for the user's username named "User", and a column for the group name named "Group". The script also assumes that the CSV file is located at "c:\ad_script\UserList.csv".

Script:

Import active directory module for running AD cmdlets
Import-module ActiveDirectory

#Store the data from UserList.csv in the $List variable
$List = Import-CSV c:\ad_script\UserList.csv

#Loop through user in the CSV
ForEach ($User in $List)
{
Check if user is enabled
$ADUser = Get-ADUser $User.User -Properties Enabled
If ($ADUser.Enabled -eq $true) {
Check if user is already a member of the group
If (Get-ADGroupMember -Identity $User.Group -Recursive | Where-Object {$_.SamAccountName -eq $User.User}) {
User is already a member of the group, output a message and skip them
Write-Host "User $($User.User) is already a member of group $($User.Group), skipping." -ForegroundColor Yellow
}
Else {
User is not already a member of the group, add them to the group
Add-ADGroupMember $User.Group -Members $User.User -ErrorAction Stop -Verbose
}
}
Else {
User is disabled, skip them
Write-Host "User $($User.User) is disabled, skipping." -ForegroundColor Red
}
}

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Bulk Add Active Directory Group Members with PowerShell

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]