Problem with executing Exchange Powershell Script

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
mp1
Posts: 199
Joined: Tue Mar 07, 2006 3:24 am

Problem with executing Exchange Powershell Script

Post by mp1 »

Hi,

I am trying to execute a Exchange Powershell Script via the Shell Script test method.

I tried the following command:

cmd /c %Script% %Params%

Script:

powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command Test-ReplicationHealth

and also direct via

powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command Test-ReplicationHealth

or cmd /c powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command Test-ReplicationHealth

Unfortunately I will always get the same error:

[08:40:51] Agent: xxxx is going to execute "ClusterStatus" script ...
[08:40:52] Script started, invalid result received:
----------
WARNING: The following errors occurred when loading console C:\Program
Files\Microsoft\Exchange Server\bin\exshell.psc1:
Cannot load Windows PowerShell snap-in
Microsoft.Exchange.Management.PowerShell.Admin because of the following error:
No Windows PowerShell Snap-ins are available for version 1.
Command "Test-ReplicationHealth" could not be executed because some Windows PowerShell snap-ins did not load.
----------


When I execute the command directly on the server, I have no problems.
Do you have any idea why the exschell.psc1 can't be load?

Thanks in advance

Martin
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Quote:
=================
Exchange 2007 is only supported on 64-bit Windows and is, itself, a 64-bit application, therefore many of the components including the shell extensions are 64-bit.

On a 64 bit version of Windows with Powershell installed there are two versions of Powershell.exe. One is the 32-bit version (found at C:\WINNT\syswow64\windowspowershell\v1.0\powershell.exe) and the other is the 64-bit version (found at C:\WINNT\system32\windowspowershell\v1.0\powershell.exe). The Exchange Management Shell snap-in will only load into the 64-bit Powershell. If you try to load it into the 32-bit Powershell.exe, you get the error message above.
=================
http://blogs.msdn.com:80/mstehle/archiv ... ap-in.aspx

So, if you specify command line like C:\Windows\system32\windowspowershell\v1.0\powershell.exe\ -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command Test-ReplicationHealth it should work.

I tried the following command:
cmd /c %Script% %Params%
Script:
powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command Test-ReplicationHealth
Bad idea
cmd /c powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command Test-ReplicationHealth
No, you don't need cmd.exe for Power Shell scripts

Regards
Alex
mp1
Posts: 199
Joined: Tue Mar 07, 2006 3:24 am

Post by mp1 »

Hi Alex,

Unfortunately I will get the same error with the full path.
There is already a System Path on: C:\Windows\system32\windowspowershell\v1.0\
So when I excute the powershell.exe, the 64-bit version will be load.

For further information - the HM agent is running on a 64bit Windows 2008 Enterprise Server.

I have done some further tests:
When I try to execute the command on a Windowx XP Client 32 bit with Exchange Management Console installed, it will work without problems:

Command:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Programme\Microsoft\Exchange Server\bin\exshell.psc1" -command Get-Acl

I also tried to execute the 32-bit powershell on the 64-bit server, the same problem.

I am not a developer, although when I do some search, there are many entries with the question: "Is your programm compiled for 64bit?"

Thanks again and best regards,

Martin
mp1
Posts: 199
Joined: Tue Mar 07, 2006 3:24 am

Post by mp1 »

Hi Alex,

Do you have any further idea to solve this problem?
Could it be, that the RMA agent must be compiled for 64bit?

Thanks,

Martin
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Martin,

We're currently trying to find out the reason, but no clear results yet.
Tell me please, what Exchange version do you use ?
mp1
Posts: 199
Joined: Tue Mar 07, 2006 3:24 am

Post by mp1 »

Tell me please, what Exchange version do you use ?
We are using both Exchange 2007 SP2 Standard and Enterprise Edition on a Windows 2008 64 bit Enterprise and Standard Server.

The test I have done on the Enterprise Server, tomorrow I will check the same on the Standard Server, although I think there is no difference - the problem seems to be the 64bit edition.

Thanks again,

Martin
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Could it be, that the RMA agent must be compiled for 64bit?
Not really necessary. RMA is 32bit application however script is executed by powershell processor that can be 32bit or 64bit application. As you see RMA is able to execute 64bit powershell.exe. Questions is why powershell.exe cannot execute script...

Regards
Alex
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Oh, I forgot about redirection... When you type C:\Windows\system32 using any 32bit application, 64bit Windows REDIRECTS all file requests to C:\Windows\SysWOW64 so RMA starts 32bit powershell.exe anyway!

There is hotfix for 64bit Windows Server 2003
http://support.microsoft.com/kb/942589
After you install the following hotfix, a 32-bit application can access the following native system folder using %WinDir%\Sysnative path instead of the %WinDir%\System32 path.
WOW64 recognizes the Sysnative folder as a special alias. Therefore, the file system does not redirect access away from the Sysnative folder.

Windows 2008 does not need this fix, you may use path like c:\Windows\Sysnative\windowspowershell\v1.0\powershell.exe

Another posible solution: create hard link. E.g. using the following command
linkd.exe %SystemRoot%\System64 %SystemRoot%\System32
Then use new path for 32bit applications (RMA)

Regards
Alex
mp1
Posts: 199
Joined: Tue Mar 07, 2006 3:24 am

Post by mp1 »

Great - it's working now, although only with the passive RMA, with the active RMA I get the following error:

Response from the agent: 300 - request timed out (RCC <-> HM <-> RMA)

I already increased the timeout to 60 sec, so I don't think this has someting to do with a timeout and it has nothing to do with the command.

When I don't load the exchange powershell, than I haven't any problems.

Best regards,

Martin
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Martin,

What about connection between HM and active RMA? Are you able to run tests with active RMA and see the results in HM?

Regards
Tom
mp1
Posts: 199
Joined: Tue Mar 07, 2006 3:24 am

Post by mp1 »

What about connection between HM and active RMA? Are you able to run tests with active RMA and see the results in HM?
I havn't any problems with oter tests wth the active RMA, although at the moment I have only some service check tests.

Regards,

Martin
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

300 - request timed out (RCC <-> HM <-> RMA)
Such error message may appear when you work with RCC GUI and RCC needs to send request to the agent thru HostMonitor.
I don't think this error has anything to do with test execution (test == "test item", not some "Test" button profided by GUI ).
Am I wrong? When exactly do you see this error?

Regards
Alex
mp1
Posts: 199
Joined: Tue Mar 07, 2006 3:24 am

Post by mp1 »

Am I wrong? When exactly do you see this error?
I will get this error via the RCC Gui on my client within in the Script Manager - Lets try.

I checked now the same on the Hosmonitor server, now I get this error:

[11:46:46] Agent error: no responce from agent within specified timeout

The timeout is on 120 sec, with the passive agent I have no problems.

Regards,

Martin
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

What about test item itself (not GUI "lets try" option)?
If test works fine and you have problem with RCC<->HostMonitor<->Active RMA communication, please increase timeout specified for RCC<->HostMonitor communication. This timeout can be specified on 1st windows displayed by RCC (before connection to HostMonitor is established)
http://www.ks-soft.net/images/hostmon4/rcc1.gif

Regards
Alex
mp1
Posts: 199
Joined: Tue Mar 07, 2006 3:24 am

Post by mp1 »

sorry, for the late reply, was out of the office ...

I just checked it with the test item it self and it's working with both agents.
As mentioned I checked it also direct on the HM server, so I think there will be now RCC timeout? Or I can't find this option

Best regards,

Martin
Post Reply