Archive for the ‘Active Directory’ Category

Problem

You want to add or remove print drivers on a print server.

Solution

Using a graphical-user interface

To add a print driver to a print server, do the following:

  1. Open the Print Management MMC snap-in.

  2. Double-click on the Print Servers node, then the print server that you want to manage.

  3. Right-click on the Drivers node and select Add Driver. Click Next to continue.

  4. On the Processor and Operating System Selection screen, place a checkmark next to the processors and OSes that will be used by your client computers. Click Next to continue.

  5. Select the manufacturer and model of the printer, or click Have Disk to use a manufacturer-supplied print driver.

  6. Click Next and then Finish to add the driver.

To manage existing print drivers, do the following:

  1. Open the Print Management MMC snap-in.

  2. Double-click on the Print Servers node, then the print server that you want to manage.

  3. Right-click on the Drivers node and select Manage Drivers.

  4. To add a new driver, click Add and follow the instructions in the previous section. To delete an installed driver, click Remove. To reinstall a print driver from media, click Re-Install.

  5. Click OK when you’re finished.

Using a command-line interface

To add a printer driver, enter the following:

	> cscript prndrvr.vbs -a -v 3 -e "Windows NT x86"

To delete a printer driver, use the following syntax:

	> cscript prndrvr.vbs d m "<DriverName>" v 3 e "Windows NT x86"

To list the printer drivers that are installed on a print server, use the following:

	> cscript prndrvr.vbs l

Problem

You want to create a printer filter to view only specific printers within the Print Management Console.

Solution

Using a graphical user interface
  1. Open the Print Management Console MMC snap-in.

  2. Right-click on Custom Printer Filters and select Add New Printer Filter.

  3. Enter a name and description for the printer filter. Optionally, place a checkmark next to “Display the total number of printers.” Click Next to continue.

  4. On the “Define a printer filter” screen, you can specify up to three conditions for the filter.

  5. In the Field drop-down box, select one of the following:

    • Printer Name
    • Queue Status
    • Jobs in Queue
    • Server Name
    • Comments
    • Driver Name
    • Is Shared
    • Location
    • Share Name
  6. For the Condition drop-down, select one of the following:

    • is exactly
    • is not exactly
    • begins with
    • not begin with
    • ends with
    • not end with
    • contains
    • not contain
  7. In the Value textbox, type a value that the condition should meet.

  8. When you have entered all necessary information, click Next to continue.

  9. On the Set Notifications (Optional) page, select one or both of the following:

    Send e-mail notification

    This will send an email whenever a printer that meets the criteria of the filter is found. Enter the recipient email address(es), sender email address, SMTP server, and message.

    Run script

    This will run a script whenever a printer that meets the criteria of the filter is found. Enter the path to the script and any command-line arguments.

  10. Click Finish to create the filter.

Discussion

One of the new features of the Print Management Console is the ability to create one or more custom printer filters using WMI information. This provides you with an at-a-glance view of all the printers in your environment, as well as printers that meet one or more specific criteria. There are three default print filters available when you first launch the PMC: All Printers, Printers Not Ready, and Printers With Jobs. You can create additional filters based on the printer name, queue status, the number of jobs in a queue, etc.

Problem

You want to add the print server role on a Windows Server 2003 server.

Solution

Using a graphical user interface
  1. Open the Configure Your Server wizard.

  2. Click Next to bypass the initial Welcome screen.

  3. On the Server role screen, select Print Server and click Next.

  4. On the Summary screen, click Next to begin the installation.

  5. Specify the path to the second R2 disc if necessary, and then click Finish.

Using a command-line interface

To add the Print Server role from the command-line, first create an unattend.txt> file containing the following:

	[Networking]

	[NetServices]
	MS_Server = params.MS_Server

	[Components]
	PMCSnap = On

Once you’ve saved the file, use the following syntax to install the Print Server role:

	> sysocmgr /i:c:\windows\inf\sysoc.inf /u:c:\unattend.txt

Using VBScript
	' This code creates an unattended installation file,
	' and then installs the Print Server Role
	' ------ SCRIPT CONFIGURATION -----
	strFile = "c:\unattend.txt"
	constForWriting = 2
	strComputer = "<ServerName>" ' use "." for the local computer
	' ------ END CONFIGURATION --------

	set objFSO = CreateObject("Scripting.FileSystemObject")
	set objFile = objFSO.OpenTextFile(strFile, constForWriting, True)
	objFile.WriteLine("[Networking]")
	objFile.WriteLine("[NetServices]")
	objFile.WriteLine("MS_Server = params.MS_Server
	objFile.WriteLine("[Components]")
	objFile.WriteLine("PMCSnap = ON")
	objFile.Close

	set objWshShell = WScript.CreateObject("WScript.Shell")
	intRC = objWshShell.Run("sysocmgr /i:%windir%\inf\sysoc.inf /u:" & _
	                        strFile, 0, TRUE)
	if intRC <> 0 then
	   WScript.Echo "Error returned from sysocmgr command: " & intRC
	else
	   WScript.Echo "Print Server role installed"
	end if

Discussion

The Print Manager role is not installed by default in Windows Server 2003 R2; you need to add the role manually using Add/Remove programs or the Configure Your Server wizard. This role has been greatly improved in R2 by including the Print Management Console MMC snap-in, which provides a unified view of installed drivers and forms, printer ports, and the ability to deploy printers using Group Policy.


Problem

You want to create a new storage group to allow for more mailbox stores, faster backups, or a logical organization of mailboxes.

Solution

Using a graphical user interface

  1. Open the Exchange System Manager (ESM) snap-in.
  2. In the left pane, browse to the server that you want to create a new storage group for.
  3. Right-click on the server and select New Storage Group.
  4. Enter a name, transaction log location, system path location for storage of temporary and recovered files and click OK.

Using a command-line interface

First create an LDIF file called add_sg.ldf with the following contents:

dn: CN=<

Storage Group Name>,<ParentDN>

changetype: add

objectClass: msExchStorageGroup

cn: <

Storage Group Name>

showInAdvancedViewOnly: TRUE

systemFlags: 1610612736

msExchESEParamEnableIndexChecking: TRUE

msExchESEParamEnableOnlineDefrag: TRUE

msExchESEParamSystemPath: <Path to store system files>

msExchESEParamPageFragment: 8

msExchESEParamPageTempDBMin: 0

msExchRecovery: TRUE

msExchESEParamZeroDatabaseDuringBackup: 0

msExchESEParamBaseName: E01

msExchESEParamCircularLog: 0

msExchESEParamEventSource: MsExchangeIS

msExchESEParamCheckpointDepthMax: 20971520

msExchESEParamCommitDefault: 0

msExchESEParamLogFilePath: <Path to log files>

msExchESEParamDbExtensionSize: 256

msExchESEParamLogFileSize: 5120

Replace < Storage Group Name> with the name of the storage group, <ParentDN> with the distinguished named for storage groups container for the appropriate server, <Path to store system files> with the filesystem path where you want system files (temporary and recovered files), and <Path to log files> with the filesystem path where you want exchange log files. Then run the following command:

>ldifde -i -f add-sg.ldf

Using VBScript

‘ This code creates a Storage Group.

‘ —— SCRIPT CONFIGURATION ——

strServer = “<

Exchange Server>”   ‘ e.g. ExchServer2

strName = “<Storage Group Name>”  ‘ e.g. SG1

strPath = “<File Path>” & strName ‘ e.g. D:\Program Files\ExchSrvr

‘ —— END CONFIGURATION ———

‘ Create URL to Storage Group

Set objSrv = CreateObject(“CDOEXM.ExchangeServer”)

objSrv.DataSource.Open strServer

‘ This for loop is a bit of a hack to retrieve the first Storage Group

‘ in the collection. VBScript doesn’t let you access specific elements

‘ of a collection the way Jscript can.

for each strSg in objSrv.StorageGroups

strTemp = strSg

exit for

next

strTemp = mid(strTemp,instr(2,strTemp,”cn”,1))

strSGUrl = “LDAP://cn=” & strName & “,” & strTemp

‘ Create/configure

Storage Group and save it

set objSG = CreateObject(“CDOEXM.StorageGroup”)

objSG.MoveSystemFiles(strPath)

objSG.MoveLogFiles(strPath)

objSG.DataSource.SaveTo strSGUrl

Wscript.Echo “Successfully created storage group.”

Discussion

Storage groups are used for physically breaking your databases up into smaller management groups. This is done for several reasons. Chief among them are so you will have more numerous but smaller databases, a logical organization of mailboxes, or faster Exchange backups and restores since the Exchange Server can run one simultaneous backup for each storage group. For example, if you have four mailbox databases in a single storage group, you can only have one backup running for that storage group; if you spread those four mailbox databases across two storage groups, you can run two simultaneous backups. For more detailed information on Exchange backups and file structures, see the Exchange Server Cookbook by Paul Robichaux et al. (O’Reilly).

Depending on the version (Standard or Enterprise) of Exchange, you can have up to four storage groups per server and up to five mailbox stores per storage group. ESM enforces these limits, but it is possible to directly modify Active Directory to exceed them. If you create more databases or storage groups than allowed by your version, the additional databases will not mount. In Exchange 2003, Microsoft recommends that you spread your mailboxes across as many stores and storage groups as possible; this is because of memory management improvements since Exchange 2000.

Storage groups are represented in Active Directory by the msExchStorageGroup class. This class has several attributes that have fairly intuitive string values and names and can be matched up to the options in ESM. Unfortunately, the raw Active Directory objects and attributes and their valid values for Exchange are not well documented. You can experiment with their settings, but you should do so only in a lab environment.

Using a Command-Line Interface

One negative aspect of creating storage groups by direct Active Directory object manipulation is that you will not get warnings concerning the maximum number of storage groups allowed.

Using VBScript

The process of calling the CDOEXM interfaces to create storage groups is rather straightforward once you have the URL for the location of the object in Active Directory. In this solution, to get the distinguished name of the storage group container for the server, the script loops through all storage groups on the sever and sets strTemp to the URL value of the last storage group. This value is then parsed to get the parent container for the storage groups to build the new storage group URL.

Problem

You want to create a recipient policy to configure an additional email address or mailbox manager policy.

Solution

Using a graphical user interface
  1. Open the Exchange System Manager (ESM) snap-in.

  2. In the left pane, browse to the Recipients Recipient Policies container.

  3. Right-click on Recipient Policies and select New Recipient Policy.

  4. Select the property pages you a want on the recipient policy form and click OK.

  5. Enter the recipient policy name.

  6. Click on Filter Rules, click Modify, select the search criteria, click OK.

  7. Read the warning message that is displayed and click OK.

  8. Set the desired policies on the E-Mail Addresses (Policy) and Mailbox Manager Settings (Policy) tabs.

  9. When you are done, click OK.

Problem

You want to enable storage limits for user mailboxes on an Exchange server.

Solution

Using a graphical user interface
  1. Open the Exchange System Manager (ESM) snap-in.

  2. In the left pane, browse to the mailboxes container of the server, storage group, and database you want to configure a storage limit for.

  3. Right-click the mailbox store. Select Properties, and then select the Limits tab.

  4. Select one or more of the following checkboxes:

    Issue warning at

    Warns users that they have exceeded the storage limit, but their mailbox will continue to function.

    Prohibit send at

    Warns users that they have exceeded the storage limit and then prevents them from sending new messages until their mailboxes are brought back underneath the configured storage limit. Users can still receive messages.

    Prohibit send and receive at

    Warns users that they have exceeded the storage limit and then prevents them from both sending and receiving messages until they have corrected the situation.

  5. Specify the appropriate values for these settings in kilobytes (KB).

The maximum value that you can configure for these items through the GUI is 2 GB (2,097,151 KB). To establish larger values than that, you need to use ADSI Edit or the command-line or script solutions listed next.

Using a command-line interface

To configure the size at which a warning will be issued, use the following syntax:

	> adfind config rb "cn=<StorageGroup>,cn=InformationStore,cn=<ServerName,
	cn=Servers,cn=<Administrative Group>,cn=Administrative Groups,cn=< 
ExchangeOrg,
	cn=Microsoft Exchange,cn=Services" dsq | admod mDBStorageQuota::<LimitinKB>

To configure the size at which a user can receive mail but not send, use the following:

	> adfind config rb "cn=<StorageGroup>,cn=InformationStore,cn=<ServerName,
	cn=Servers,cn=<Administrative Group>,cn=Administrative Groups,cn=<ExchangeOrg,
	cn=Microsoft Exchange,cn=Services" dsq | admod mDBOverQuotaLimit::<LimitinKB>

To configure the limit at which a user can neither send nor receive messages, use:

	> adfind config rb "cn=<StorageGroup>,cn=InformationStore,cn=<ServerName,
	cn=Servers,cn=<Administrative Group>,cn=Administrative Groups,cn=<ExchangeOrg,
	cn=Microsoft Exchange,cn=Services" dsq | admod mDBOverHardQuotaLimit::<LimitinKB>

You can set multiple attributes in a single command by specifying more than one attribute in the AdMod portion of the command syntax, as follows:

	> adfind config rb "cn=<StorageGroup>,cn=InformationStore,cn=<ServerName,
	cn=Servers,cn=<Administrative Group>,cn=Administrative Groups,cn=<ExchangeOrg,
	cn=Microsoft Exchange,cn=Services" dsq | admod mDBStorageQuota::<LimitinKB>
	mDBOverQuotaLimit::<LimitinKB> mDBOverHardQuotaLimit::<LimitinKB>

Using VBScript
	' The following script will update the Warning, OverQuota, and
	' HardOverQuota attributes of a  
mailbox store
	'-----------SCRIPT CONFIGURATION-----------------------------
	' strLDAPString = "cn=<StorageGroup>,cn=InformationStore," & _
	"cn=<ServerName>,cn=Servers,cn=<AdministrativeGroup>," & _
	"cn=Administrative Groups,cn=<ExchangeOrg>,cn=Microsoft Exchange," & _
	"cn=Services,cn=Configuration,<ForestRootDN>"

	strWarningLimit = "<WarningLimitinKB>"
	strSoftQuotaLimit = "<ReceiveOnlyLimitinKB>"
	strHardQuotaLimit = "<NoSendOrReceiveLimitinKB>"
	'-------------------END CONFIGURATION----------------------

	Set objMaiboxStore = GetObject _
	    ("LDAP://" & strLDAPString)

	objMailboxStore.Put "mdBStorageQuota", strWarningLimit
	objMailboxStore.Put "mdBOverQuotaLimit", strSoftQuotaLimit
	objMailboxStore.Put "mdBOverHardQuotaLimit", strHardQuotaLimit

	objMailboxStore.SetInfo

Discussion

It’s not uncommon for administrators to want to set reasonable size limits on individual users’ mailboxes; you can configure this globally at the mailbox store level. Since you can have multiple stores on a single server, this can allow you to create multiple stores with multiple storage limits for departments or groups that have greater storage needs. You can also override the mailbox store defaults for individual user accounts by modifying the Exchange General tab within Active Directory Users and Computers for an individual user account, or else by programmatically modifying the same three attributes and then setting the mdBUseDefaults attribute to FALSE. You can also set mailbox limits using a System Policy, and then apply the same policy to multiple stores.

Problem

You want to view the sizes and message counts of all mailboxes on a server.

Solution

Using a graphical user interface
  1. Open the Exchange System Manager (ESM) snap-in.

  2. In the left pane, browse to the mailboxes container of the server, storage group, and database you want to view mailboxes in.

  3. In the right pane, scroll down through the list of mailboxes noting the Size and Total Items columns.

Using VBScript
	' This code displays all mailboxes and their sizes
	' ------ SCRIPT CONFIGURATION ------
	strComputer = "< 
Exchange Server>" 'e.g. ExchServer2
	' ------ END CONFIGURATION ---------

	set objWMI = GetObject("winmgmts:\\" & strComputer & _
	                       "\root\MicrosoftExchangeV2")
	set objMbxs = objWMI.ExecQuery("Select * from Exchange_Mailbox",,48)
	for each objMbx in objMbxs
	  Wscript.Echo objMbx.MailBoxDisplayName & " " & objMbx.size & "KB " _
	               & objMbx.TotalItems & " items"
	Next
	Wscript.Echo "Script completed successfully."

Discussion

Mailbox sizes and message counts are items on Exchange systems that administrators routinely want to know about for the purposes of reporting and metrics. Administrators want to know if their mail system is balanced and if users are spread across the mailbox stores evenly. Knowing the number of users and the size of their mail-boxes in each mailbox store, the administrator can make better decisions about where new user mailboxes should be placed or if some leveling of mailboxes is required.

Problem

You want to enumerate all disconnected mailboxes on a server.

Solution

Using a graphical user interface
  1. Open the Exchange System Manager (ESM) snap-in.

  2. In the left pane, browse to the mailboxes container of the server, storage group, and database for which you want to view disconnected mailboxes.

  3. In the right pane, scroll down through the list, taking note of all mailboxes with a small red circle with an X.

Using VBScript
	' This code enumerates disconnected mailboxes.
	' ------ SCRIPT CONFIGURATION ------
	strComputer = "<Exchange Server>" 'e.g. ExchServer2
	' ------ END CONFIGURATION ---------
	set objWMI = GetObject("winmgmts:\\" & strComputer & _
	                       "\root\MicrosoftExchangeV2")

	set objDiscMbx = objWMI.ExecQuery("Select * from Exchange_Mailbox",,48)
	for each objMbx in objDiscMbx
	  if (objMbx. 
DateDiscoveredAbsentInDS <> "") then
	     Wscript.Echo objMbx.MailBoxDisplayName & " " & _
	                  objMbx.DateDiscoveredAbsentInDS
	  end if
	next
	Wscript.Echo "Successfully enumerated disconnected mailboxes."

Discussion

When you tell the system to delete an Exchange mailbox, it isn’t really deleted. It is simply disassociated or disconnected from the user object. These mailboxes are referred to as orphaned or disconnected. This recipe shows you how to enumerate the disconnected mailboxes you have on a specified server.

Problem

You want to reconnect a mailbox in the Exchange Store to a user object.

Solution

Using a graphical user interface
  1. Open the Exchange System Manager (ESM) snap-in.

  2. In the left pane, browse to the mailboxes container of the server, storage group, and database you want to reconnect a mailbox.

  3. In the right pane, scroll down until you find the mailbox that you wish to reconnect. The mailbox should have a small red circle with a white X on it indicating it is disconnected.

  4. Right-click the mailbox and select Reconnect.

  5. Choose a user object in the directory you wish to reconnect this mailbox to.

  6. A dialog box indicating the Reconnect Operation has completed successfully should pop up. Click OK.


Problem

You want to purge a deleted mailbox from the Exchange Store.

Solution

Using a graphical user interface

  1. Open the Exchange System Manager (ESM) snap-in.
  2. In the left pane, browse to the mailboxes container of the server, storage group, and database you want to purge a mailbox from.
  3. In the left pane, scroll down until you find the mailbox that you wish to purge. The mailbox should have a small red circle with a white X in it, indicating that it is disconnected.
  4. Right-click the mailbox and select Purge.
  5. When prompted if you are sure you want to continue click Yes.

Using VBScript

‘ This code purges a deleted mailbox.

‘ —— SCRIPT CONFIGURATION ——

strComputer = “<

Exchange Server>” ‘e.g. ExchServer2

strMailbox = “<Mailbox Alias>”    ‘e.g. jsmith

‘ —— END CONFIGURATION ——–

Set objWMI = GetObject(“winmgmts:\\” & strComputer & _

“\root\MicrosoftExchangeV2”)

set objDiscMbx = objWMI.ExecQuery(“Select * from Exchange_Mailbox WHERE ” _

& “MailboxDisplayName='” & strMailbox & “‘”,,48)

for each objMbx in objDiscMbx

objMbx.Purge

next

Wscript.Echo “Successfully purged mailbox.”

Discussion

A mailbox that has been deleted still has physical presence in the Exchange store. This recipe wipes that mailbox from the store completely. Once a mailbox has been purged, the only way to retrieve it is through restoring from a backup, which could be a lengthy process given the need to recover the entire store. In other words, don’t do this unless you are sure of the consequences.

Purging a mailbox requires Exchange Full Administrator permissions..

Using a Graphical User Interface

You may run into a case where ESM doesn’t show you a mailbox is disconnected when in fact you know it is. This can happen if you delete the mailbox and immediately look at it in ESM. To clear that condition, you will need to right-click on the mailboxes container and select Run Cleanup Agent. This will cause some house cleaning to be done; the mailbox should then show up as disconnected.

Using VBScript

The Purge method is part of the Exchange_Mailbox class, which is new for Exchange 2003. In Exchange 2000, there was no method available to purge a mailbox via a script.

Be extremely careful with this script because it could easily remove all disconnected mailboxes on a given Exchange server. If the WHERE clause is removed in the SELECT statement of the WMI query, the purge loop below that would then clear every mailbox that was disconnected, so be careful.