Problem with executing Exchange Powershell Script
Problem with executing Exchange Powershell Script
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
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
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.
Regards
Alex
=================
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.
Bad ideaI tried the following command:
cmd /c %Script% %Params%
Script:
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 scriptscmd /c powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command Test-ReplicationHealth
Regards
Alex
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
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
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
We are using both Exchange 2007 SP2 Standard and Enterprise Edition on a Windows 2008 64 bit Enterprise and Standard Server.Tell me please, what Exchange version do you use ?
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
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...Could it be, that the RMA agent must be compiled for 64bit?
Regards
Alex
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
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
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
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
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Such error message may appear when you work with RCC GUI and RCC needs to send request to the agent thru HostMonitor.300 - request timed out (RCC <-> HM <-> RMA)
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
I will get this error via the RCC Gui on my client within in the Script Manager - Lets try.Am I wrong? When exactly do you see this error?
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
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
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