Я пытаюсь добавить внешний контакт с MS Exchange с помощью Powershell.Команда Powershell не найдена после PSSession Импорт
$username = "[email protected]"
$password = "password"
$secure_password = $password | ConvertTo-SecureString -AsPlainText -Force
$credencial = New-Object System.Management.Automation.PSCredential ($username, $secure_password)
$session_name = "office365_session"
foreach($tmp in Get-PSSession){
if ($tmp.Name -eq $session_name) {
$opened_session = Get-PSSession -Name $session_name
}
}
if ($opened_session -eq $null) {
$opened_session = New-PSSession -Name $session_name -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $credencial -Authentication Basic -AllowRedirection -WarningAction SilentlyContinue -ErrorAction Stop
Import-PSSession $opened_session -AllowClobber -WarningAction SilentlyContinue -ErrorAction Stop -DisableNameChecking | Out-Null
}
New-MailContact -Name "test" -DisplayName "test user" -ExternalEmailAddress "[email protected]" -FirstName "Test" -LastName "User"
Но команда "Нью-MailContact" не найден и выдает ошибку:
New-MailContact : The term 'New-MailContact' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Как запускать эту команду "New-MailContact"? Может быть, мне нужно импортировать что-то еще или, возможно, есть еще один способ добавить контакт?
Добавить оснастку после импорта сеанса. – websch01ar