Skip to content

Commit c0bfef9

Browse files
committed
Synchronise all example templates with that of our default one.
1 parent 0536e25 commit c0bfef9

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

examples/Multi-session Installation/Invoke-AppDeployToolkit.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ try
184184
if (Test-Path -LiteralPath "$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1" -PathType Leaf)
185185
{
186186
Get-ChildItem -LiteralPath "$PSScriptRoot\PSAppDeployToolkit" -Recurse -File | Unblock-File -ErrorAction Ignore
187-
Import-Module -FullyQualifiedName @{ ModuleName = "$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1"; Guid = '8c3c366b-8606-4576-9f2d-4051144f7ca2'; ModuleVersion = '4.2.0' } -Force
187+
Import-Module -FullyQualifiedName @{ ModuleName = [System.Management.Automation.WildcardPattern]::Escape("$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1"); Guid = '8c3c366b-8606-4576-9f2d-4051144f7ca2'; ModuleVersion = '4.2.0' } -Force
188188
}
189189
else
190190
{
@@ -217,7 +217,7 @@ try
217217
if ($_.Name -match 'PSAppDeployToolkit\..+$')
218218
{
219219
Get-ChildItem -LiteralPath $_.FullName -Recurse -File | Unblock-File -ErrorAction Ignore
220-
Import-Module -Name $_.FullName -Force
220+
Import-Module -Name ([System.Management.Automation.WildcardPattern]::Escape("$($_.FullName)\$($_.BaseName).psd1")) -Force
221221
}
222222
}
223223
}
@@ -230,7 +230,7 @@ catch
230230
{
231231
# An unhandled error has been caught.
232232
$mainErrorMessage = "An unhandled error within [$($MyInvocation.MyCommand.Name)] has occurred.`n$(Resolve-ADTErrorRecord -ErrorRecord $_)"
233-
Write-ADTLogEntry -Message $mainErrorMessage -Severity 3
233+
Write-ADTLogEntry -Message $mainErrorMessage -Severity Error
234234
Show-ADTDialogBox -Text $mainErrorMessage -Icon Stop -NoWait
235235
Close-ADTSession -ExitCode 60001
236236
}

examples/VLC/Invoke-AppDeployToolkit.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ $adtSession = @{
112112
DeployAppScriptVersion = '4.2.0'
113113
}
114114

115+
116+
##================================================
117+
## MARK: Deployment type definitions
118+
##================================================
119+
115120
function Install-ADTDeployment
116121
{
117122
[CmdletBinding()]
@@ -307,7 +312,7 @@ try
307312
if (Test-Path -LiteralPath "$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1" -PathType Leaf)
308313
{
309314
Get-ChildItem -LiteralPath "$PSScriptRoot\PSAppDeployToolkit" -Recurse -File | Unblock-File -ErrorAction Ignore
310-
Import-Module -FullyQualifiedName @{ ModuleName = "$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1"; Guid = '8c3c366b-8606-4576-9f2d-4051144f7ca2'; ModuleVersion = '4.2.0' } -Force
315+
Import-Module -FullyQualifiedName @{ ModuleName = [System.Management.Automation.WildcardPattern]::Escape("$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1"); Guid = '8c3c366b-8606-4576-9f2d-4051144f7ca2'; ModuleVersion = '4.2.0' } -Force
311316
}
312317
else
313318
{
@@ -340,7 +345,7 @@ try
340345
if ($_.Name -match 'PSAppDeployToolkit\..+$')
341346
{
342347
Get-ChildItem -LiteralPath $_.FullName -Recurse -File | Unblock-File -ErrorAction Ignore
343-
Import-Module -Name $_.FullName -Force
348+
Import-Module -Name ([System.Management.Automation.WildcardPattern]::Escape("$($_.FullName)\$($_.BaseName).psd1")) -Force
344349
}
345350
}
346351
}
@@ -353,12 +358,13 @@ catch
353358
{
354359
# An unhandled error has been caught.
355360
$mainErrorMessage = "An unhandled error within [$($MyInvocation.MyCommand.Name)] has occurred.`n$(Resolve-ADTErrorRecord -ErrorRecord $_)"
356-
Write-ADTLogEntry -Message $mainErrorMessage -Severity 3
361+
Write-ADTLogEntry -Message $mainErrorMessage -Severity Error
357362

358363
## Error details hidden from the user by default. Show a simple dialog with full stack trace:
359364
# Show-ADTDialogBox -Text $mainErrorMessage -Icon Stop -NoWait
360365

361366
## Or, a themed dialog with basic error message:
362-
Show-ADTInstallationPrompt -Message "$($adtSession.DeploymentType) failed at line $($_.InvocationInfo.ScriptLineNumber), char $($_.InvocationInfo.OffsetInLine):`n$($_.InvocationInfo.Line.Trim())`n`nMessage:`n$($_.Exception.Message)" -MessageAlignment Left -ButtonRightText OK -Icon Error -NoWait
367+
Show-ADTInstallationPrompt -Message "$($adtSession.DeploymentType) failed at line $($_.InvocationInfo.ScriptLineNumber), char $($_.InvocationInfo.OffsetInLine):`n$($_.InvocationInfo.Line.Trim())`n`nMessage:`n$($_.Exception.Message)" -ButtonRightText OK -Icon Error -NoWait
368+
363369
Close-ADTSession -ExitCode 60001
364370
}

examples/WinSCP/Invoke-AppDeployToolkit.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ $adtSession = @{
112112
DeployAppScriptVersion = '4.2.0'
113113
}
114114

115+
116+
##================================================
117+
## MARK: Deployment type definitions
118+
##================================================
119+
115120
function Install-ADTDeployment
116121
{
117122
[CmdletBinding()]
@@ -316,7 +321,7 @@ try
316321
if (Test-Path -LiteralPath "$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1" -PathType Leaf)
317322
{
318323
Get-ChildItem -LiteralPath "$PSScriptRoot\PSAppDeployToolkit" -Recurse -File | Unblock-File -ErrorAction Ignore
319-
Import-Module -FullyQualifiedName @{ ModuleName = "$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1"; Guid = '8c3c366b-8606-4576-9f2d-4051144f7ca2'; ModuleVersion = '4.2.0' } -Force
324+
Import-Module -FullyQualifiedName @{ ModuleName = [System.Management.Automation.WildcardPattern]::Escape("$PSScriptRoot\PSAppDeployToolkit\PSAppDeployToolkit.psd1"); Guid = '8c3c366b-8606-4576-9f2d-4051144f7ca2'; ModuleVersion = '4.2.0' } -Force
320325
}
321326
else
322327
{
@@ -349,7 +354,7 @@ try
349354
if ($_.Name -match 'PSAppDeployToolkit\..+$')
350355
{
351356
Get-ChildItem -LiteralPath $_.FullName -Recurse -File | Unblock-File -ErrorAction Ignore
352-
Import-Module -Name $_.FullName -Force
357+
Import-Module -Name ([System.Management.Automation.WildcardPattern]::Escape("$($_.FullName)\$($_.BaseName).psd1")) -Force
353358
}
354359
}
355360
}
@@ -362,12 +367,13 @@ catch
362367
{
363368
# An unhandled error has been caught.
364369
$mainErrorMessage = "An unhandled error within [$($MyInvocation.MyCommand.Name)] has occurred.`n$(Resolve-ADTErrorRecord -ErrorRecord $_)"
365-
Write-ADTLogEntry -Message $mainErrorMessage -Severity 3
370+
Write-ADTLogEntry -Message $mainErrorMessage -Severity Error
366371

367372
## Error details hidden from the user by default. Show a simple dialog with full stack trace:
368373
# Show-ADTDialogBox -Text $mainErrorMessage -Icon Stop -NoWait
369374

370375
## Or, a themed dialog with basic error message:
371-
Show-ADTInstallationPrompt -Message "$($adtSession.DeploymentType) failed at line $($_.InvocationInfo.ScriptLineNumber), char $($_.InvocationInfo.OffsetInLine):`n$($_.InvocationInfo.Line.Trim())`n`nMessage:`n$($_.Exception.Message)" -MessageAlignment Left -ButtonRightText OK -Icon Error -NoWait
376+
Show-ADTInstallationPrompt -Message "$($adtSession.DeploymentType) failed at line $($_.InvocationInfo.ScriptLineNumber), char $($_.InvocationInfo.OffsetInLine):`n$($_.InvocationInfo.Line.Trim())`n`nMessage:`n$($_.Exception.Message)" -ButtonRightText OK -Icon Error -NoWait
377+
372378
Close-ADTSession -ExitCode 60001
373379
}

0 commit comments

Comments
 (0)