Skip to content

Commit 9ba09da

Browse files
committed
Moved error handling
1 parent 7c6a92c commit 9ba09da

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

AutomatedLab.Common/Common/Public/Install-SoftwarePackage.ps1

+11-11
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@ function Install-SoftwarePackage
3232
[string]$WorkingDirectory
3333
)
3434

35-
#if the path cannot be found and starts with \\automatedlabsources...
36-
if ((-not (Test-Path -Path $Path) -and $Path -match '\\\\automatedlabsources[a-z]{5}\.file\.core\.windows\.net'))
37-
{
38-
#we assume, the LabSources share was not mapped correctly and try again by calling 'C:\AL\AzureLabSources.ps1'
39-
$labSourcesConnectOutput = C:\AL\AzureLabSources.ps1
40-
if ($labSourcesConnectOutput.AlternativeLabSourcesPath)
41-
{
42-
$Path = $Path.Replace($labSourcesConnectOutput.LabSourcesPath, $labSourcesConnectOutput.AlternativeLabSourcesPath)
43-
}
44-
}
45-
4635
$pInfo = New-Object -TypeName System.Diagnostics.ProcessStartInfo
4736
$pInfo.FileName = $Path
4837
if (-not [string]::IsNullOrWhiteSpace($WorkingDirectory)) { $pInfo.WorkingDirectory = $WorkingDirectory }
@@ -76,6 +65,17 @@ function Install-SoftwarePackage
7665
}
7766
#endregion New-InstallProcess
7867

68+
#if the path cannot be found and starts with \\automatedlabsources...
69+
if ((-not (Test-Path -Path $Path) -and $Path -match '\\automatedlabsources[a-z]{5}\.file\.core\.windows\.net'))
70+
{
71+
#we assume, the LabSources share was not mapped correctly and try again by calling 'C:\AL\AzureLabSources.ps1'
72+
$labSourcesConnectOutput = C:\AL\AzureLabSources.ps1 2> $null
73+
if ($labSourcesConnectOutput.AlternativeLabSourcesPath)
74+
{
75+
$Path = $Path.Replace($labSourcesConnectOutput.LabSourcesPath, $labSourcesConnectOutput.AlternativeLabSourcesPath)
76+
}
77+
}
78+
7979
if (-not (Test-Path -Path $Path -PathType Leaf))
8080
{
8181
Write-Error "The file '$Path' could not found"

0 commit comments

Comments
 (0)