Using XML configuration files in PowerShell scripts<confMBX> <Filters> <Filter Name="Prohibit send quota"> <ProhibitSendQuota>300MB</ProhibitSendQuota> </Filter> </Filters> <StorageGroups> <StorageGroup Name="SG1"> <SystemFolderPath>R:\SG1</SystemFolderPath> <LogFolderPath>S:\Log-SG1</LogFolderPath> <MDBName>MDB1</MDBName> <EdbFilePath>R:\SG1\MDB1\MDB1.edb</EdbFilePath> <CreatePF>T</CreatePF> </StorageGroup> <StorageGroup Name="SG2"> <SystemFolderPath>R:\SG2</SystemFolderPath> <LogFolderPath>S:\Log-SG2</LogFolderPath> <MDBName>MDB2</MDBName> <EdbFilePath>R:\SG2\MDB2\MDB2.edb</EdbFilePath> </StorageGroup> <StorageGroup Name="SG3"> <SystemFolderPath>R:\SG3</SystemFolderPath> <LogFolderPath>S:\Log-SG3</LogFolderPath> <MDBName>MDB3</MDBName> <EdbFilePath>R:\SG3\MDB3\MDB3.edb</EdbFilePath> </StorageGroup> </StorageGroups> </confMBX>
This config file can be used in a script : # setting global parameters $hostname = hostname # Reading the config file $xml = [xml]$(get-content MBX_config.xml) # Loop on StorageGroup foreach ($sg in $xml.confMBX.StorageGroups.StorageGroup) { # create the Storage Group with a specific Path for log files new-StorageGroup -Server:$hostname -Name:$sg.Name -LogFolderPath:$sg.LogFolderPath -SystemFolderPath:$sg.SystemFolderPath # Create the MailBox Database and Mount it new-mailboxdatabase -StorageGroup:$sg.Name -Name:$sg.MDBName -EdbFilePath:$sg.EdbFilePath | mount-database # Setting up the filter for this DataBase foreach($filter in $xml.Filters.Filter) { if ($filter.Name -eq "Prohbit Send Quota") { set-mailboxdatabase $SG.MDBName -ProhibitSendQuota:$filter.ProhibitSendQuota } } }
|