Closed DCurtin closed 4 years ago
hey @DCurtin - Thanks for opening this up! I think to catch all scenarios, I can wrap the call to [System.Console]::CursorVisible
in a try/catch block with the catch just being empty (and possibly removing that error from the $global:Error
array as well)
It seems to catch as expected here:
Start-Job {
try {
[System.Console]::CursorVisible = $true
}
catch {
"Couldn't be set"
}
} | Wait-Job | Receive-Job
Thoughts?
Also worth noting that Start-GSDriveFileUpload
will kick off background jobs by default if you don't include the -Wait
parameter, IIRC.
hey @DCurtin - Fix added and deployed in PSGSuite v2.33.2, you should no longer see that pesky error! Let me know if all is well =]
awesome, I noticed that about it kicking off background jobs. I likely don't need to wrap it in a job but wanted a way to manage sets in a more custom way.
Really appreciate this project.
All's well, thank you for the update.
Yup! It starts them as async requests in background threads. You can check on the status at any time with Get-GSDriveFileUploadStatus
as well, in case you want visibility at the forefront. Using a PS Job may obscure that a bit since you don't really have the ability to invoke a new command in the existing Job afaik, so you're leaving it up to chance at that point IMO. With a shaky internet connection, it may be a bit risky, even with the built-in failure retry mechanism
Describe the bug Exception thrown Exception setting "CursorVisible": "The handle is invalid. when running Start-GSDriveFileUpload in a ps job To Reproduce Steps to reproduce the behavior: $newJob = Start-Job -ScriptBlock {Start-GSDriveFileUpload -Path $args[0] -Parents @('some-parent-id') -Verbose} -ArgumentList @('filepath');
Expected behavior CursorVisble exception to not be thrown? The file seems to upload successfully regardless. So it's not terribly important, just annoying
Environment (please complete the following information):
Additional context When running get-host on a job this is returned
Name : ServerRemoteHost Version : 1.0.0.0 InstanceId : 0c466ab7-b486-42fc-af7e-2dc2a99a2617 UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : en-US CurrentUICulture : en-US PrivateData : DebuggerEnabled : True IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace
On line 328 and 221 of https://github.com/scrthq/PSGSuite/blob/master/PSGSuite/Public/Drive/Start-GSDriveFileUpload.ps1
It's setting [System.Console]::CursorVisible = $true when $host.name Is not PS ISE maybe ServerRemoteHost needs to be added to the filter?