Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 如何在所有域计算机上使用I-Exchange命令?_Powershell_Powershell Remoting_Exchange Server 2010 - Fatal编程技术网

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

Powershell 如何在所有域计算机上使用I-Exchange命令?,powershell,powershell-remoting,exchange-server-2010,Powershell,Powershell Remoting,Exchange Server 2010,在没有安装Exchange命令行管理程序的情况下,如何调用Exchange命令来获取标准域计算机上的邮箱信息 通过RDP直接在远程Exchange服务器上运行PowerShell 将本地计算机上的命令调用到远程Exchange服务器 在本地计算机上导入Exchange服务器的命令 我编写了一个脚本,在本地使用所有exchange 2010+命令,而无需安装exchange工具 像 Import-ExchTools 'MyDomain' get-mailbox $(whoami) 包括在脚本中

在没有安装Exchange命令行管理程序的情况下,如何调用Exchange命令来获取标准域计算机上的邮箱信息

  • 通过RDP直接在远程Exchange服务器上运行PowerShell
  • 将本地计算机上的命令调用到远程Exchange服务器
  • 在本地计算机上导入Exchange服务器的命令

我编写了一个脚本,在本地使用所有exchange 2010+命令,而无需安装exchange工具

Import-ExchTools 'MyDomain'
get-mailbox $(whoami)
包括在脚本中

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
}