Powershell Task issues - VisualCron - Forum

Community forum

Nikolaj Pedersen
2014-10-15T08:36:08Z
I'm having trouble figuring out how to run a Powershell script correctly, there is no documentation about best practice with user profiles/credentials.

The behavior of the Powershell Task varies alot, especially when I'm importing modules in the script, such as AD module, Exchange etc.
I usually end up with just CMD execute task, where i add:
C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -ExecutionPolicy Bypass -File "C:\SCRIPT.ps1", instead of using the Powershell Task.

Using the normal Powershell Task will usually give me a lot of crazy errors.
Windows Server 2008R2 x64, VisualCron 7.2.1, Powershell Version 3.0.

At the moment, I'm trying to run a regular script, as you can see on this screenshot, it works perfectly fine, running from a normal Powershell console, as the user, 'batchService'.

VC Powershell task settings and normal Powershell Console run:
Powershell Task Settings and Powershell Console


When I run the task, a process has stopped working - the VisualCron TaskPowershell.exe
VC Error message and Task has stopped working

Any suggestions?
Support
2014-10-15T09:11:45Z
Try unchecking Load profile and Local logon if you try to access a UNC share to see if it works better?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nikolaj Pedersen
2014-10-15T09:29:18Z
Originally Posted by: Support 

Try unchecking Load profile and Local logon if you try to access a UNC share to see if it works better?


It's the same scenario:

VC Error output:
11:25:00: Server->Execute path: C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe
11:25:00: Server->Executing Task process
Is 64 bit process: True
Is 64 bit operating system: True
Current user: NT AUTHORITY\SYSTEM
.NET version: 4.0.30319.18444
AddExceptionHandlers
AddAssemblyLoadEvent
Argument(0): 220696
CreateTaskServiceChannel
CreateTaskServiceChannel->Complete
pts.CreateService(UniqueAddressId)
11:26:03: Server->Executing Task process exited with exit code: 255
Support
2014-10-15T09:39:39Z
Originally Posted by: Nikolaj Pedersen 

Originally Posted by: Support 

Try unchecking Load profile and Local logon if you try to access a UNC share to see if it works better?


It's the same scenario:

VC Error output:
11:25:00: Server->Execute path: C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe
11:25:00: Server->Executing Task process
Is 64 bit process: True
Is 64 bit operating system: True
Current user: NT AUTHORITY\SYSTEM
.NET version: 4.0.30319.18444
AddExceptionHandlers
AddAssemblyLoadEvent
Argument(0): 220696
CreateTaskServiceChannel
CreateTaskServiceChannel->Complete
pts.CreateService(UniqueAddressId)
11:26:03: Server->Executing Task process exited with exit code: 255



But it crashed before and now it is not?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nikolaj Pedersen
2014-10-15T11:07:16Z
It crashed before and it crashes now.
As I wrote, the same scenario, nothing changes.
Support
2014-10-15T12:39:57Z
Ok, so it gives exit code but crashes. Could you please test this with the latest beta 7.5.0 as well?

http://www.visualcron.co....aspx?g=posts&t=4540 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nikolaj Pedersen
2014-10-16T11:34:37Z
Hi Henrik,
After a reboot, the unchecking of Load profile and Local logon made the task stop crashing.
But now, the task executes fine, but the script doesn't execute. It just 'outputs' the UNC path to the script as a string, and displays 'Success' in Result.

Job screendump:
UserPostedImage
Nikolaj Pedersen attached the following image(s):
Support
2014-10-16T12:36:28Z
Originally Posted by: Nikolaj Pedersen 

Hi Henrik,
After a reboot, the unchecking of Load profile and Local logon made the task stop crashing.
But now, the task executes fine, but the script doesn't execute. It just 'outputs' the UNC path to the script as a string, and displays 'Success' in Result.

Job screendump:
UserPostedImage



I think it executes but not do what you want. What if you write to the output in a sample script?

By the way, did you try the new version?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nikolaj Pedersen
2014-10-16T12:46:34Z
I'm quite sure that it doesn't execute.
How do you want me to write to the output?
Using Write-host, Write-Out or what cmdlet?
To a file?
Support
2014-10-16T12:49:24Z
Yes, try Write-Host
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nikolaj Pedersen
2014-10-16T13:16:18Z
I've written this small script:

Executed from: \\UNC\PATH\SCRIPTS\TestScript.ps1
$fileName = "test.txt"
Write-Host "This is a test - file name is $fileName written with WriteHost cmdlet"
Write-Output "This is a test - file name is $fileName written with WriteOutput cmdlet"
Copy C:\temp\$fileName -Destination \\UNC\PATH\Temp\


Output in VC is still:
"\\UNC\PATH\SCRIPTS\TestScript.ps1"
Result: Success

No, I have not tried using VC 7.5 Beta yet.
Nikolaj Pedersen attached the following image(s):
bbusse
2014-10-16T14:41:03Z
Same problem in the latest 7.5.0 beta, Henrik.

I haven't used a powershell task for quite a while, and when i do it's usually very simple so i just type my code into the area where you can, vs saving a PS1 file on the filesystem. So I tried in 7.1.4, 7.2.1, and 7.5.0 beta. All 4 versions just display the filename in the Output. StdError has no output. My script was simply this:

GCI c:\temp\

it should've listed the files I have in c:\temp, like it does if I just put the code in vs referencing a PS1 file. Also, since in our environment we normally run VisualCron as a service account, I changed mine to use 'Local System' like VC does by default, with the same result.

In 7.5.0 beta, I also tried executing the PS1 file in x86 mode, just to make sure. Same result, just lists the path to the PS1 file as the output.

BTW, i don't think you can use write-host using a powershell task. It's not a 'traditional' Console-Host environment for powershell, like running PowerShell.exe. Different context. Just thought i'd mention that. When you do try, you'll get a message like this (see screenshot)

Brian
bbusse attached the following image(s):
Support
2014-10-20T07:34:16Z
Thanks, we have now fixed various issues in this version. Please try it:

http://www.visualcron.co....aspx?g=posts&t=4540 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2014-10-20T07:35:13Z
By the way, to write to console you should use:

write-output
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nikolaj Pedersen
2014-10-24T08:48:20Z
This sounds really good.
Do you have an estimated release for the stable version?
Nikolaj Pedersen
2014-11-06T16:14:31Z
Upgrading to the new release of 7.5.0 doesn't seem to work for me:

17:13:26: Server->Execute path: C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe
17:13:26: Server->Executing Task process
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->CreateService->Response channel created on address: /TaskProcess/2195
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Requesting Task information
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
17:13:26: Server->Sending Task information
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Task information sent
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Task information received
17:13:26: Server->Task information sent
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before PowerShell execution
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: VisualCronAPI, Version=1.0.3.23712, Culture=neutral, PublicKeyToken=55f7a52402de1c04
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before impersonation
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.CreateRunspace
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.Commands.Diagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.Commands.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.WSMan.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.ThreadOptions
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.Open
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Success opening Runspace(1): UseCurrentThread
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.CreatePipeline
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.Invoke
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Preparing Task log
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Sending result
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Result sent
Is 64 bit process: True
Is 64 bit operating system: True
Current user: NT AUTHORITY\SYSTEM
.NET version: 4.0.30319.18444
AddExceptionHandlers
AddAssemblyLoadEvent
Argument(0): 2195
CreateTaskServiceChannel
CreateTaskServiceChannel->Complete
pts.CreateService(UniqueAddressId)
pts.CreateService(UniqueAddressId)->Complete
17:13:28: Server->Executing Task process exited with exit code: 0
17:13:28: Server->Waiting for completion and result
17:13:28: Server->Task result received, success: False
17:13:26: Server->Execute path: C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe
17:13:26: Server->Executing Task process
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->CreateService->Response channel created on address: /TaskProcess/2195
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Requesting Task information
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
17:13:26: Server->Sending Task information
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Task information sent
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Task information received
17:13:26: Server->Task information sent
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before PowerShell execution
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:26: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: VisualCronAPI, Version=1.0.3.23712, Culture=neutral, PublicKeyToken=55f7a52402de1c04
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before impersonation
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.CreateRunspace
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.Commands.Diagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.Commands.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.PowerShell.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Microsoft.WSMan.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.ThreadOptions
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.Open
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Assembly loaded: System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Success opening Runspace(1): UseCurrentThread
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.CreatePipeline
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Before runspace.Invoke
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Preparing Task log
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Sending result
17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)->Result sent
Is 64 bit process: True
Is 64 bit operating system: True
Current user: NT AUTHORITY\SYSTEM
.NET version: 4.0.30319.18444
AddExceptionHandlers
AddAssemblyLoadEvent
Argument(0): 2195
CreateTaskServiceChannel
CreateTaskServiceChannel->Complete
pts.CreateService(UniqueAddressId)
pts.CreateService(UniqueAddressId)->Complete
17:13:28: Server->Executing Task process exited with exit code: 0
17:13:28: Server->Waiting for completion and result
17:13:28: Server->Task result received, success: False


I'm made a new job with a new Powershell task, running a simple test script from an UNC path. With a service user without loading profile checked, a credential that I just added.
bbusse
2014-11-06T16:43:08Z
I have to assume the dual backslashes might not be a good thing? Noticed it several times when it mentions the path to TaskPowerShell.exe



17:13:27: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2195)

Brian
Support
2014-11-06T22:41:30Z
I do not think double backslashes is the problem. But I wonder what error you get in in the error output column?

Also, have you tried to run it with a Credential (with Load profile checked)?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nikolaj Pedersen
2014-11-10T11:56:16Z
This is the output with the local profile checked (Screenshot of task settings attached)
12:41:28: Server->Execute path: C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe
12:41:28: Server->Executing Task process
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->CreateService->Response channel created on address: /TaskProcess/2433
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Requesting Task information
12:41:29: Server->Sending Task information
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Task information sent
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Task information received
12:41:29: Server->Task information sent
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before PowerShell execution
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: VisualCronAPI, Version=1.0.3.23712, Culture=neutral, PublicKeyToken=55f7a52402de1c04
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.Commands.Diagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.Commands.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.WSMan.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before runspace.ThreadOptions
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before runspace.Open
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Success opening Runspace(1): UseCurrentThread
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before runspace.CreatePipeline
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before runspace.Invoke
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Preparing Task log
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Sending result
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Result sent
Is 64 bit process: True
Is 64 bit operating system: True
Current user: DOMAIN\batchService
.NET version: 4.0.30319.18444
AddExceptionHandlers
AddAssemblyLoadEvent
Argument(0): 2433
CreateTaskServiceChannel
CreateTaskServiceChannel->Complete
pts.CreateService(UniqueAddressId)
pts.CreateService(UniqueAddressId)->Complete
12:41:30: Server->Executing Task process exited with exit code: 0
12:41:30: Server->Waiting for completion and result
12:41:30: Server->Task result received, success: False
12:41:28: Server->Execute path: C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe
12:41:28: Server->Executing Task process
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->CreateService->Response channel created on address: /TaskProcess/2433
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Requesting Task information
12:41:29: Server->Sending Task information
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Task information sent
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Task information received
12:41:29: Server->Task information sent
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before PowerShell execution
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: VisualCronAPI, Version=1.0.3.23712, Culture=neutral, PublicKeyToken=55f7a52402de1c04
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.Commands.Diagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.Commands.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.PowerShell.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Microsoft.WSMan.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before runspace.ThreadOptions
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before runspace.Open
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Assembly loaded: System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Success opening Runspace(1): UseCurrentThread
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before runspace.CreatePipeline
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Before runspace.Invoke
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Preparing Task log
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Sending result
12:41:30: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2433)->Result sent
Is 64 bit process: True
Is 64 bit operating system: True
Current user: DOMAIN\batchService
.NET version: 4.0.30319.18444
AddExceptionHandlers
AddAssemblyLoadEvent
Argument(0): 2433
CreateTaskServiceChannel
CreateTaskServiceChannel->Complete
pts.CreateService(UniqueAddressId)
pts.CreateService(UniqueAddressId)->Complete
12:41:30: Server->Executing Task process exited with exit code: 0
12:41:30: Server->Waiting for completion and result
12:41:30: Server->Task result received, success: False


I've attached to pics, the task settings and the folder/log server settings, notice the double backslash again.
Nikolaj Pedersen attached the following image(s):
Support
2014-11-11T09:32:03Z
Ok, first try to launch a very simple script. Maybe that just writes to a local file or something to see if that works.

If it works, then we need to find out which row in your script causes the problem. If we know that we can get closer to why.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nikolaj Pedersen
2014-11-11T16:33:06Z
I created a new task executed the following script, with cred DOMAIN\batchService ( unchecked profile and local) - also tried with no creds.
This is the output from VC:
Is 64 bit process: True
Is 64 bit operating system: True
Current user: HENTON\SYSTEM
.NET version: 4.0.30319.18444
AddExceptionHandlers
AddAssemblyLoadEvent
Argument(0): 2449
CreateTaskServiceChannel
CreateTaskServiceChannel->Complete
pts.CreateService(UniqueAddressId)
pts.CreateService(UniqueAddressId)->Complete
17:26:16: Server->Execute path: C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe
17:26:16: Server->Executing Task process
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->CreateService->Response channel created on address: /TaskProcess/2449
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Requesting Task information
17:26:17: Server->Sending Task information
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Task information sent
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Task information received
17:26:17: Server->Task information sent
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Before PowerShell execution
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: VisualCronAPI, Version=1.0.3.23712, Culture=neutral, PublicKeyToken=55f7a52402de1c04
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Before runspace.CreateRunspace
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: Microsoft.PowerShell.Commands.Diagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: Microsoft.PowerShell.Commands.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: Microsoft.PowerShell.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: Microsoft.WSMan.Management, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Before runspace.ThreadOptions
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Before runspace.Open
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
17:26:17: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Assembly loaded: System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
17:26:18: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Success opening Runspace(1): UseCurrentThread
17:26:18: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Before runspace.CreatePipeline
17:26:18: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Before runspace.Invoke
17:26:18: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Preparing Task log
17:26:18: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Sending result
17:26:18: ExecuteProcess("C:\Program Files (x86)\VisualCron\\TaskPowerShell.exe" 2449)->Result sent
17:26:18: Server->Executing Task process exited with exit code: 0
17:26:18: Server->Waiting for completion and result
17:26:18: Server->Task result received, success: False


testPs2.ps1 script is:
Write-host "Test Host"
Write-Output "Test Output"


Runnes the script from Powershell console:
PS C:\> C:\Temp\testPs2.ps1
Test Host
Test Output
PS C:\> $host


Name             : ConsoleHost
Version          : 3.0
InstanceId       : 787fb278-666e-4f98-946a-97a3945ae6f7
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : da-DK
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace



KJDavie
2014-11-12T01:55:08Z
Hi Nikolaj,

Per Brians comments, for complex Powershell / Scripts, the best approach is to use the Execute Task at this stage.

In my experience you will have to do it this way if you want to use Includes as you have described, Execute as a particular privilege / Credential to run as, or specify the default/home directory to run in.

We (our Site . . . ) have an enhancement request in for some changes / options in how Powershell is used from VisualCron:

Please see this request for my attempt, and anything else it needs from your perspective would be welcome also.
http://www.visualcron.co...sts&t=4054#post18189 

Regards

Kevin
KJDavie attached the following image(s):
Nikolaj Pedersen
2014-11-12T06:53:36Z
Originally Posted by: KJDavie 

Per Brians comments, for complex Powershell / Scripts, the best approach is to use the Execute Task at this stage.


Hi KJDavie,
Thanks for the tip!
But as I wrote in the first post, because the Powershell task part of VC is unusable and unstable, we're using the CMD execute task, like you described.

The thing is, I'm not even trying to use any crazy functionality, includes or anything, I'm just trying to use the Powershell task, which I guess is intended for running Powershell scripts. The path to the test script is C:\temp\testPs2.ps1 and the script consists of 2 lines:
Write-host "Test Host"
Write-Output "Test Output"


The task fails, with the error result that I posted in my last post.
Support
2014-11-12T11:35:34Z
Originally Posted by: Nikolaj Pedersen 

Originally Posted by: KJDavie 

Per Brians comments, for complex Powershell / Scripts, the best approach is to use the Execute Task at this stage.


Hi KJDavie,
Thanks for the tip!
But as I wrote in the first post, because the Powershell task part of VC is unusable and unstable, we're using the CMD execute task, like you described.

The thing is, I'm not even trying to use any crazy functionality, includes or anything, I'm just trying to use the Powershell task, which I guess is intended for running Powershell scripts. The path to the test script is C:\temp\testPs2.ps1 and the script consists of 2 lines:
Write-host "Test Host"
Write-Output "Test Output"


The task fails, with the error result that I posted in my last post.



Write-Host will fail. We are execution through a different .NET powershell host so I guess that is the reason for failing. Use Write-Output instead only. That should work.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Nikolaj Pedersen
2014-11-12T12:21:24Z
Removing 'Write-Host' CMDLET worked - the script result is successful!
I don't wanna make a Whole script failed just because of one command.
Earlier in the post, you told me to use the 'Write-host' CMDLET.

Are you planning to fix that issue?

I'm using the WHOAMI command in a Powershell/cmd script to test user context/run as, I figured out what user is running the Powershell scirpt.
The result is:
batchServce@DOMAIN (local login+load profile - both disabled), the output is nt authority\system
batchServce@DOMAIN (local login+load profile - both enabled), the output is DOMAIN\batchService

Is this working as intended?
Scroll to Top