D
D
dsneosporim2020-12-30 14:40:49
PowerShell
dsneosporim, 2020-12-30 14:40:49

Task Scheduler ->Poweshell->Excel->AD?

Dear experts, good afternoon everyone!
The following task arose: It is
necessary to write a script in Powershell that would parse an excel file and, based on the results of parsing, add / delete a user to / from a group / s or block an account in AD.
Example.
The following data is in the excel table:
Full name Block mail Block internet Block account
Ivanov 10/10/2019 10/11/2019 10/24/2019
The logic is as follows: powershell accesses the excel file with the entered data once a day, checks the conditions for adding/removing a user/her from/to the group/s, then based on the results of checking the dates (key condition), the powershell script accesses AD to add/remove the group or blocking accounts in accordance with the date when it is necessary to perform actions with a user in AD.
If someone can attach some kind of "backbone" of the script, I will be grateful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Dmitriev, 2020-12-30
@SignFinder

1. Create an array and drive it into a variable using Import-Excel
2. Open the loop using ForEach
3. In the loop, make nested conditions using If Else, or run the loop a number of times with one condition.
You can turn off an account Disable-ADAccount, delete add to a group - Remove-ADGroupMember and Add-ADGroupMember

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question