Forum Discussion
fil232323
Nov 11, 2024Copper Contributor
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...
- 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-mailboxor 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
kyazaferr
Nov 12, 2024MCT
Install-Module -Name ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName email address removed for privacy reasons -ShowProgress $true
If you're connecting to On-Premises Exchange (using PowerShell remoting):
- Make sure that your PC is connected via VPN and that the server's ports are reachable.
- Ensure that PowerShell remoting is configured on the server, as mentioned above.
- $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://mail.mydomain.com/powershell/ -Credential $cred -Authentication Basic -AllowRedirection
Enter-PSSession $session - est if PowerShell Remoting is working: Test if WinRM is working between your machine and the Exchange server by running:
- Test-WSMan -ComputerName <ExchangeServer>
- If this test fails, you may have to enable WinRM on both your machine and the server.
- Check if VPN is correctly configured: If you're not able to connect via VPN, ensure that your VPN client allows for DNS resolution to the domain and network routing to the Exchange server.
- Check firewalls and proxies: Ensure there are no network-level restrictions (like firewalls or proxy servers) blocking your connection.
kyazaferr
Nov 12, 2024MCT
To connect remotely to an Exchange server from a non-domain PC, ensure that you have:
- A working VPN connection to the domain.
- Correct authentication settings (full domain user or email address and correct password).
- PowerShell remoting enabled on the server.
- Correct URLs and use HTTPS for secure connections.