diff --git a/Scripts/Export-GHEntraFido.ps1 b/Scripts/Export-GHEntraFido.ps1 index 73282ed..fc8c399 100644 --- a/Scripts/Export-GHEntraFido.ps1 +++ b/Scripts/Export-GHEntraFido.ps1 @@ -23,22 +23,21 @@ Function Export-GHEntraFido { [string]$Url ) - if (-not ('HtmlAgilityPack.HtmlDocument' -as [type])) { - $dll = Get-ChildItem -Path $HOME -Recurse -Filter HtmlAgilityPack.dll -ErrorAction SilentlyContinue | - Select-Object -First 1 - - if (-not $dll) { - throw "HtmlAgilityPack.dll not found. Ensure the dependency is installed before running Export-GHEntraFido." + if (-not (Get-Module -Name PSParseHTML)) { + Import-Module PSParseHTML -ErrorAction Stop } - Add-Type -Path $dll.FullName -} + if (-not ('HtmlAgilityPack.HtmlDocument' -as [type])) { + $module = Get-Module PSParseHTML + $dll = Get-ChildItem -Path $module.ModuleBase -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 under PSParseHTML module path. Ensure PSParseHTML 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