본문 바로가기
ICT

[PowerShell] Remote Session Connection Issue Remediation

by NeoSailer 2024. 3. 12.

[Scenario]

- After replacing Exchange server, account creation script did not work

- The error message is "Please connect to Rotorks On-Premise Exchange (Please connect to Rotorks On-Premise Exchange)" which seems a customized error message

 

[Objectives]

- Examine related PowerShell scripts and remediate them

 

[Remediation]

- Go to the Azure automation account where account creation script belong to

 

- The script is ran on on-premise system via hybrid-worker. So figure out what is the on-premise server by check hybrid worker groups

 

Automation Account --> Group Name --> Hybrid worker group

 

 

 

- Remote control the on-premis server then open PowerShell

 

- In the PowerShell script, customized fucntions are seen but cannot figure out where they are from

 

- Ran "$env:PSmodulePath" to figure out the module library path

PS C:\Users\admin.jyoon> $env:PSModulePath
C:\Users\admin.jyoon\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\Common Files\Skype for 
Business Online\Modules\;C:\Program Files\Microsoft\HybridConnectionManager 0.7\;C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\;C:\Program Files (x86)\Microsoft Endpoint Manage
r\AdminConsole\bin;C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.1840.0

 

- Seems "C:\Program Files\WindowsPowerShell\Modules" is the most probable candidate thus go to the path and search library files

 

- Open "Rotork.Exchange.Management" folder and open "Rotork.Exchange.Management.psm1"

 

- The customized functions, Function New-RotorkExchangeMailbox and Function Get-RotorkExchangeMailbox are in the library. Now updated the server name

 

- After changing server name, the script works!

반응형

댓글