-
-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathConvert_web_request_response_to_a_string.ps1
More file actions
45 lines (41 loc) · 1.22 KB
/
Convert_web_request_response_to_a_string.ps1
File metadata and controls
45 lines (41 loc) · 1.22 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
# https://gist.github.com/mklement0/209a9506b8ba32246f95d1cc238d564d
function ConvertTo-BodyWithEncoding
{
[CmdletBinding(PositionalBinding = $false)]
param
(
[Parameter(Mandatory, ValueFromPipeline)]
[Microsoft.PowerShell.Commands.WebResponseObject]
$InputObject,
# The encoding to use; defaults to UTF-8
[Parameter(Position = 0)]
$Encoding = [System.Text.Encoding]::UTF8
)
begin
{
if ($Encoding -isnot [System.Text.Encoding])
{
try
{
$Encoding = [System.Text.Encoding]::GetEncoding($Encoding)
}
catch
{
throw
}
}
}
process
{
$Encoding.GetString($InputObject.RawContentStream.ToArray())
}
}
# We cannot invoke an expression with non-latin words to avoid "??????"
# New-ItemProperty -LiteralPath Registry::HKEY_CLASSES_ROOT\*\shell\Paint.NET -Name "(Default)" -PropertyType String -Value "Открыть с помощью Paint.NET" -Force
# https://github.com/farag2/Utilities/blob/master/Apps/Paint.NET_context_menu.ps1
$Parameters = @{
Uri = "https://raw.githubusercontent.com/farag2/Utilities/refs/heads/master/Apps/Paint.NET_context_menu.ps1"
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters | ConvertTo-BodyWithEncoding | Invoke-Expression