Powershell Get Domain Mailbox的几种方法

一、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/>



二、

时间: 2024-08-03 03:30:14

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

Powershell Get Domain User的几种方法

一.Get-User单用户查询 $User=Get-ADUser -identity wendy -Properties * 二.Get-User多用户循环查询 $export[email protected]() $Users=Get-ADUser -Filter * -SearchScope Subtree -SearchBase "OU=xx,OU=xx,dc=xx,dc=xx,dc=xx" -Properties * foreach($user in $users) { #$U

Powershell Get Domain Group的几种方法

Group常见属性介绍: 一.Get-ADGroup获取群组(如下例循环获取群组的发送权限) #群组的发送权限info $groups=Get-ADGroup -filter * -SearchScope Subtree -SearchBase "OU=xx,OU=xx,DC=xx,DC=xx,DC=xx" #获取群组名称 $export[email protected]() foreach($group in $groups) { $groupname=$group.SamAccou

iOS 本地存储四种方法(没看)

在iOS开发过程中,不管是做什么应用,都会碰到数据保存的问题.将数据保存到本地,能够让程序的运行更加流畅,不会出现让人厌恶的菊花形状,使得用户体验更好.下面介绍?一下数据保存的方式: 1.NSKeyedArchiver:采用归档的形式来保存数据,该数据对象需要遵守NSCoding协议,并且该对象对应的类必须提 供encodeWithCoder:和initWithCoder:方法.前?一个方法告诉系统怎么对对象进行编码,而后?一个方法则是告诉系统怎 么对对象进行解码.例如对Possession对象

elasticsearch导入数据的几种方法

Elasticsearch一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.ElasticSearch也支持存储,查询,排序,分页等数据库的功能.Elasticsearch的数据就存储在硬盘中.当我们的访问日志非常大时,kabana绘制图形的时候会非常缓慢.而且硬盘空间有限,不可能保存所有的日志文件.如果我们想获取站点每天的重要数据信息,比如每天的访问量并希望能图像化的形式显示该如何做呢? 当然首先我们要把你想要的信息从Elasticsearch导出,然在整理后再导入Elast

php读取网络文件curl,fsockopen,file_get_contents,file,fopen几种方法

php读取网络文件 curl, fsockopen ,file_get_contents 几个方法的效率对比 最近需要获取别人网站上的音乐数据.用了file_get_contents函数,但是总是会遇到获取失败的问题,尽管按照手册中的 例子设置了超时,可多数时候不会奏效: $config['context'] = stream_context_create(array(‘http’ => array(‘method’ => “GET”,   ’timeout’ => 5//这个超时时间不

SQL Server启动的几种方法

SQL Server 启动有以下几种方法: (1)在Control Panel--Administrative Tools--Services,找到SQL Server (XXX)进行启动. 其中XXX为实例名,默认实例名为"MSSQLSERVER". Figure-1: 在OS Services中启动 (2)在SQL Server Configuration Manager中启动. Figure-2: 在SQL Server Configuration Manager中启动 (3)在

有关WINDOWS XP登录密码的几种方法

网上关于破解WINDOWS XP登录密码的几种方法很多,但许多根本不行.我现在总结自己试过几种,这几种方法其实均比较菜的,但可行的.WINDOWS XP登录是由SAM 文件管理的,总体来说“山姆大叔”是比较难搞定的,所以网上许多方法不行的原因吧.上次在网上看到关于一篇关于SAM 文件的文章,写得不错,但没能收藏起来.反正有不少人在研究这个.我想就是有了破解的方法,高手们也不一定全公布吧,这是由于大家不难知道的原因——安全,他们不便公布!如果很轻易就破了的话,那微软一定要打这个补丁的,那他们的成果

跨域的几种方法

js中几种实用的跨域方法原理详解(转自:http://www.cnblogs.com/2050/p/3191744.html) 这里说的js跨域是指通过js在不同的域之间进行数据传输或通信,比如用ajax向一个不同的域请求数据,或者通过js获取页面中不同域的框架中(iframe)的数据.只要协议.域名.端口有任何一个不同,都被当作是不同的域. 下表给出了相对http://store.company.com/dir/page.html同源检测的结果: 要解决跨域的问题,我们可以使用以下几种方法:

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

Spring+Hibernate两种方法实现增删改查 首先,定义一个Customer的bean类,设置好Customer.hbm.xml文件.再定义好一个Dao接口.准备好一个jdbc.properties文件. 第一种方法: 在dao类中定义一个HibernateTemplate类的对象,用该对象调用HibernateTemplate模板封装好的方法,如下: /*** * hibernateTemplate的转配模式 */ public class CustomerDaoImpl implem