Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/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将SMTPAddress详细信息导出到.CSV失败?_Powershell_Active Directory_Office365_Exchange Server - Fatal编程技术网

PowerShell将SMTPAddress详细信息导出到.CSV失败?

PowerShell将SMTPAddress详细信息导出到.CSV失败?,powershell,active-directory,office365,exchange-server,Powershell,Active Directory,Office365,Exchange Server,我编写此PowerShell脚本是为了导出以下信息: Name Mail ObjectClass SMTP Address (only SMTP and smtp addresses) DistinguishedName RecipientTypeDetails --> This is to know what type of Mailbox (Shared, User,Resource,etc...) WhenMailboxCreated WhenChanged WhenCreated

我编写此PowerShell脚本是为了导出以下信息:

Name 
Mail
ObjectClass
SMTP Address (only SMTP and smtp addresses)
DistinguishedName
RecipientTypeDetails --> This is to know what type of Mailbox (Shared, User,Resource,etc...)
WhenMailboxCreated
WhenChanged
WhenCreated
Identity
SKUAssigned
因为不知何故,它只显示了: 名称、邮件、对象类区分名称,而SMTP地址列为空

这是我的剧本:

function Get-EmailAddress
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $True,
                   ValueFromPipeline = $True,
                   ValueFromPipelineByPropertyName = $True,
                   HelpMessage = 'What e-mail address would you like to find?')]
        [string[]]$EmailAddress
    )

    process
    {       
        foreach ($address in $EmailAddress)
        {
            Get-ADObject -Properties mail, proxyAddresses -Filter "mail -like '*$address*' -or proxyAddresses -like '*$address*'" | 
                Select Name, 
                       Mail, 
                       ObjectClass,
                       @{Label='SMTP Address';Expression={ $address.proxyAddresses | ?{ $address -Like "*smtp*" } -replace 'smtp:' -join ';' }},
                       DistinguishedName
            Get-Recipient $address | 
                Select DisplayName, 
                       RecipientType, 
                       RecipientTypeDetails, 
                       EmailAddresses, 
                       *When*, 
                       Identity, 
                       SKUAssigned
        }
    }
}

Get-EmailAddress HelpDesk,ServiceDesk | Export-Csv -Path C:\TEMP\Result.csv -NoTypeInformation

我也经历过类似的事情

我不知道为什么,但您必须在
获取对象属性SMTP
中包含“SMTP”属性,或者使用
-Properties*

?{$address-Like“*SMTP*”}
->
?{$\Like”*SMTP*“}