whenz
asked on
Exchange Powershell Script not running when launched from batch file
I have a batch file which launches an exchange powershell script:
The thing is that when I manually launch the StartExport.bat file the scripts runs through as expected. I developed a small .exe file which launches the StartExport.bat and then nothing happens. I see in the Windows Task Manager that powershell.exe runs for 2 seconds and then stops. The .exe only launches the StartExport.bat, nothing else.
Any help is appreciated!
+++++++++++++ StartExport.bat +++++++++++++
@ECHO OFF
powershell.exe Set-ExecutionPolicy Unrestricted
powershell.exe -command "& {C:\opensystems\RuntimeScripts\ExportScript1.ps1 }"
+++++++++++++ StartExport.bat +++++++++++++
+++++++++++++ ExportScript1.ps1 +++++++++++++
function LoadExchangeTools {
if (-not (Get-pssnapin | ? {$_.name -like 'Microsoft.Exchange'})) {
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.e2010
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
}
}
LoadExchangeTools
$OpenSystemsMailboxes = "OpenSystemsMailboxes"
$OpenSystemsAliasManaged = "OpenSystemsAliasManaged"
.
.
.
.
.
+++++++++++++ ExportScript1.ps1 +++++++++++++
The thing is that when I manually launch the StartExport.bat file the scripts runs through as expected. I developed a small .exe file which launches the StartExport.bat and then nothing happens. I see in the Windows Task Manager that powershell.exe runs for 2 seconds and then stops. The .exe only launches the StartExport.bat, nothing else.
Any help is appreciated!
Did you specify the credentials to be used when running this scheduled task?
ASKER
I think I know what the problem is.
When I launch my .exe I see in the taskmanager the process powershell.exe*32. When I launch the .bat file directly I see powershell.exe in the task manager.
Therefore it seems that something with the .exe is wrong ...
Regards,
When I launch my .exe I see in the taskmanager the process powershell.exe*32. When I launch the .bat file directly I see powershell.exe in the task manager.
Therefore it seems that something with the .exe is wrong ...
Regards,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.