Bulk users move with condition check using powershell

Опубликовано: 16 Июнь 2024
на канале: InfoAlias
68
2

To create a PowerShell script that searches for all enabled users with the department matching "Marketing" and moves them to a specific Organizational Unit (OU) named "Marketing", you can use the Active Directory module for PowerShell.

#powershell
#powershellscript
#activedirectory
#automation
#script


Explanation:
Import-Module ActiveDirectory: Loads the Active Directory module.
$targetOU: Specifies the Distinguished Name (DN) of the target OU.
Get-ADUser -Filter: Searches for all enabled users with the department attribute set to "Marketing".
Move-ADObject: Moves each user to the specified target OU.
Write-Output: Outputs the result of the operation for each user.
Prerequisites:
Run the script with sufficient privileges to read user properties and move objects in Active Directory.
Ensure the Distinguished Name (DN) of the target OU is correct.
Running the Script:
Save the script as MoveMarketingUsers.ps1.
Open PowerShell with administrative privileges.
Execute the script: .\MoveMarketingUsers.ps1.
Adjust the DC=yourdomain,DC=com part of the $targetOU variable to match your domain's naming context. If your domain is example.com, then it should be OU=Marketing,DC=infoalias,DC=local.


Смотрите видео Bulk users move with condition check using powershell онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь InfoAlias 16 Июнь 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 68 раз и оно понравилось 2 людям.