List of disabled users and users' mobile number

+3

I have the domain administrator account but cannot execute powershell since it is disabled on my workstation. Thus I need one script, which can get a list of disabled users. I also need a list of mobile numbers of all users.

It would be better if the script can run automatically once a week and send me an email.

$res = PDO->prepare(SELECT * FROM users WHERE status = :status ORDER BY name ASC);

$res->setFetchMode(PDO::FETCH_ASSOC);

$res->execute(array('status' => $disabled_status));

Create message body, something like:

$message = '<p>Disabled users:</p>';

while($lot = $res->fetch()) {

$message .= '<p>' . $lot['name'] . ' ' . $lot['phone'] . '</p>';

}

Send eMail with simple mail().

2. by muabshir - 2 years ago (2016-10-24) in reply to comment 1 by Oleg ZorinComment

But in this code how we communicate with the domain controler

4. by Oleg Zorin - 2 years ago (2016-10-24) in reply to comment 2 by muabshirComment

Probably I miss something in your request, but...

I think that you have some DB with your user's information and statuses. And you want to get some data from DB once in a week. Right?

So put this script in separate file. And run it with CRON (for unix server) or Task Manager (for win server) once per week.

5. by muabshir - 2 years ago (2016-10-24) in reply to comment 4 by Oleg ZorinComment

Oleg Zorin i don't think they have any DB or table currently according to the statement they have domain controller and he only want to get the list of disable users from domain controller, furthermore he also don't have any script to run as cron

7. by Shidong Wang - 2 years ago (2016-10-24) in reply to comment 5 by muabshirComment

You are absolutely right. Thanks very much for your clarification to Oleg. :-)