Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions Scripts/Export-GHEntraFido.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,30 @@ Function Export-GHEntraFido {
[string]$Url
)

if (-not (Get-Module -Name PSParseHTML)) {
Import-Module PSParseHTML -ErrorAction Stop
}

if (-not ('HtmlAgilityPack.HtmlDocument' -as [type])) {
$dll = Get-ChildItem -Path $HOME -Recurse -Filter HtmlAgilityPack.dll -ErrorAction SilentlyContinue |
Select-Object -First 1
$module = Get-Module PSParseHTML
$dll = $null

if (-not $dll) {
throw "HtmlAgilityPack.dll not found. Ensure the dependency is installed before running Export-GHEntraFido."
}
if ($module -and $module.ModuleBase) {
$dll = Get-ChildItem -Path $module.ModuleBase -Recurse -Filter HtmlAgilityPack.dll -ErrorAction SilentlyContinue |
Select-Object -First 1
}

Add-Type -Path $dll.FullName
}
if (-not $dll) {
$dll = Get-ChildItem -Path $HOME -Recurse -Filter HtmlAgilityPack.dll -ErrorAction SilentlyContinue |
Select-Object -First 1
}

$response = Invoke-WebRequest -Uri $Url -UseBasicParsing
$htmlContent = $response.Content
if (-not $dll) {
throw "HtmlAgilityPack.dll not found. Ensure the dependency is installed before running Export-GHEntraFido."
}

$htmlDocument = New-Object HtmlAgilityPack.HtmlDocument
$htmlDocument.LoadHtml($htmlContent)
Add-Type -Path $dll.FullName
}

# Fetch the webpage content
$response = Invoke-WebRequest -Uri $Url -UseBasicParsing
Expand Down
Loading