mirror of
https://github.com/pbatard/Fido.git
synced 2025-09-16 14:18:02 +02:00
Fix script failure with PowerShell 7.x
* Won't help though, since Microsoft forcibly removed the ability to parse HTML in newer PowerShell, which we need... * Also fix session variable not being set. * Closes #19
This commit is contained in:
14
Fido.ps1
14
Fido.ps1
@@ -63,7 +63,11 @@ $code = @"
|
|||||||
}
|
}
|
||||||
"@
|
"@
|
||||||
|
|
||||||
Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace "System.IO", "System.Text", "System.Drawing", "System.Globalization" -ReferencedAssemblies System.Drawing -Name Utils -ErrorAction Stop
|
if ($host.version -ge "7.0") {
|
||||||
|
Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace System.Runtime, System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing.Common -Name Utils -ErrorAction Stop
|
||||||
|
} else {
|
||||||
|
Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing -Name Utils -ErrorAction Stop
|
||||||
|
}
|
||||||
Add-Type -AssemblyName PresentationFramework
|
Add-Type -AssemblyName PresentationFramework
|
||||||
# Hide the powershell window: https://stackoverflow.com/a/27992426/1069307
|
# Hide the powershell window: https://stackoverflow.com/a/27992426/1069307
|
||||||
[Gui.Utils]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) | Out-Null
|
[Gui.Utils]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) | Out-Null
|
||||||
@@ -582,10 +586,14 @@ $Continue.add_click({
|
|||||||
$i = 0
|
$i = 0
|
||||||
$SelectedIndex = 0
|
$SelectedIndex = 0
|
||||||
try {
|
try {
|
||||||
$r = Invoke-WebRequest -UserAgent $UserAgent -WebSession $Session $url
|
$r = Invoke-WebRequest -UserAgent $UserAgent -SessionVariable "Session" $url
|
||||||
# Go through an XML conversion to keep all PowerShells happy...
|
# Go through an XML conversion to keep all PowerShells happy...
|
||||||
if (-not $($r.AllElements | ? {$_.id -eq "product-languages"})) {
|
if (-not $($r.AllElements | ? {$_.id -eq "product-languages"})) {
|
||||||
throw "Unexpected server response"
|
if ($host.version -ge "7.0") {
|
||||||
|
throw "This PowerShell version can not parse HTML"
|
||||||
|
} else {
|
||||||
|
throw "Unexpected server response"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$html = $($r.AllElements | ? {$_.id -eq "product-languages"}).InnerHTML
|
$html = $($r.AllElements | ? {$_.id -eq "product-languages"}).InnerHTML
|
||||||
$html = $html.Replace("selected value", "value")
|
$html = $html.Replace("selected value", "value")
|
||||||
|
Reference in New Issue
Block a user