none
exchange 批量创建数据库 RRS feed

  • 问题

  • #requires -version 2

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex,
     [Parameter(Mandatory = $true)]
     [string]$MailServer,
     [Parameter(Mandatory = $true)]
     [string]$DBPath
     
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     echo "creating database ${Prefix}${i}"
     New-MailboxDatabase -name "${Prefix}${i}" -Server ${MailServer} -EdbFilePath ${DBPath}\${Prefix}${i}\${Prefix}${i}.edb -LogFolderPath ${DBPath}\${Prefix}${i}
    }

    2018年10月30日 6:59

全部回复

  • 批量挂载数据库

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex,
     [Parameter(Mandatory = $true)]
     [int]$Mounted 
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     if($Mounted -eq 1)
     {
      Write-Host "Mounting ${Prefix}${i}"
      mount-database "${Prefix}${i}" -Confirm:$false
     }
     elseif($Mounted -eq 0)
     {
      Write-Host "Dismounting ${Prefix}${i}"
      dismount-database "${Prefix}${i}" -Confirm:$false
     }
    }

    批量更新数据库

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex,
     [Parameter(Mandatory = $true)]
     [string]$MailServer
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     echo "updating databasecopy ${Prefix}${i} copy on ${MailServer} "
     Update-MailboxDatabaseCopy -Identity "${Prefix}${i}\${MailServer}" -DeleteExistingFiles -Force -Confirm:$false
     Set-MailboxDatabase "${Prefix}${i}" -CircularLoggingEnabled $True
    }

    批量更新数据策略

    #requires -version 2

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     echo "updating database ${Prefix}${i}"
     Set-MailboxDatabase "${Prefix}${i}" -OfflineAddressBook "\默认脱机通讯簿 (Ex2013)" -ProhibitSendReceiveQuota 10GB -ProhibitSendQuota 50GB -IssueWarningQuota 8GB -CircularLoggingEnabled $true
    }

    2018年10月30日 7:02
  • 批量添加数据卡副本

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex,
     [Parameter(Mandatory = $true)]
     [string]$MailboxServer 
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     $dbname="${Prefix}${i}"
     echo "adding database $dbname copy on ${MailboxServer} "
     Add-MailboxDatabaseCopy -Identity $dbname -MailboxServer ${MailboxServer} -ActivationPreference 2
    }

    2018年10月30日 7:03
  • 批量启动 日志循环

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     echo "enable circle log for database ${Prefix}${i}"
     Set-MailboxDatabase "${Prefix}${i}" -CircularLoggingEnabled $true
    }

    批量切换换动数据库

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex,
     [Parameter(Mandatory = $true)]
     [string]$ActivateOnServer
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     echo "moving ActiveMailboxDatabase ${Prefix}${i} to $ActivateOnServer"
     Move-ActiveMailboxDatabase "${Prefix}${i}" -ActivateOnServer "$ActivateOnServer" -Confirm:$false
    }

    数据库_批量取消循环日志_v1.0

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     echo "disable circle log for database ${Prefix}${i}"
     Set-MailboxDatabase "${Prefix}${i}" -CircularLoggingEnabled $false
    }

    数据库_批量添加数据库副本_v1.0

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex,
     [Parameter(Mandatory = $true)]
     [string]$MailboxServer 
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     $dbname="${Prefix}${i}"
     echo "adding database $dbname copy on ${MailboxServer} "
     Add-MailboxDatabaseCopy -Identity $dbname -MailboxServer ${MailboxServer} -ActivationPreference 2
    }

    数据库_批量添加数据库副本配置only_v1.0

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex,
     [Parameter(Mandatory = $true)]
     [string]$MailboxServer 
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     $dbname="${Prefix}${i}"
     echo "adding database $dbname copy  ConfigurationOnly on ${MailboxServer} "
     Add-MailboxDatabaseCopy -Identity $dbname -MailboxServer ${MailboxServer} -ConfigurationOnly
    }

    2018年10月30日 7:10
  • 批量移除数据库副本

    [CmdletBinding()]
    param (

     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex
    )
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     echo "remove databasecopy ${Prefix}${i} from catl-mbxarch01"
     Remove-MailboxDatabaseCopy -Identity "${Prefix}${i}\mbxarch01" -Confirm:$false
    }

    数据库_批量创建-挂载-配置更新-副本创建

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Prefix,
     [Parameter(Mandatory = $true)]
     [int]$StartIndex, 
     [Parameter(Mandatory = $true)]
     [int]$EndIndex,
     [Parameter(Mandatory = $true)]
     [string]$MailboxServer,
     [Parameter(Mandatory = $true)]
     [string]$MailboxCopyServer,
     [Parameter(Mandatory = $true)]
     [string]$DBPath,
     [Parameter(Mandatory = $true)]
     [bool]$IsArchiveDatabase
    )
    echo "==================Create DataBase=================="
    for($i=${StartIndex};$i -le ${EndIndex}; $i++){
     echo "creating database ${Prefix}${i}"
     New-MailboxDatabase -name "${Prefix}${i}" -Server ${MailboxServer} -EdbFilePath ${DBPath}\${Prefix}${i}\${Prefix}${i}.edb -LogFolderPath ${DBPath}\${Prefix}${i}
    }
    echo "==================Mount DataBase=================="
    for($j=${StartIndex};$j -le ${EndIndex}; $j++){
     echo "mounting database ${Prefix}${j}"
     mount-database "${Prefix}${j}" -Confirm:$false
    }
    echo "==================Update DataBase Configuration=================="
    for($k=${StartIndex};$k -le ${EndIndex}; $k++){
     echo "updating databasecopy ${Prefix}${k}"
     if($IsArchiveDatabase)
     {
      Set-MailboxDatabase "${Prefix}${k}" -OfflineAddressBook "\默认脱机通讯簿 (Ex2013)" -ProhibitSendReceiveQuota 52GB -ProhibitSendQuota 50GB -IssueWarningQuota 48GB
     }else{
      Set-MailboxDatabase "${Prefix}${k}" -OfflineAddressBook "\默认脱机通讯簿 (Ex2013)" -ProhibitSendReceiveQuota 102GB -ProhibitSendQuota 100GB -IssueWarningQuota 98GB
     }
    }
    echo "==================Create DataBase Copy=================="
    for($p=${StartIndex};$p -le ${EndIndex}; $p++){
     $dbname="${Prefix}${p}"
     echo "adding database $dbname copy on ${MailboxCopyServer} "
     Add-MailboxDatabaseCopy -Identity $dbname -MailboxServer ${MailboxCopyServer} -ActivationPreference 2
     echo "add CircularLog of $dbname"
     Set-MailboxDatabase $dbname -CircularLoggingEnabled $True
    }
    echo "==================End=================="

     
    2018年10月30日 7:16
  • 谁可以给这个群组发邮件

    Get-DistributionGroup _alldirectors | Select-Object -ExpandProperty AcceptMessagesOnlyFrom
    SendersOrMembers | ft name


    2018年10月30日 7:17
  • 统计用户邮箱信息

    $datetime=Get-Date -Format 'yyyy-MM-dd'
    $dbs=Get-MailboxDatabase
    foreach($db in $dbs)
    {
     $aliases=(Get-Mailbox -Database $db).alias
     foreach($name in $aliases)
     {
      $user=Get-ADUser -Identity $name -Properties DisplayName,Enabled,Department,Company,info,EmailAddress,Manager,Office,SamAccountName,Title,Description
      $DisplayName=[string]$user.DisplayName
      $Enabled=[string]$user.Enabled
      $SamAccountName=[string]$user.SamAccountName
      $Department=[string]$user.Department
      $Company=[string]$user.Company
      $info=[string]$user.info
      $EmailAddress=[string]$user.EmailAddress
      $Office=[string]$user.Office
      $Title=[string]$user.Title
      $Employeenum=[string]$user.Description
      $managerdn=$user.Manager
      $manager_DisplayName=""
      $manager_SamAccountName=""
      $manager_Description=""
      if($managerdn -ne $null -and $managerdn -ne '')
      {
       $manager=Get-ADUser -Properties DisplayName,SamAccountName,Description -identity $managerdn 
       $manager_DisplayName=[string]$manager.DisplayName
       $manager_SamAccountName=[string]$manager.SamAccountName
       $manager_Description=[string]$manager.Description
      }
      #=============================================================
      $mailinfo=Get-Mailbox "$EmailAddress"
      $Database=[string]$mailinfo.Database
      $LitigationHoldEnabled=[string]$mailinfo.LitigationHoldEnabled
      $RetentionHoldEnabled=[string]$mailinfo.RetentionHoldEnabled
      $LitigationHoldDuration=[string]$mailinfo.LitigationHoldDuration
      $RetentionPolicy=[string]$mailinfo.RetentionPolicy
      $AddressBookPolicy=[string]$mailinfo.AddressBookPolicy
      $RulesQuota=[string]$mailinfo.RulesQuota
      $ThrottlingPolicy=[string]$mailinfo.ThrottlingPolicy
      $ArchiveDatabase=[string]$mailinfo.ArchiveDatabase
      $ArchiveQuota=[string]$mailinfo.ArchiveQuota
      $ArchiveWarningQuota=[string]$mailinfo.ArchiveWarningQuota
      $DisabledArchiveGuid=[string]$mailinfo.DisabledArchiveGuid
      $AuditEnabled=[string]$mailinfo.AuditEnabled
      $AuditLogAgeLimit=[string]$mailinfo.AuditLogAgeLimit
      $OrganizationalUnit=[string]$mailinfo.OrganizationalUnit
      $HiddenFromAddressListsEnabled=[string]$mailinfo.HiddenFromAddressListsEnabled
      $MaxSendSize=[string]$mailinfo.MaxSendSize
      $MaxReceiveSize=[string]$mailinfo.MaxReceiveSize
      $RecipientType=[string]$mailinfo.RecipientType
      $Guid=[string]$mailinfo.Guid
      $WhenCreated=[string]$mailinfo.WhenCreated
      $WhenChanged=[string]$mailinfo.WhenChanged
      #=============================================================
      $mailstats=Get-MailboxStatistics "$EmailAddress"
      $DeletedItemCount=[string]$mailstats.DeletedItemCount.Value
      $ItemCount=[string]$mailstats.ItemCount.Value
      $LastLogonTime=[string]$mailstats.LastLogonTime
      $LastLogoffTime=[string]$mailstats.LastLogoffTime
      $TotalDeletedItemSize=[string]$mailstats.TotalDeletedItemSize
      $TotalItemSize=[string]$mailstats.TotalItemSize
      $DatabaseMoutedServer=[string]$mailstats.ServerName
      $MailboxGuid=[string]$mailstats.MailboxGuid
      #=============================================================
      $archivemailstats=Get-MailboxStatistics "$EmailAddress" -Archive
      $ArchiveDeletedItemCount=[string]$archivemailstats.DeletedItemCount.Value
      $ArchiveItemCount=[string]$archivemailstats.ItemCount.Value
      $ArchiveLastLogonTime=[string]$archivemailstats.LastLogonTime
      $ArchiveLastLogoffTime=[string]$archivemailstats.LastLogoffTime
      $ArchiveTotalDeletedItemSize=[string]$archivemailstats.TotalDeletedItemSize
      $ArchiveTotalItemSize=[string]$archivemailstats.TotalItemSize
      $ArchiveDatabaseMoutedServer=[string]$archivemailstats.ServerName
      $ArchiveMailboxGuid=[string]$archivemailstats.MailboxGuid
      echo $datetime";$db;"$DisplayName";"$SamAccountName";"$Enabled";"$Department";"$Company";"$info";"$EmailAddress";"$Office";"$Title";"$Employeenum";"$manager_DisplayName";"$manager_SamAccountName";"$manager_Description";"$Database";"$LitigationHoldEnabled";"$RetentionHoldEnabled";"$LitigationHoldDuration";"$RetentionPolicy";"$AddressBookPolicy";"$RulesQuota";"$ThrottlingPolicy";"$ArchiveDatabase";"$ArchiveQuota";"$ArchiveWarningQuota";"$DisabledArchiveGuid";"$AuditEnabled";"$AuditLogAgeLimit";"$OrganizationalUnit";"$HiddenFromAddressListsEnabled";"$MaxSendSize";"$MaxReceiveSize";"$RecipientType";"$Guid";"$WhenCreated";"$WhenChanged";"$MailboxGuid";"$DeletedItemCount";"$ItemCount";"$LastLogonTime";"$LastLogoffTime";"$TotalDeletedItemSize";"$TotalDeletedItemSize";"$TotalItemSize";"$DatabaseMoutedServer";"$ArchiveMailboxGuid";"$ArchiveDeletedItemCount";"$ArchiveItemCount";"$ArchiveLastLogonTime";"$ArchiveLastLogoffTime";"$ArchiveTotalDeletedItemSize";"$ArchiveTotalItemSize";"$ArchiveDatabaseMoutedServer
     }
    }

    2018年10月30日 7:18
  • 批量邮箱归档

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$OriginalDatabases,
     [Parameter(Mandatory = $false)]
     [string]$ArchivePolicy, 
     [Parameter(Mandatory = $true)]
     [string]$ArchiveDatabases 
    )
    $odbs=$OriginalDatabases.split(",")
    $adbs=$ArchiveDatabases.split(",")
    $acount=$adbs.count
    $ArchivePolicy="CATL-Archive-10Months"
    $handledCount=1
    $index=0
    foreach($odb in $odbs)
    {
     $mails=(Get-Mailbox -Database $odb | where { $_.ArchiveDatabase -eq $null}).alias
     foreach($mail in $mails)
     {
      $adb=$adbs[$index]
      echo "mail:${mail} - policy:${ArchivePolicy} - odb:${odb}- adb:${adb} - ${handledCount}"
      Set-Mailbox -identity "$mail" -RetentionPolicy "$ArchivePolicy"
      Enable-Mailbox -identity "$mail" -Archive -ArchiveDatabase "$adb"
      $index++
      $handledCount++
      if($index -eq $acount)
      {
       $index=0
      }
     }
    }

    2018年10月30日 7:25
  • 批量查询邮箱归档 状态

    [CmdletBinding()]
    param (
     
     [Parameter(Mandatory = $true)]
     [string]$Database
    )
    $mails=(Get-Mailbox -Database $Database).alias
    $title="{0,-20}{1,-40}{2,-40}" -f "Alias","Master Size(MB)","Archive Size(MB)"
    $line="{0,-20}{1,-40}{2,-40}" -f "--------------------","--------------------","--------------------"
    echo $title
    echo $line
    foreach($mail in $mails)
    {
        Start-ManagedFolderAssistant -identity "$mail"
        $mastersize=(Get-MailboxStatistics -identity "$mail").totalitemsize.value.ToMB()
        $archivesize=(Get-MailboxStatistics -Archive -identity "$mail").totalitemsize.value.ToMB()
        $str="{0,-20}{1,-40}{2,-40}" -f "$mail","$mastersize","$archivesize"
        echo $str
    }

    2018年10月30日 7:26
  • 获取所有邮箱归档信息

    $dbs=Get-MailboxDatabase
    foreach($db in $dbs)
    {
     $mails=(Get-Mailbox -Database $db).alias
     foreach($mail in $mails)
     {
      $m=Get-mailbox "$mail"
      $am=(Get-MailboxStatistics -Archive -identity "$mail").totalitemsize.value.ToMB()
      $name=[string]$m.Name
      $SamAccountName=[string]$m.SamAccountName
      $RetentionPolicy=[string]$m.RetentionPolicy
      $primarysmtpaddress=[string]$m.PrimarySmtpAddress
      $archivedatabase=[string]$m.ArchiveDatabase
      $archivesize=[string]$am
      echo $name";"$SamAccountName";"$RetentionPolicy";"$primarysmtpaddress";"$archivedatabase";"$archivesize
      echo $name";"$SamAccountName";"$RetentionPolicy";"$primarysmtpaddress";"$archivedatabase";"$archivesize >> c:\temp\mailbox.csv
     }
    }

    2018年10月30日 7:28