简体   繁体   English

如何在所有域计算机上使用I Exchange命令?

[英]How can use I Exchange Commands on all domain computers?

How can call Exchange commands to get mailbox information on a standard domain computer without the Exchange Management Shell installed? 在未安装Exchange命令行管理程序的情况下,如何调用Exchange命令以在标准域计算机上获取邮箱信息?

  • Run PowerShell directly on remote Exchange server over RDP. 通过RDP直接在远程Exchange服务器上运行PowerShell。
  • Invoke-command on a local machine to remote Exchange Server. 在本地计算机上向远程Exchange Server调用命令。
  • Import-Commands of the Exchange server on a local machine. 本地计算机上Exchange服务器的导入命令。

I write a script to use localy all exchange 2010+ commands without needed instaling the exchange tools. 我编写了一个脚本,以使用本地所有的exchange 2010+命令,而无需安装交换工具。

use like 使用像

Import-ExchTools 'MyDomain'
get-mailbox $(whoami)

include in your script 在脚本中包含

function Get-RmExchSession ($AD='MyDomain') {
    Get-PSSession | Remove-PSSession
    $SrvBlackList = @('vexchmb7','vexchmb6', 'vexchtopt1')
        $PoolExch = $(
                (Get-ADGroupMember -server $AD 'Exchange Servers') | ?{$_.objectClass -eq 'computer'} | ?{$_.Name -and $SrvBlackList -notcontains $_.name} | Sort-Object -Descending CreationDate | %{
                    [pscustomobject][ordered]@{
                        name = $_.Name
                        dNSHostName = "$($_.Name).$AD.adds"
                    }
                }
        )

    foreach ($exch in $PoolExch) {
        $ExchSession = $null
        #Write-Host $Exch.dNSHostName -nonewline
        if (Test-connexion $Exch.dNSHostName) {
            # on se connecte au dernier Srv exchange mis en place, le plus ressant
            # ne fonctionne pas sur les AD avec approbation unidirectionnele, il faut le credential ADMIN
            $ExchSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://$($Exch.dNSHostName)/PowerShell/" -ea SilentlyContinue

            if ($ExchSession) {
                #Write-Host " Session OK" -fore Green
                return $ExchSession
            } else {
                Write-host " Impossible de se connecter avec le Current Credential, tentative avec '$AD\Administrateur'" -fore Red -NoNewline
            }
        }
    }
    $null
}

function Import-ExchTools ($AD='MyDomain') {
    $exchSess = (Get-RmExchSession $AD)
    if ($exchSess) {
        Import-PSSession $exchSess -wa 0 | Out-Null
        $exchSess
    }
    return $null
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在PowerShell中将所有Active Directory计算机读入阵列? - How can I read all Active Directory computers into an array in PowerShell? 如何定位域中的特定容器和特定计算机? - How can I target a specific container and specific computers within my domain? 如何将PowerShell脚本推送到域计算机? - How do I push a PowerShell script out to domain computers? 如何使用WMI获取计算机的当前OU并列出该OU中的所有其他计算机? - How do I use WMI to get the current OU of a computer and list all other computers in that OU? 脚本调优以包括域中的所有计算机 - script tuning for include all computers in domain 需要扫描所有域计算机上的.pst文件 - Need to scan all domain computers for .pst files 如何使用 PowerShell 获取多台计算机的 RAM/内存详细信息? - How can I use PowerShell to get RAM / Memory details of multiple computers? 在 Powershell 中,如何正确使用 Get-CimInstance 来检索各个计算机的 IPV6 地址? - In Powershell, how can I correctly use Get-CimInstance to retrieve the IPV6 addresses of respective computers? 我如何使所有这些命令一起运行 - How can i make all of these commands run together 如何使用Powershell查找所在计算机列表是否是域? - How to find if a list of computers on are a domain using Powershell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM