Я пытаюсь использовать:
**# Credentials for the user Mailbox to configure Out-of-office schedule for**
$UserCredential = Get-Credential -UserName user@contoso.com
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
$EXOModule = Import-PSSession $Session
$StartTime = Get-Date 17:00
$EndTime = Get-Date 8:00
**# AutoReplyState = Enabled/Disabled/Scheduled**
Set-MailboxAutoReplyConfiguration -Identity $UserName -StartTime $StartTime -EndTime $EndTime -AutoReplyState Scheduled
**# Cleanup**
Remove-Module -Name $EXOModule.Name
Remove-PSSession $Session
Но меня постоянно спрашивают:
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Есть ли способ указать имя пользователя и пароль или указать строку или что-то?
Как я могу автоматизировать это без ошибок?
Может быть:
param (
[string]$UserName
)
**# Credential for the user mailbox to configure Out-of-office schedule for**
$UserCredential = Get-AutomationPSCredential -Name $UserName
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
$EXOModule = Import-PSSession $Session
**# One hour earlier due to different time zone on the server side**
$StartTime = Get-Date 07:00
$EndTime = Get-Date 15:00
**# AutoReplyState = Enabled/Disabled/Scheduled**
Set-MailboxAutoReplyConfiguration -Identity $UserName -StartTime $StartTime -EndTime $EndTime -AutoReplyState Scheduled
**# Cleanup**
Remove-Module -Name $EXOModule.Name
Remove-PSSession $Session
Но где мне указать имя пользователя и пароль?