Systems and SQL Server

I have SQL Agent Operators named ‘Alerts’ and ‘MSXOperator’.  I use the ‘Alerts’ operator for SQL Server native generated fatal errors.   Didn’t realize the MSXOperator was created on Target SQL Server Agent by the process of enlisting as Target to the Master.  Changing the ‘Alerts’ Operator from my Central Management Server worked like a charm, but the MSXOperator didn’t work.  The error message is “Cannot modify or delete operator ‘MSXOperator’ while this server is a TSX.”.  Of course I googled the error, others had the error but there were no answers.

The error is generated on the target but not the master when this statement is run.

USE [msdb]
EXEC msdb.dbo.sp_update_operator @name=N’MSXOperator’,

Execute the statement on the master instance to change the email address.  In my case I was changing to a distribution group from my personal account.  Look at the Target from Manage Target Servers on the master instance.  The download instruction Operation of “6(RE_ENLIST)” is created and on the next polling will download the email address change to the target.


Check the properties of MSXOperator on the target server.  It’s been changed.  When you exit the properties you will still get the error message “Cannot modify or delete operator ‘MSXOperator’ while this server is a TSX.”.  That’s one of those SQL Server twitches.

Many comments praise the use of adding a linked server to AD and creating a view to capture user information.  There is a 1000 record limit, so that presents an obstacle to work around.  I struggled with permissions and never got a linked server to AD to work.  I’m not a Domain Admin and have limited exposure to AD in general.  Links to those methods are below.

Using Power shellflat filesSSIS package and Agent Job I created system to capture AD information on an hourly basis.  I experimented with the Power Shell Active Directory module a lot.  Having never had access to AD, it was a whole new world learning the structure and query syntax.  I made scripts for user group membership, computers  and here is the script to capture user information.

Import-module ActiveDirectory


# User details list

$cr = “`r” #Carriage Return
$tq = “`”” #Text Qualifier
#Column Headings

Out-File -Width 2147483647 -Encoding ASCII -FilePath \\LG0123SQL\Process\Spool\AdUser.txt
#Data Rows
Get-ADUser -Filter * -Properties * |
ForEach-object {
$AccountExpirationDate = $_.AccountExpirationDate
$AccountExpires = $_.AccountExpires
$assistant = $_.assistant
$Deleted = $_.Deleted
$Department = $_.Department
$DistinguishedName = $_.DistinguishedName
$EmailAddress = $_.EmailAddress
$EmployeeNumber = $_.EmployeeNumber
$Enabled = $_.Enabled
$extensionAttribute4 = $_.extensionAttribute4
$extensionAttribute5 = $_.extensionAttribute5
$extensionAttribute6 = $_.extensionAttribute6
$extensionAttribute7 = $_.extensionAttribute7
$extensionAttribute9 = $_.extensionAttribute9
$extensionAttribute11 = $_.extensionAttribute11
$extensionAttribute12 = $_.extensionAttribute12
$extensionAttribute13 = $_.extensionAttribute13
$extensionAttribute15 = $_.extensionAttribute15
$GivenName = $_.GivenName
$HomePhone = $_.HomePhone
$Initials = $_.Initials
$LastLogonDate = $_.LastLogonDate
$Manager = $_.Manager
$MobilePhone = $_.MobilePhone
$Modified = $_.Modified
$Name = $_.Name
$Office = $_.Office
$OfficePhone = $_.OfficePhone
$SamAccountName = $_.SamAccountName
$Surname = $_.Surname
$Title = $_.Title
} |
Out-File -Width 2147483647 -Encoding ASCII -FilePath \\LG0123SQL\Process\Spool\AdUser.txt -append # output

The output does need to be a UNC path. Once the flat files are created then SSIS and T-sql can take it from there to update the database of users and computers.  The project is an inventory of users, computers and the software installed on their computers.  The firm users have some expensive software and the licensing must be closely tracked.

Here are the links to other discussion on pulling in AD to SQL Server.