2013年8月31日 星期六

Exchange 有公用資料夾移動到另一部伺服器的公用資料夾資料庫 ReplaceReplicaOnPFRecursive.ps1


.\AddReplicaToPFRecursive.ps1 -server "CCH-MAIL11" -TopPublicFolder "\" -ServerToAdd "CCH-MAIL16"
.\AddReplicaToPFRecursive.ps1 -server "CCH-MAIL13" -TopPublicFolder "\NON_IPM_SUBTREE" -ServerToAdd "CCH-MAIL15"

幹REMOVE時 -TopPublicFolder \ 不用""包
.\RemoveReplicaToPFRecursive.ps1 -server "CCH-MAIL15" -TopPublicFolder \ -ServerToRemove "CCH-MAIL11"



AddReplicaToPFRecursive.ps1
                [-Server <ServerIdParameter>]
                [-TopPublicFolder <PublicFolderIdParameter>]
                [-ServerToAdd <ServerIdParameter>]
PARAMETERS:
        -Server (optional)
                The server to operate against. Must be an Exchange 2007 Mailbox server
                with a public folder database. Defaults to a convenient server.
        -TopPublicFolder (required)
                The folder identity of the top of the tree of folders to modify
        -ServerToAdd (required)
                The server identity to add to the replica list. Must be a server with a
                public folder database.
        -------------------------- EXAMPLE 1 --------------------------
C:\PS> .\AddReplicaToPFRecursive.ps1 -TopPublicFolder "\Folder" -ServerToAdd "MyEx2003Server"
        -------------------------- EXAMPLE 2 --------------------------
C:\PS> .\AddReplicaToPFRecursive.ps1 -Server "MyEx2007Server" -TopPublicFolder "\Folder" -ServerToAdd "MyEx2003Server"



.\AddReplicaToPFRecursive.ps1 -TopPublicFolder "\NON_IPM_Subtree" -ServerToAdd "CCH-MAIL16"

2013年8月29日 星期四

Exchange 仲裁信箱 Arbitration Mailbox


Get-Mailbox -Database <Database ID> -Arbitration

New-MoveRequest -Identity "SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9}" -TargetDatabase "17E"
New-MoveRequest -Identity "SystemMailbox{1f05a927-58e1-439d-ac15-f69c0d044383}" -TargetDatabase "17E"
New-MoveRequest -Identity "FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042" -TargetDatabase "17E"
get-mailbox -Identity "FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042" | fd -wrap
FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042




1. Find the Arbitration Mailbox using the Exchange MAnagement Shell (EMS):
Get-Mailbox -Arbitration | Where {$_.Name -like "SystemMailbox*" } | ft –wrap

2. Now create a new move request in order to move the system mailboxes to another mailbox database:
New-MoveRequest -Identity "SystemMailbox{1f05a927-32d1-4e19-8ea5-67eba859f541-yourGUID}" -TargetDatabase "dbxxxx"

3. Verify whether the move request completed:
Get-MoveRequest

4. Now remove the move request
Remove-MoveRequest -Identity "the name of the request like Microsoft Exchange Approval Assistant"

Exchange determine the Microsoft Exchange version



Get-ExchangeServer | Format-Table Name, *Version*



Microsoft Exchange 2010

To determine the Rollup that has been applied to Microsoft Exchange 2010, run the following command in the Exchange Management Shell:

GCM exsetup |%{$_.Fileversioninfo}

To determine the Microsoft Exchange version for all Microsoft Exchange Servers in the organisation:

Get-ExchangeServer | Format-Table Name, *Version*

Exchange 無法在移動後清理來源信箱.

此方法無效


警告: 無法在移動後清理來源信箱.
錯誤詳細資料: MapiExceptionUnexpectedMailboxState: Unable to delete mailbox. (hr=0x80004005, ec=2634)



To Speed up the move request:
On ALL CAS Servers
Edit C:\Program Files\Microsoft\Exchange Server\V14\Bin\MSExchangeMailboxReplication.exe.config
--Find the following counter: “maxCleanupRetries”
--The default value is 5. Change to 1.
Restart MSExchangeMailboxReplication Service

To Clean up a Soft Deleted Mailbox on a database:
Get-MailboxStatistics -Database <MAILBOXDATABASE> | Where { $_.DisconnectReason -eq "SoftDeleted" } | Format-List LegacyDN, DisplayName, MailboxGUID, DisconnectReason
Remove-StoreMailbox -Database <MAILBOXDATABASE> -Identity <MAILBOXGUID> -MailboxState Softdeleted

To Clean up all Soft Deleted Mailboxes on a database:
Get-MailboxStatistics -Database <MAILBOXDATABASE> | Where-Object {$_.DisconnectReason -eq “Softdeleted”} | ForEach {Remove-StoreMailbox -Database $_.database -identity $_.mailboxguid -MailboxState Softdeleted}


Remove-StoreMailbox -Database db_name -Identity "User name" -MailboxState Softdeleted

Exchange Create a Mailbox Repair Request






FIX ALL
New-MailboxRepairRequest -Mailbox 9000 -CorruptionType SearchFolder,AggregateCounts,ProvisionedFolder,FolderView


New-MailboxRepairRequest -Mailbox tony@contoso.com -CorruptionType FolderView


Get-Mailbox -Filter {CustomAttribute2 -like "Repair Required"} | New-MailboxRepairRequest -CorruptionType SearchFolder,AggregateCounts,ProvisionedFolder,FolderView


New-MailboxRepairRequest -Mailbox ayla -CorruptionType ProvisionedFolder,SearchFolder -DetectOnly


New-MailboxRepairRequest -Mailbox ayla -CorruptionType ProvisionedFolder,SearchFolder -DetectOnly


New-MailboxRepairRequest -Database MBX-DB01 -CorruptionType AggregateCounts

2013年8月27日 星期二

Exchange Remove-DatabaseAvailabilityGroupServer Uninstall Exchange2010



Remove-DatabaseAvailabilityGroupServer

摘要: 1 個項目。1 個成功,0 個失敗。
經過時間: 00:01:43

CCH-MAIL19
已完成
警告:
Active Manager 作業失敗。錯誤 嘗試叢集作業時發生錯誤。錯誤: 收回節點 'cch-mail19' 已返回,但並未完全清除該節點。請執行 cluster.exe node <NodeName> /forcecleanup 以完成清除此節點的作業。。
已完成的 Exchange 管理命令介面命令:
Remove-DatabaseAvailabilityGroupServer -MailboxServer 'CCH-MAIL19' -Identity 'DAG16'
經過時間: 00:01:43

Uninstall Exchange2010

摘要: 2 個項目。1 個成功,1 個失敗。
經過時間: 00:00:10

正在設定必要條件
已完成
經過時間: 00:00:00

信箱角色 必要條件
失敗
錯誤:
此電腦是叢集成員,必須先使用 Remove-DatabaseAvailabilityGroupServer 工作將它從資料庫可用性群組移除,才能解除安裝 Exchange。
按一下這裡以取得說明... http://go.microsoft.com/fwlink/?linkid=30939&l=zh-Hant&v=ExBPA.14&id=22cdcab6-17f3-435a-a3a9-ec7dcb636608
經過時間: 00:00:10


cluster.exe node <NodeName> /forcecleanup 這個在Server2012上打到死都不能RUN

要用POWERSHELL http://technet.microsoft.com/zh-tw/library/ee619744(v=ws.10).aspx


cluster node /forcecleanup Clear-ClusterNode
For more information, see: Clear-ClusterNode (http://go.microsoft.com/fwlink/?LinkId=143781)

2013年8月26日 星期一

VMM Performing an operation in Virtual Machine Manager fails with error 801

VMM cannot find the Virtual hard disk object' error 801



To resolve this issue, remove the orphaned objects from the database by following the steps below.

1. Stop the System Center Virtual Machine Manager service on the VMM 2012 server.

2. Back up the Virtual Manager database.

3. Open SQL Management Studio and run the following script on the VMM database:

BEGIN TRANSACTION T1

DECLARE custom_cursor CURSOR FOR
SELECT VHDId, VDriveId from
dbo.tbl_WLC_VDrive WHERE [VHDId] NOT IN
(SELECT VHDId from dbo.tbl_WLC_VHD WHERE VHDID IS NOT NULL)

DECLARE @VHDId uniqueidentifier
DECLARE @VDriveId uniqueidentifier

OPEN custom_cursor
FETCH NEXT FROM custom_cursor INTO @VHDId, @VDriveId

WHILE(@@fetch_status = 0)
BEGIN
if(@VHDId is NOT NULL)
DELETE FROM dbo.tbl_WLC_VDrive
WHERE VDriveId = @VDriveId
FETCH NEXT FROM custom_cursor INTO @VHDId, @VDriveId
END
CLOSE custom_cursor
DEALLOCATE custom_cursor

COMMIT TRANSACTION T1
4. Start the System Center Virtual Machine Manager service again and refresh problem VMs. The VMs should return to a proper reporting state.

2013年8月25日 星期日

AD 依條件搬移ADComputer物件到指定的容器中

AD 依條件搬移ADComputer物件到指定的容器中

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe Move-ADObject.ps1

Move-ADObject.ps1
Import-Module activedirectory
$target = Get-ADOrganizationalUnit -LDAPFilter "(name=用戶端電腦)"
Get-ADComputer -LDAPFilter "(name=CAR*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=PCS*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=OA*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=IPD*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=OPD*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName
Get-ADComputer -LDAPFilter "(name=CR*)" -SearchBase "CN=Computers,DC=cch,DC=org,DC=tw" | Move-ADObject -TargetPath $target.DistinguishedName

Exchange 更新所有的通訊清單及郵件政策

Exchange 更新所有的通訊清單及郵件政策




%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe\update-address.ps1


update-address.ps1
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
Get-AddressList | Update-AddressList
Get-GlobalAddressList | Update-GlobalAddressList
Get-OfflineAddressBook | Update-OfflineAddressBook
Get-EmailAddressPolicy | Update-EmailAddressPolicy

Exchange 備份信箱至PST

Exchange 備份信箱至PST


New-MailboxExportRequest -Mailbox jmail -FilePath "E:\jmail.pst"

Exchange 取得物件LastLoggedOnUserAccount=XXX的信箱

Exchange 取得物件LastLoggedOnUserAccount=XXX的信箱

get-mailbox | get-mailboxstatistics | where-object {$_.LastLoggedOnUserAccount -eq "cch\XXX"}

Exchange Add-MailboxPermission Remove-MailboxPermission

Exchange Add-MailboxPermission Remove-MailboxPermission

Add-MailboxPermission -Identity 'CN=12345,OU=其他,DC=cch,DC=org,DC=tw' -User 'CCH\67890' -AccessRights 'FullAccess'

Remove-MailboxPermission -Identity 'CN=12345,OU=總院,DC=cch,DC=org,DC=tw' -User 'CCH\67890' -InheritanceType 'All' -AccessRights 'FullAccess'

Exchange 取得超過一年未登入的信箱

Exchange 取得超過一年未登入的信箱


Get-Mailbox -Server xxx -ResultSize Unlimited | Get-MailboxStatistics | where {$_.Lastlogontime -lt (get-date).AddDays(-365)} | Select DisplayName, LastLogonTime,StorageLimitStatus  | Export-CSV -Encoding Unicode "C:\LastLogonTime365.txt" -NoTypeInformation

Exchange 取得SERVER中信箱已滿Mailbox Disabled的使用者並匯出


Exchange 取得SERVER中信箱已滿Mailbox Disabled的使用者並匯出

Get-Mailbox -Server xxxx -ResultSize Unlimited | Get-MailboxStatistics | where {$_.StorageLimitStatus -match "MailboxDisabled"} | Select DisplayName, LastLogonTime,StorageLimitStatus  | Export-CSV -Encoding Unicode "C:\temp\MailboxDisabled.txt" -NoTypeInformation

StorageLimitStatus -ne 不等於???
StorageLimitStatus -eq 等於

Exchange 取得信箱大小排序並匯出

Exchange 取得信箱大小排序並匯出

Get-Mailbox -Server xxxx -ResultSize Unlimited | Get-MailboxStatistics | where {$_.StorageLimitStatus -ne "BelowLimit"} | Select DisplayName,LastLoggedOnUserAccount,StorageLimitStatus,@{name="TotalItemSize (MB)";expression={[math]::Round(($_.TotalItemSize.Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}},@{name="TotalDeletedItemSize (MB)";expression={[math]::Round(($_.TotalDeletedItemSize.Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}},ItemCount,DeletedItemCount | Sort "TotalItemSize (MB)" -Descending | Export-CSV -Encoding Unicode "C:\TEST\Exceeded Quotas.csv" -NoTypeInformation

Exchange 取得DisplayName LastLogonTime StorageLimitStatus

Exchange 取得DisplayName  LastLogonTime  StorageLimitStatus


Get-Mailbox -Identity XXXXX -ResultSize Unlimited | Get-MailboxStatistics | Select DisplayName
, LastLogonTime,StorageLimitStatus



DisplayName                             LastLogonTime                                                StorageLimitStatus
-----------                             -------------                                                ------------------
XXXXX(XXXX)                                                                                               BelowLimit

2013年8月24日 星期六

Exchange 查看使用者登入在那一個主機

Exchange 查看使用者登入在那一個主機

Which Servers are people logged onto


 Get-LogonStatistics -Identity "DisplayName" |fl clientname

 Get-LogonStatistics -Identity ID |fl clientname

Exchange move-DatabasePath 搬移信箱資料庫路徑

Exchange move-DatabasePath 搬移信箱資料庫路徑


move-DatabasePath -Identity '14F' -EdbFilePath 'F:\Mailbox\14F\14F.edb' -LogFolderPath 'F:\Mailbox\Log\14F'

Exchange New-AddressList Move-AddressList 建立移動通訊清單

Exchange New-AddressList Move-AddressList 建立移動通訊清單

建立後移動
New-AddressList -Name "01.分院榮譽院長" -RecipientFilter {((RecipientType -eq 'UserMailbox') -a
nd ((CustomAttribute1 -like '分院榮譽院長') -or (CustomAttribute6 -like '分院榮譽院長') -or (CustomAttribute7 -like '分
院榮譽院長')))}
Move-AddressList -Identity 01.分院榮譽院長 -Target '\B.依主管職稱\A2.合作醫院與分院'




直接建立
New-AddressList -Name "\B.依主管職稱\A2.合作醫院與分院\01.分院榮譽院長" -RecipientFilter {((RecipientType -eq 'UserMailbox') -a
nd ((CustomAttribute1 -like '分院榮譽院長') -or (CustomAttribute6 -like '分院榮譽院長') -or (CustomAttribute7 -like '分
院榮譽院長')))}


移動

Move-AddressList -Identity "\C.總院\4.行政部門\體系營運中心\國際醫療中心" -Target "\C.總院\4.行政部門"

2013年8月23日 星期五

Exchange 匯出主機中所選的帳號資訊,並以最後登入時間排序‧

Exchange 匯出主機中所選的帳號資訊,並以最後登入時間排序‧



Get-Mailbox -server ServerName -ResultSize Unlimited | Get-MailboxStatistics | sort LastLogonTime | select DisplayName, LastLogonTime, LastLoggedOnUserAccount, TotalItemSize, DatabaseName, StorageLimitStatus | Out-File c:\temp\LastLogon_Report.csv
 



Get-Mailbox -server ServerName  -ResultSize Unlimited | Get-MailboxStatistics | sort LastLogonTi
me | select DisplayName, LastLogonTime, LastLoggedOnUserAccount | Out-File c:\temp\LastLogon_Report.csv

Get-Mailbox -server ServerName  -ResultSize Unlimited | Get-MailboxStatistics | sort LastLogonTime | select DisplayName, LastLogonTime, LastLoggedOnUserAccount, StorageLimitStatus | Out-File c:\temp\LastLogon_Report.csv

Exchange 清除信箱內所有信件

Exchange 清除信箱內所有信件
 -Force 不提示執行

Search-Mailbox -Identity " DisplayName  " -DeleteContent -Force
Search-Mailbox -Identity  UserId -DeleteContent -Force