Powershell command not found after PSSession Import -


I'm trying to add external contacts with MS Exchange with Pavarseld.

$ username = "username@domain.com" $ password = "password" $ secure_password = $ password | ConvertTo-SecureString -AsPlainText Force $ credencial = new-object System.Management.Automation.PSCredential ($ username, $ secure_password) $ session_name = "office365_session" a get foreach ($ tmp PSSession) {if ($ tmp.Name - eq $ session_name) {$ opened_session = get-PSSession -nam $ session_name}} if ($ opened_session -eq $ null) {$ opened_session = New-PSSession -nam $ 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 -nam "test" -DisplayName "test user" -ExternalEmailAddress "some.email@mail.com" -FirstName "Test" -LastName "user"

But "New-MailContact" command not found and throws an error:

  New-MailContact: The term 'New-MailContact' is not recognized as the name of a cmdlet, function, script file , Or check the spelling of the operative program name, or if the path is included, verify that the path is correct and try again  

How to run that "New-MailConnectac" command? Maybe I need to import something else, or maybe there is another way to add contacts?

part does not work because you are importing a session exchange box.

Here is an example for O365

  $ session = New-PSSession-ConfigurationName Microsoft Exchange-connection Yuri https://ps.outlook.com/powershell-Credential $ credencial- authentication Basic-olive radiation;  

Only you can run Stop-DisableNameChecking

  Import-PSSession $ session -AllowClobber -WarningAction SilentlyContinue -ErrorAction. Out-null New-Mail-Contact -Name "Test" -DisplayName "Test User" -ExternalEmailAddress "some.email@mail.com" -First name "Test" -ListName "User"  
< / Div>

Comments