I have a local file ($URLsFile), which contains a list of URLs:
http://WIND451325/Dev/Application.aspx__%__dev.com
http://WIND451326/Dev/Application.aspx__%__dev.com
When using the [uri] Types Accelerator with the Get-Content command:
[uri[]]$ArrayURLs = Get-Content -Path $URLsFile
I've noticed some changes in the value of the AbsoluteUri property, as __%__
changed to __%25__
:
foreach ($item in $ArrayURLs)
{
$item.AbsoluteUri
}
http://WIND451325/Dev/Application.aspx__%25__dev.com
http://WIND451326/Dev/Application.aspx__%25__dev.com
After going through the official documentation:
https://learn.microsoft.com/en-us/dotnet/api/system.uri?view=net-7.0
I could not find any reference to the subject.
You can use the overload with dontEscape
set to $true
.
$ArrayURLs = Get-Content -Path $URLsFile |
ForEach-Object { [uri]::new($_, $true) }
This ctor is obsolete, in newer versions of PowerShell 7+, you should use the UriCreationOptions
overload instead.
$options = [System.UriCreationOptions]@{
DangerousDisablePathAndQueryCanonicalization = $true
}
$ArrayURLs = Get-Content -Path $URLsFile |
ForEach-Object { [uri]::new($_, [ref] $options) }