一、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. mysql sql_mode配置

    查看mysql sql_mode SELECT @@GLOBAL.sql_mode; 修改mysql sql_mode: set global sql_mode=''; 修改my.ini: sql_m ...

  2. sklearn中xgboost模块中plot_importance函数(特征重要性)

    # -*- coding: utf-8 -*- """ ######################################################### ...

  3. php里面的编码问题

    1 获取当前字符串的编码 $encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312",& ...

  4. 多线程-Executor,Executors,ExecutorService,ScheduledExecutorService,AbstractExecutorService

    引用 系统启动一个新线程的成本是比较高的,因为涉及与操作系统交互.使用线程池可以很好地提高性能,尤其是当程序中需要创建大量生存期很短的线程时,更应该考虑使用线程池.线程池在系统启动时即创建大量空闲的线 ...

  5. Linux高性能server编程——I/O复用

     IO复用 I/O复用使得程序能同一时候监听多个文件描写叙述符.通常网络程序在下列情况下须要使用I/O复用技术: client程序要同一时候处理多个socket client程序要同一时候处理用户 ...

  6. 171. Anagrams【medium】

    Given an array of strings, return all groups of strings that are anagrams. Notice All inputs will be ...

  7. 前端点击删除按钮删除table表格的数据

    table.on('tool(hostTable)', function (obj) { var data = obj.data;//须写 if (obj.event === 'del') { var ...

  8. java全局变量使用

    1.在多线程的作用下,全局变量可能被多个程序使用,如果有人修改,全局变量就被修改了,导致别人使用的时候,出现问题 2.解决方法: 全局变量改为私有变量. 或者把全局变量改为final类型,只能读取,不 ...

  9. Unix系统编程(五)read系统调用

    read系统调用从文件描述符fd所指代的打开文件中读取数据. ssize_t read(int fd, void *buffer, size_t count); count参数指定最多能读取的字节数, ...

  10. CSS border-style 属性查询

    border-style 属性用于设置元素所有边框的样式,或者单独地为各边设置边框样式.只有当这个值不是 none 时边框才可能出现. none solid dotted dashed double ...