Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


cedric.wident
2021-01-06T17:23:25Z
Hi,

I have an issue with a powershell task that hangs indefinitely. Here's the code in my Powershell
Sponsor
Forum information
cedric.wident
2021-01-06T17:25:49Z
Sorry, it seems I had an issue when posting. Here is the actual topic:


Hi,

I have an issue with a powershell task that hangs indefinitely. Here's the code in my Powershell Task:

Get-DbaBackupInformation -SqlInstance instance -Path "path" -MaintenanceSolution | Select-Object -Property Type -Unique | Write-Output
Exit


It runs until I kill the task, then I get the output (I'm using it in another task) and the job continues.

Here is the extended debug output:

06/01/2021 18:19:22	Debug	Calling StartTaskProcess() with Task: Select Available Restore Types (77)
06/01/2021 18:19:22	Debug	Task (77) was added to processlist: Select Available Restore Types
06/01/2021 18:19:22	Debug	RaiseTaskStarted->Start
06/01/2021 18:19:22	Debug	RaiseTaskStarted->StatisticsAPI.ThreadStarted
06/01/2021 18:19:22	Debug	RaiseTaskStarted->TaskProcess.Task.ProcessorsAffinity
06/01/2021 18:19:22	Debug	RaiseTaskStarted->Retrieve Job process
06/01/2021 18:19:22	Debug	RaiseTaskStarted->TaskProcess.IsTaskNotification-: False
06/01/2021 18:19:22	Info	Task started(PowerShell): Select Available Restore Types (77)
06/01/2021 18:19:22	Debug	RaiseTaskStarted->Clear stats
06/01/2021 18:19:22	Debug	RaiseTaskStarted->OutputHandlerAPI.Update
06/01/2021 18:19:22	Debug	RaiseTaskStarted->TaskProcessStarted(TaskProcess)
06/01/2021 18:19:22	Comm	SendTaskProcess->Running(77)
06/01/2021 18:19:22	Debug	RaiseTaskStarted->PerformDesktopUnlock
06/01/2021 18:19:22	Debug	RaiseTaskStarted->Exit
06/01/2021 18:19:22	Debug	RunAsType: API
06/01/2021 18:19:22	Debug	Username: Lemon_Adm
06/01/2021 18:19:22	Comm	SendVCProcessName->Running(77)
06/01/2021 18:19:22	Debug	Process status - StatisticsAPI.ProcessStarted (10024)
06/01/2021 18:19:22	Debug	ExecuteHelper started process: 10024
06/01/2021 18:19:22	Debug	Process status - retrieving process id (77)
06/01/2021 18:19:22	Debug	Process status - Writing standard in (77)
06/01/2021 18:19:22	Debug	Process status - Waiting for exit (77)
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->18:19:22: Is 64 bit process: True
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->18:19:22: Is 64 bit operating system: True
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->18:19:22: Current user: GROUPE\Lemon_Adm
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->18:19:22: .NET version: 4.0.30319.42000
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Built date: 20/11/2020 09:13:24
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->18:19:22: AddExceptionHandlers
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->18:19:22: Argument(0): 77
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->18:19:22: pts.CreateService(77)
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before CreateService
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->CreateService->Response channel created on address: /TaskProcess/77
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->After CreateService
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->18:19:22: pts.CreateService(77)->Complete
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before Requesting Task information log
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Requesting Task information
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->After Requesting Task information log
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before Requesting Task information call
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->After Requesting Task information call
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Task information sent
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Task information received
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before PowerShell execution
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->18:19:22: Current user: GROUPE\Lemon_Adm
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before runspace.ThreadOptions
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before runspace.Open
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Success opening Runspace(1): Opened
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before runspace.CreatePipeline
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Added script text
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Adding 'Out-String' command with 'Stream' parameter
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->AddHandler->OutputDataReceived
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->AddHandler->ErrorDataReceived
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->AddHandler->InvocationStateChanged
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->ps.Invoke
06/01/2021 18:19:22	Debug	ProcessLog (77): 18:19:22: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->InvocationStateChanged: Running
06/01/2021 18:19:24	Debug	ProcessTotalProcessorTime: 7,26 jobs percent:80,89
06/01/2021 18:19:27	Debug	ProcessTotalProcessorTime: 0,00 jobs percent:245,78
06/01/2021 18:19:29	Debug	06:19:29.529 Process standard output: Database Differential
06/01/2021 18:19:29	Debug	06:19:29.529 Process standard output: Database
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->InvocationStateChanged: Completed
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->outputCollection.Count: 2
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->obj: Database Differential
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->obj: Database
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->ps.InvocationStateInfo.State: Completed
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->RemoveHandler->OutputDataReceived
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->RemovedHandler->ErrorDataReceived
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->RemovedHandler->InvocationStateChanged
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Disposing ps
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Nulling ps
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before runspace.Close
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before impersonation.Undo
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Before exiting
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Preparing Task log
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Sending result - success: True
06/01/2021 18:19:29	Debug	ProcessTaskResult->Task result received, VCTaskPId: 77
06/01/2021 18:19:29	Debug	Received Task result for Task name: Select Available Restore Types
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Result sent
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Exception handlers removed
06/01/2021 18:19:29	Debug	ProcessLog (77): 18:19:29: ExecuteProcess("C:\Program Files (x86)\VisualCron\PowerShell\TaskPowerShell.exe" 77)->Handlers removed
06/01/2021 18:19:30	Debug	ProcessTotalProcessorTime: 0,52 jobs percent:189,78
06/01/2021 18:19:33	Debug	ProcessTotalProcessorTime: 0,00 jobs percent:27,48
06/01/2021 18:19:34	Info	User 'Lemon_Adm ' - Tries to kill/stop all processes from specified Task (Select Available Restore Types)
06/01/2021 18:19:34	Info	Task process was aborted by user.
06/01/2021 18:19:36	Err	TaskService Exception -> System.ServiceModel.CommunicationException: Une erreur s'est produite lors de la lecture du canal : Le canal de communication a été fermé. (109, 0x6d). ---> System.IO.PipeException: Une erreur s'est produite lors de la lecture du canal : Le canal de communication a été fermé. (109, 0x6d).
   à System.ServiceModel.Channels.PipeConnection.OnAsyncReadComplete(Boolean haveResult, Int32 error, Int32 numBytes)
   --- Fin de la trace de la pile d'exception interne ---
   à System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   à System.ServiceModel.Channels.TransportDuplexSessionChannel.EndTryReceive(IAsyncResult result, Message& message)
   à System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
   à System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
06/01/2021 18:19:36	Debug	Process status - has left WaitForExit (77)
06/01/2021 18:19:36	Debug	Process status - StatisticsAPI.ProcessFinished (10024)
06/01/2021 18:19:36	Debug	Process status - OutPut captured (77)
06/01/2021 18:19:36	Debug	Process status - trying to retrieve exit code (77)
06/01/2021 18:19:36	Debug	Process status - ExitCode fetched (77)
06/01/2021 18:19:36	Debug	hUserToken was Zero
06/01/2021 18:19:36	Debug	Process status - ProcessHandles closed (77)
06/01/2021 18:19:36	Debug	Process status - StdStreams close (77)
06/01/2021 18:19:36	Debug	ProcessTotalProcessorTime: 1,55 jobs percent:8,29
06/01/2021 18:19:36	Debug	Closing desktop handles (77)
06/01/2021 18:19:36	Debug	StartExecuteHelperProcess->TaskProcess.Task.Stats.ExitCode: 0
06/01/2021 18:19:36	Info	Task completed (PowerShell) (Success)->'Select Available Restore Types' (77)
06/01/2021 18:19:36	Comm	SendTaskProcess->Terminated(77)
06/01/2021 18:19:36	Debug	RemoveTaskProcess->Task (77) was removed from processlist: Select Available Restore Types


I've tried running it from a script but I get the same result.

Also, the command runs fine in Powershell ISE with the same user.

Do you have any suggestion ? I'm running VC 9.4.5.
Support
2021-01-06T17:32:28Z
1. can you send the full script to support@visualcron.com
2. if you restart the VisualCron service and test again do you get the same issue?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top