AutomatedLab icon indicating copy to clipboard operation
AutomatedLab copied to clipboard

[Bug]: Download of SysInternals suite sometimes fails

Open richardweber85 opened this issue 1 year ago • 1 comments

Description

Master.zip containing SysInternals suite could not be downloaded. Folder 'C:\Users\jenkins\AppData\Local\Temp\tmp3BB0' exists, but is empty.

In my case, the following error occurres sometimes:

Performing update of SysInternals suite and lab sources directory now
powershell.exe : Microsoft.PowerShell.Archive\Expand-Archive : The path 'C:\Users\jenkins\AppData\Local\Temp\tmp3BB0\master.zip' either 
At D:\.jenkins\workspace\MyPipeline@tmp\durable-4969c78b\powershellWrapper.ps1:3 char:1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Microsoft.Power...er.zip' either :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
does not exist or is not a valid file system path.
At C:\Program Files\WindowsPowerShell\Modules\AutomatedLab\5.36.0\AutomatedLab.psm1:3563 char:9
+         Microsoft.PowerShell.Archive\Expand-Archive -Path $archivePat ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (C:\Users\jenkin...3BB0\master.zip:String) [Expand-Archive], InvalidOpe 
   rationException
    + FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Expand-Archive

Steps to reproduce the issue

New-LabDefinition -Name 'Test' -DefaultVirtualizationEngine HyperV -VmPath 'D:\AutomatedLab-VMs' -ErrorAction Stop



Proposed solution: A check whether SysInternals suite was successfully downloaded is missing.

In C:\Program Files\WindowsPowerShell\Modules\AutomatedLab\5.36.0\AutomatedLabInternals.psm1:

                try
                {
                    Invoke-WebRequest -Uri $sysInternalsDownloadURL -UseBasicParsing -OutFile $tempFilePath
                    # TODO: add a check whether file $tempFilePath exists here
                    $fileDownloaded = $true
                    Write-PSFMessage -Message "File '$sysInternalsDownloadURL' downloaded"
                }
                catch
                {
                    Write-ScreenInfo -Message "File '$sysInternalsDownloadURL' could not be downloaded. Skipping." -Type Error -TaskEnd
                    $fileDownloaded = $false
                }

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.17763.4974
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.4974
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

AutomatedLab Version

Name                      Version
----                      -------
AutomatedLab              5.36.0
AutomatedLab              5.32.0
AutomatedLab.Common       2.0.216
AutomatedLab.Common       2.0.208
AutomatedLab.Recipe       5.36.0
AutomatedLab.Recipe       5.32.0
AutomatedLab.Ships        5.36.0
AutomatedLab.Ships        5.32.0
AutomatedLabDefinition    5.36.0
AutomatedLabDefinition    5.32.0
AutomatedLabNotifications 5.36.0
AutomatedLabNotifications 5.32.0
AutomatedLabTest          5.36.0
AutomatedLabTest          5.32.0
AutomatedLabUnattended    5.36.0
AutomatedLabUnattended    5.32.0
AutomatedLabWorker        5.36.0
AutomatedLabWorker        5.32.0

richardweber85 avatar Jan 16 '24 14:01 richardweber85

Good catch (no pun intended). You could also do a Test-Path for the downloaded ZIP file before expanding it.

SamErde avatar Jan 16 '24 15:01 SamErde