-
Notifications
You must be signed in to change notification settings - Fork 0
/
getFSCDataTest.psm1
32 lines (27 loc) · 1015 Bytes
/
getFSCDataTest.psm1
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
function Get-fscInfo {
param (
[Parameter(Mandatory = $true)]
[string]$fsc
)
$url = "https://nationalstocknumber.info/nsn-and-fsc-catalog/fsc/$fsc"
Write-Host $url
$response = Invoke-WebRequest -Uri $url
# Check if the request was successful
if ($response.StatusCode -eq 200) {
$htmlContent = $response.Content
# Use regex to extract fsc name and description
$fscName = [regex]::Match($htmlContent, '<h1 class="font16em nomargin-bottom">NSN (.*?) Catalog</h1>').Groups[1].Value
$fscDescription = [regex]::Match($htmlContent, '<p>(FSC \d+ Includes .*?)</p>').Groups[1].Value
# Return a hashtable with the fsc name and description
Write-Host $fscName
return @{
Name = $fscName
Description = $fscDescription
}
}
else {
Write-Host "Failed to fetch the webpage. Status code: $($response.StatusCode)"
}
}
# Export the function
Export-ModuleMember -Function Get-fscInfo