一、Disconnected Mailboxes

1、Finding Disconnected Mailboxes

The first function is called Get-DisconnectedMailbox and the name is pretty much self explanitory. This function will give you a list of all disconnected mailboxes on each of your mailbox servers. Take a look at the following code:

function Get-DisconnectedMailbox {
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$false)]
[System.String]
$Name = '*'
) $mailboxes = Get-MailboxServer
$mailboxes | %{
$disconn = Get-Mailboxstatistics -Server $_.name | ?{ $_.DisconnectDate -ne $null }
$disconn | ?{$_.displayname -like $Name} |
Select DisplayName,
@{n="StoreMailboxIdentity";e={$_.MailboxGuid}},
Database
}
}

Note: If you’ve recently deleted a mailbox, but it’s not showing up when running Get-DisconnectedMailbox, you may need to force Exchange to recognize this by running the Clean-MailboxDatabase cmdlet.


2、Purging Disconnected Mailboxes

You purge mailboxes using the Remove-Mailbox cmdlet, specifying the StoreMailboxIdentity and Database for the disconnected mailbox in question. For a good example of this, check out Nitin Gupta’s post on removing disconnected mailboxes.

In an effort to simplify the purging of disconnected mailboxes, I wrote the Remove-DisconnectedMailbox function that is designed to work with Get-DisconnectedMailbox. Here is the code:

function Remove-DisconnectedMailbox {
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter(Position=0, ValueFromPipelineByPropertyName=$true, Mandatory=$true)]
[System.String]
$StoreMailboxIdentity,
[Parameter(Position=1, ValueFromPipelineByPropertyName=$true, Mandatory=$true)]
[System.String]
$Database
) process {
Remove-Mailbox @PSBoundParameters
}
}
Get-DisconnectedMailbox “Bill Jones” | Remove-DisconnectedMailbox -Confirm:$false
Get-DisconnectedMailbox “Bradford Boyer” | %{Connect-Mailbox -Identity $_.StoreMailboxIdentity -Database ‘DB1′ -User ‘contoso\bboyer’ -Alias ‘bboyer’}

参考至博文<http://www.mikepfeiffer.net/2010/06/managing-disconnected-exchange-mailboxes-with-powershell/>


二、

Powershell Get Domain Mailbox的几种方法的更多相关文章

  1. Powershell Get Domain User的几种方法

    一.Get-User单用户查询 $User=Get-ADUser -identity wendy -Properties * 二.Get-User多用户循环查询 $export=@() $Users= ...

  2. Powershell Get Domain Group的几种方法

    Group常见属性介绍: 一.Get-ADGroup获取群组(如下例循环获取群组的发送权限) #群组的发送权限info $groups=Get-ADGroup -filter * -SearchSco ...

  3. ASP.NET Core设置URLs的几种方法

    前言 在使用ASP.NET Core 3.1开发时,需要配置服务器监听的端口和协议,官方帮助文档进行简单说明,文档中提到了4种指定URL的方法 设置ASPNETCORE_URLS 环境变量: 使用do ...

  4. SQL Server启动的几种方法

    SQL Server 启动有以下几种方法: (1)在Control Panel——Administrative Tools——Services,找到SQL Server (XXX)进行启动. 其中XX ...

  5. Ajax跨域的几种方法以及每种方法的原理

    js中几种实用的跨域方法原理详解 这里说的js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通过js获取页面中不同域的框架中(iframe)的数据.只要协 ...

  6. 【总结】清除webbrowser cookie/session的6种方法

    下面是我测试下来的6种清除webbrowser中cookie的6种方法: //方法一:调用 wininet.dll清除cookie (推荐) SuppressWininetBehavior(); // ...

  7. GRIDVIEW传值的两种方法

    第一种方法:在onselectedindexchanged中写事件 第二种方法:OnRowCommand事件 前端页面: <%@ Page Language="C#" Aut ...

  8. iOS 本地存储四种方法

    在iOS开发过程中,不管是做什么应用,都会碰到数据保存的问题.将数据保存到本地,能够让程序的运行更加流畅,不会出现让人厌恶的菊花形状,使得用户体验更好.下面介绍⼀一下数据保存的方式: 1.NSKeye ...

  9. HibernateTemplate、HibernateDaoSupport两种方法实现增删改查Good(转)

    Spring+Hibernate两种方法实现增删改查 首先,定义一个Customer的bean类,设置好Customer.hbm.xml文件.再定义好一个Dao接口.准备好一个jdbc.propert ...

随机推荐

  1. Ant—使用Ant构建简单Java项目(三)

    博客<Ant-使用Ant构建简单Java项目(二)>我们简化了运行Test类中main方法须要运行的命令,本博客来介绍一下如何使build.xml文件和当中使用property标签定义的属 ...

  2. 要练习的lambda

    取list的id 放入新List<Integer> List<Integer> list1 = list.stream().map(albumGroup1 -> albu ...

  3. mysql中实现分类汇总功能

    1.创建测试表: CREATE TABLE test_ROLLUP_1 ( StateCode ), DepCode ), SendMoney INT ); 2.插入测试语句: INSERT INTO ...

  4. SignalR IOS Android

    http://www.dotblogs.com.tw/toysboy21/archive/2014/03/24/144505.aspx https://www.youtube.com/watch?v= ...

  5. Impala中多列转为一行

    之前有一位朋友咨询我,Impala中怎样实现将多列转为一行,事实上Impala中自带函数能够实现,不用自己定义函数. 以下我開始演示: -bash-4.1$ impala-shell Starting ...

  6. Atitit.二维码功能的设计实践 attilax 总结

    Atitit.二维码功能的设计实践 attilax 总结 1.1. 二维码要实现的功能1 1.2. 现有二维码功能设计不足的地方(待改进)1 1.3. 二维码组件1 1.4. Java版  zxing ...

  7. Android CoordinatorLayout 入门介绍

    Android CoordinatorLayout 入门介绍 CoordinatorLayout View 知道如何表现 在 2015 年的 I/O 开发者大会上,Google 介绍了一个新的 And ...

  8. centos单机安装Hadoop2.6

    一,安装环境 硬件:虚拟机 操作系统:Centos 6.4 64位 IP:10.51.121.10 主机名:datanode-4 安装用户:root 二,安装JDK 安装JDK1.6或者以上版本.这里 ...

  9. apache ab测试

    网站并发测试,网站服务使用的是apache2.4 因此使用ab来测试网站性能. windows使用cms 打开apache/bin 运行ab.exe (......../apache/bin/ab), ...

  10. pycharm-community-3.1.1.tar.gz下载

    国外服务器着实慢, 下载地址:http://yun.baidu.com/share/link?shareid=2521912381&uk=3020189984