-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThings_To_Consider_1_Character_Escaping.ps1
64 lines (57 loc) · 2.33 KB
/
Things_To_Consider_1_Character_Escaping.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#No escaping
#Lines 4, 9
$String = '
Write-Verbose "$(Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable)"
Write-Verbose "$($Arguments.Trim() -join ' ')"
#Invoke the legacy app
if ($SeparateWindow) {
Write-Verbose "SeparateWindow was invoked, using Start-Process Invocation method"
Start-Process -FilePath (Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable) -ArgumentList ($Arguments -join ' ')
} else {
Write-Verbose "Using legacy console invocation method"
& "$(Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable)" $Arguments
}
'
$String
#Basic string escaping
$String = '
Write-Verbose "$(Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable)"
Write-Verbose "$($Arguments.Trim() -join '' '')"
#Invoke the legacy app
if ($SeparateWindow) {
Write-Verbose "SeparateWindow was invoked, using Start-Process Invocation method"
Start-Process -FilePath (Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable) -ArgumentList ($Arguments -join '' '')
} else {
Write-Verbose "Using legacy console invocation method"
& "$(Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable)" $Arguments
}
'
$String
#Character escaping Here String
$String = @'
Write-Verbose "$(Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable)"
Write-Verbose "$($Arguments.Trim() -join ' ')"
#Invoke the legacy app
if ($SeparateWindow) {
Write-Verbose "SeparateWindow was invoked, using Start-Process Invocation method"
Start-Process -FilePath (Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable) -ArgumentList ($Arguments -join ' ')
} else {
Write-Verbose "Using legacy console invocation method"
& "$(Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable)" $Arguments
}
'@
$String
#Character Escaping Script Blocks
$String = {
Write-Verbose "$(Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable)"
Write-Verbose "$($Arguments.Trim() -join ' ')"
#Invoke the legacy app
if ($SeparateWindow) {
Write-Verbose "SeparateWindow was invoked, using Start-Process Invocation method"
Start-Process -FilePath (Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable) -ArgumentList ($Arguments -join ' ')
} else {
Write-Verbose "Using legacy console invocation method"
& "$(Join-Path -Path $BinaryPath -ChildPath $BinaryExecutable)" $Arguments
}
}.ToString()
$String