ShS's Blog

Just another sysadmin's weblog

Archive for the ‘PowerShell’ Category

Скрипт для получения отчета о событиях входа/выхода на компьютерах домена

Posted by shs на 2010/11/24

Давно хотел сделать для себя нечто подобное, но руки все никак не доходили. Наконец-то сподобился. И так, зачастую бывает необходимо получить отчет о событиях входа/выхода на отдельной рабочей станции и/или группе компьютеров домена: кто, когда выполнял интерактивный вход, вход по RDP, блокировал/разблокировал рабочую станцию, обращался к компьютеру по сети и т.п. Вся информация, которая нам необходимо для решения этой задачки, содержится в событиях 528/538/540 (для рабочих станций под управлением windows предшествующих Vista). Читать далее…

Posted in Active Directory, PowerShell, Scripts | Отмечено: , , | 23 комментария »

Определение email адресов-кандидатов для использования в качестве ловушек для спама (Spam traps) в почтовом сервере MDaemon.

Posted by shs на 2010/08/03

Как я уже писал ранее, в почтовом сервере Mdaemon существует возможность настроить ловушки для спама. Кратко напомню, что ловушки для спама — это некий перечень e-mail адресов. Все письма, которые поступают по адресам-ловушкам, «скармливаются» Байесовскому фильтру в качестве образцов spam’а для обучения оного фильтра. Естественно, что в качестве ловушек должны выступать адреса, на которые ничего, кроме спама, не приходит. Но, помимо этого, хотелось бы, чтобы в этом перечне были те адреса, которые наиболее интенсивно используются спамерами. Читать далее…

Posted in E-Mail, MDaemon, PowerShell, Scripts | Отмечено: , , , , | 2 комментария »

Массовое заполнение телефонных номеров пользователей в AD. Использование в качестве источника данных рабочей книги Excel, доступ к которой производится при помощи COM-объекта Excel.Application

Posted by shs на 2010/07/08

Задачка была достаточно простая:

Имеется список сотрудников и их внутренних телефонных номеров, оформленный в виде «книги» MSExcel. Необходимо заполнить поле «Номер телефона» (атрибут telephoneNumber) для каждого пользователя в AD соответствующим значением, взятым из вышеназванного списка сотрудников.

 Для доступа к данным, содержащимся в excel’овском файле  можно использовать один из двух вариантов:

  1. Подцепить xls-файл, как ODBC-источник данных и, затем, при помощи ADODB обращаться к нему, как к таблице.
  2. Использовать COM-объект Excel.Application, для работы с файлом «силами и средствами» Excel.

Читать далее…

Posted in Active Directory, PowerShell, Scripts | Отмечено: , , , | 2 комментария »

Аудит учетных записей AD – MDaemon

Posted by shs на 2010/06/24

Написал небольшой скрипт для аудита учетных записей MDaemon и учетных записей пользователей AD.

Задача была такова:
Имеется AD
Имеется сервер (член домена), на котором установлен почтовый сервер MDaemon (хранящий информацию о своих учетных записях в файле UserList.dat)
Необходимо найти учетные записи MDaemon, которые не принадлежат ни одному из «живых» (незаблокированных) пользователей AD. Читать далее…

Posted in Active Directory, E-Mail, MDaemon, PowerShell, Scripts | Отмечено: , , | Leave a Comment »

Offline files и как с ними бороться

Posted by shs на 2010/05/29

Небольшая заметка для тех, кто, как и я, использует offline files в Windows XP. Штука эта достаточно капризная. Если вы замечаете, что что-то «сломалось» в offline files и у вас нет ни времени, ни желания разбираться, почему оно ведет себя как-то не так, как должно, существует простой способ лечения. Выглядит он почти, как лечение головной боли при помощи гильотины, но зато этот способ так же эффективен и быстр: Читать далее…

Posted in PowerShell, Scripts | Отмечено: , | Leave a Comment »

Scripting Games 2010. Advanced Event 10 (Moving Files from the Desktop to a Folder)

Posted by shs на 2010/05/28

Десятое задание:

Event Scenario

The network team manager complained to the desktop team manager that user profiles are too large and are therefore killing network performance. An investigation has revealed that users are in the habit of downloading pictures, videos, and other large files from the Internet and storing them on their desktops. This habit has created user profiles that are in some cases over one GB in size.
Читать далее…

Posted in PowerShell, Scripting Games 2010, Scripts | Отмечено: , , , | Leave a Comment »

Scripting Games 2010. Advanced Event 9 (Logging Out Users Forcibly Based on a Program’s Launch)

Posted by shs на 2010/05/26

Девятое задание:

Event Scenario

Your users do not seem to know how to log out of their computers. This is a problem because each evening, a particular application runs as a scheduled task to back itself up to a network share. This occurs before the network backup job takes place. The storage manager has assigned you to write a script that will forcibly log out users from their workstations when a particular program launches. For the purposes of this example, use calc.exe.
Читать далее…

Posted in PowerShell, Scripting Games 2010, Scripts | Отмечено: , , , | Leave a Comment »

Scripting Games 2010. Advanced Event 8 (Creating Text Files of Specific Sizes)

Posted by shs на 2010/05/25

Восьмое задание:

Event Scenario

Your IT networking team has asked for assistance. They are testing network throughput on the Layer 4 switches. In performing their tests, they need the ability to create text files that are specific sizes. They have specifically requested the following sizes: 100 KB, 1 MB, 10 MB, and 100 MB. Because there are several members of the networking team involved in the project, and because they will be working on many different machines during the survey, they have requested a script that will create text files of those specific sizes.
Читать далее…

Posted in PowerShell, Scripting Games 2010, Scripts | Отмечено: , , , | Leave a Comment »

Scripting Games 2010. Advanced Event 7 (Creating a Graphical Tool)

Posted by shs на 2010/05/24

Седьмое задание:

Event Scenario

You have been tasked to create a graphical tool that will display the following information:
1.     Logged-on user name.
2.     Computer name and domain name, if applicable.
3.     How long the user has been logged on.
4.     The number of programs running.
5.     The amount of committed memory and free physical memory.
6.     The current level of CPU utilization.
7.     If the user is a regular user or has administrator rights

Читать далее…

Posted in PowerShell, Scripting Games 2010, Scripts | Отмечено: , , , | Leave a Comment »

Scripting Games 2010. Advanced Event 6 (Event Sink)

Posted by shs на 2010/05/21

Шестое задание:

Event Scenario

You have a group of files you would like to copy to several portable USB drives for a college course. You do not want to have to drag and drop every time a new drive is inserted into your USB port. You would like instead to automatically copy the files to the drive when the portable drive is inserted into your USB port.
Читать далее…

Posted in PowerShell, Scripting Games 2010, Scripts | Отмечено: , , , | 1 Comment »