9 lines
618 B
PowerShell
9 lines
618 B
PowerShell
$username='adm_exch@domain'
|
|
$pwsd='superpass'
|
|
$password = ConvertTo-SecureString $pwsd -AsPlainText -Force
|
|
$Cred = New-Object System.Management.Automation.PSCredential ($username, $password)
|
|
|
|
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://win2016-dc-exch.domain/powershell/ -Authentication Basic -AllowRedirection -Credential $Cred
|
|
Invoke-Command -Session $Session -ScriptBlock { Get-Mailbox -OrganizationalUnit domain/NSD -ResultSize Unlimited } | Format-List DisplayName, WindowsEmailAddress, CustomAttribute1 | Out-File -Encoding UTF8 mailbox.nausd
|
|
Remove-PSSession $Session
|