@@ -29,7 +29,18 @@ param(
29
29
[switch ]$Force
30
30
)
31
31
32
+ try {
33
+ $null = Get-Variable ' foobar' - Scope 1 - ErrorAction Stop
34
+ }
35
+ catch [System.ArgumentOutOfRangeException ] {
36
+ throw ' Dot-sourcing this script is not allowed.'
37
+ }
38
+ catch {}
39
+
32
40
Set-StrictMode - Version 3.0
41
+ if (-not $PSBoundParameters.ContainsKey (' ErrorAction' )) {
42
+ $ErrorActionPreference = ' Stop'
43
+ }
33
44
34
45
# Get content from source files
35
46
function Get-SourceContent {
@@ -59,16 +70,18 @@ function Get-SourceContent {
59
70
[Alias (' gprh' )]
60
71
[OutputType ([psobject ])]
61
72
param ()
62
- $Aliases = @ (' %ALIASES%' )
63
- $Functions = @ (' %FUNCTIONS%' )
64
- $Aliases | Get-Command - ListImported | Select-Object @ {n = ' Command' ; e = ' DisplayName' }, @ {n = ' Parameters' ; e = ' '''' ' }
65
- $Functions | Get-Command - ListImported | Select-Object @ {n = ' Command' ; e = ' Name' }, @ {n = ' Parameters' ; e = { $_.ParameterSets -join [System.Environment ]::NewLine } }
73
+ @ (' %ALIASES%' ) |
74
+ Get-Command - ListImported |
75
+ Select-Object @ {n = ' Command' ; e = ' DisplayName' }, @ {n = ' Parameters' ; e = ' '''' ' }
76
+ @ (' %FUNCTIONS%' ) |
77
+ Get-Command - ListImported |
78
+ Select-Object @ {n = ' Command' ; e = ' Name' }, @ {n = ' Parameters' ; e = { $_.ParameterSets -join [System.Environment ]::NewLine } }
66
79
}
67
80
}.ToString()
68
81
69
82
[object []]$contentAllHosts = Get-SourceContent - Path " $PSScriptRoot /Common"
70
83
71
- if (Test-Path ' env:VBOX_MSI_INSTALL_PATH' - PathType Container ) {
84
+ if (Test-Path ' env:VBOX_MSI_INSTALL_PATH' ) {
72
85
$contentAllHosts += Get-SourceContent - Path " $PSScriptRoot /VirtualBoxHost"
73
86
}
74
87
0 commit comments