Forum Discussion

fil232323's avatar
fil232323
Copper Contributor
Nov 11, 2024
Solved

How to connect to exchange in domain from non-domain network

Hi I'm trying to connect from my home PC to Exchange (via VPN) like this $username = "mylogin" $password = "p@$$w0rd" $securePassword = ConvertTo-SecureString $password -AsPlainText -Force $cre...
  • fil232323's avatar
    Nov 13, 2024

    Thanks for the advice, but I've already done and checked all this a long time ago. That's why I wrote here to find a solution.

    As a result, I found a solution.

    you need to make the following settings in iis.
    in the Default Web Site - PowerShell section
    you need to select the "Authentication" item and enable Basic authentication in it

    $username = "login@domain"  
    $password = "P@$$w0rd" 
    $securePassword = ConvertTo-SecureString $password -AsPlainText -Force
    $cred = New-Object System.Management.Automation.PSCredential($username, $securePassword)
    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchange2019.domain.local/powershell/ -Authentication Basic -Credential $Cred -AllowRedirection
    Import-PSSession $Session 
    Get-mailbox

    or via exchange server (10.10.0.42)

    $username = "login@domain"  
    $password = "P@$$w0rd" 
    $securePassword = ConvertTo-SecureString $password -AsPlainText -Force
    $cred = New-Object System.Management.Automation.PSCredential($username, $securePassword)
    Enter-PSSession -ComputerName 10.10.0.42 -Credential $cred
    $username = "login@domain"  
    $password = "P@$$w0rd" 
    $securePassword = ConvertTo-SecureString $password -AsPlainText -Force
    $cred = New-Object System.Management.Automation.PSCredential($username, $securePassword)
    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchange2019.domain.local/powershell/ -Authentication Basic -Credential $Cred -AllowRedirection
    Import-PSSession $Session 
    Get-mailbox

     

Resources