Browse Source

Fixed HEIF function

pull/411/head
Dmitry Nefedov 2 years ago
parent
commit
ce611114c7
  1. 163
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 3
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  3. 3
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  4. 163
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  5. 163
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 163
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

163
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -10740,21 +10740,44 @@ function HEIF
$Manually $Manually
) )
# Check whether the extension is already installed
if (-not (Get-AppxPackage -Name Microsoft.Windows.Photos))
{
return
}
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
switch ($PSCmdlet.ParameterSetName) switch ($PSCmdlet.ParameterSetName)
{ {
"Install" "Install"
{ {
# Check whether the extension is already installed
if (-not ((Get-AppxPackage -Name Microsoft.HEVCVideoExtension) -and (Get-AppxPackage -Name Microsoft.Windows.Photos)))
{
return
}
try try
{ {
# Check the internet connection # Check whether https://store.rg-adguard.net is alive
$Parameters = @{ $Parameters = @{
Uri = "https://www.google.com" Uri = "https://store.rg-adguard.net/api/GetFiles"
Method = "Head" Method = "Head"
DisableKeepAlive = $true DisableKeepAlive = $true
UseBasicParsing = $true UseBasicParsing = $true
@ -10764,103 +10787,58 @@ function HEIF
return return
} }
try $Body = @{
{ type = "url"
# Check whether https://store.rg-adguard.net is alive url = "https://www.microsoft.com/store/productId/9n4wgh0z6vhq"
$Parameters = @{ ring = "Retail"
Uri = "https://store.rg-adguard.net/api/GetFiles" lang = "en-US"
Method = "Head" }
DisableKeepAlive = $true $Parameters = @{
UseBasicParsing = $true Uri = "https://store.rg-adguard.net/api/GetFiles"
} Method = "Post"
if (-not (Invoke-WebRequest @Parameters).StatusDescription) ContentType = "application/x-www-form-urlencoded"
Body = $Body
UseBasicParsing = $true
Verbose = $true
}
$Raw = Invoke-WebRequest @Parameters
# Parsing the page
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*x64*.appx*"} | ForEach-Object -Process {
$TempURL = ($_.Groups | Select-Object -Index 1).Value
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version)
{ {
return Write-Verbose -Message $Localization.Patient -Verbose
} Write-Verbose -Message $Localization.HEVCDownloading -Verbose
$Body = @{
type = "url"
url = "https://www.microsoft.com/store/productId/9n4wgh0z6vhq"
ring = "Retail"
lang = "en-US"
}
$Parameters = @{
Uri = "https://store.rg-adguard.net/api/GetFiles"
Method = "Post"
ContentType = "application/x-www-form-urlencoded"
Body = $Body
Verbose = $true
}
$Raw = Invoke-WebRequest @Parameters
# Parsing the page
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*x64*.appx*"} | ForEach-Object -Process {
$TempURL = ($_.Groups | Select-Object -Index 1).Value
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version)
{
Write-Verbose -Message $Localization.Patient -Verbose
Write-Verbose -Message $Localization.HEVCDownloading -Verbose
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = $TempURL
OutFile = "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx"
Verbose = $true
}
Invoke-WebRequest @Parameters
Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force $Parameters = @{
Uri = $TempURL
OutFile = "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx"
UseBasicParsing = $true
Verbose = $true
} }
} Invoke-WebRequest @Parameters
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force
}
} }
} }
catch [System.Net.WebException] catch [System.Net.WebException]
{ {
Write-Warning -Message $Localization.NoInternetConnection Write-Warning -Message ($Localization.NoResponse -f "https://store.rg-adguard.net/api/GetFiles")
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.NoResponse -f "https://store.rg-adguard.net/api/GetFiles") -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
} }
} }
"Manually" "Manually"
{ {
if ((-not (Get-AppxPackage -Name Microsoft.HEVCVideoExtension)) -and (Get-AppxPackage -Name Microsoft.Windows.Photos)) Start-Process -FilePath ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
{
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
Start-Process -FilePath ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
}
}
} }
} }
} }
@ -13589,7 +13567,7 @@ function UseStoreOpenWith
#region Update Policies #region Update Policies
<# <#
.SYNOPSIS .SYNOPSIS
Update Local Group Policy Editor (gpedit.msc) to make all manually created policy keys in the registry visible in the snap-in Display all policy registry keys (even manually created ones) in the Local Group Policy Editor snap-in (gpedit.msc)
.EXAMPLE .EXAMPLE
UpdateLGPEPolicies UpdateLGPEPolicies
@ -13599,6 +13577,7 @@ function UseStoreOpenWith
.NOTES .NOTES
Machine-wide user Machine-wide user
Current user
#> #>
function UpdateLGPEPolicies function UpdateLGPEPolicies
{ {

3
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -9977,7 +9977,7 @@ function MultipleInvokeContext
#region Update Policies #region Update Policies
<# <#
.SYNOPSIS .SYNOPSIS
Update Local Group Policy Editor (gpedit.msc) to make all manually created policy keys in the registry visible in the snap-in Display all policy registry keys (even manually created ones) in the Local Group Policy Editor snap-in (gpedit.msc)
.EXAMPLE .EXAMPLE
UpdateLGPEPolicies UpdateLGPEPolicies
@ -9987,6 +9987,7 @@ function MultipleInvokeContext
.NOTES .NOTES
Machine-wide user Machine-wide user
Current user
#> #>
function UpdateLGPEPolicies function UpdateLGPEPolicies
{ {

3
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -11198,7 +11198,7 @@ function MultipleInvokeContext
#region Update Policies #region Update Policies
<# <#
.SYNOPSIS .SYNOPSIS
Update Local Group Policy Editor (gpedit.msc) to make all manually created policy keys in the registry visible in the snap-in Display all policy registry keys (even manually created ones) in the Local Group Policy Editor snap-in (gpedit.msc)
.EXAMPLE .EXAMPLE
UpdateLGPEPolicies UpdateLGPEPolicies
@ -11208,6 +11208,7 @@ function MultipleInvokeContext
.NOTES .NOTES
Machine-wide user Machine-wide user
Current user
#> #>
function UpdateLGPEPolicies function UpdateLGPEPolicies
{ {

163
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -10778,21 +10778,44 @@ function HEIF
$Manually $Manually
) )
# Check whether the extension is already installed
if (-not (Get-AppxPackage -Name Microsoft.Windows.Photos))
{
return
}
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
switch ($PSCmdlet.ParameterSetName) switch ($PSCmdlet.ParameterSetName)
{ {
"Install" "Install"
{ {
# Check whether the extension is already installed
if (-not ((Get-AppxPackage -Name Microsoft.HEVCVideoExtension) -and (Get-AppxPackage -Name Microsoft.Windows.Photos)))
{
return
}
try try
{ {
# Check the internet connection # Check whether https://store.rg-adguard.net is alive
$Parameters = @{ $Parameters = @{
Uri = "https://www.google.com" Uri = "https://store.rg-adguard.net/api/GetFiles"
Method = "Head" Method = "Head"
DisableKeepAlive = $true DisableKeepAlive = $true
UseBasicParsing = $true UseBasicParsing = $true
@ -10802,103 +10825,58 @@ function HEIF
return return
} }
try $Body = @{
{ type = "url"
# Check whether https://store.rg-adguard.net is alive url = "https://www.microsoft.com/store/productId/9n4wgh0z6vhq"
$Parameters = @{ ring = "Retail"
Uri = "https://store.rg-adguard.net/api/GetFiles" lang = "en-US"
Method = "Head" }
DisableKeepAlive = $true $Parameters = @{
UseBasicParsing = $true Uri = "https://store.rg-adguard.net/api/GetFiles"
} Method = "Post"
if (-not (Invoke-WebRequest @Parameters).StatusDescription) ContentType = "application/x-www-form-urlencoded"
Body = $Body
UseBasicParsing = $true
Verbose = $true
}
$Raw = Invoke-WebRequest @Parameters
# Parsing the page
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*x64*.appx*"} | ForEach-Object -Process {
$TempURL = ($_.Groups | Select-Object -Index 1).Value
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version)
{ {
return Write-Verbose -Message $Localization.Patient -Verbose
} Write-Verbose -Message $Localization.HEVCDownloading -Verbose
$Body = @{
type = "url"
url = "https://www.microsoft.com/store/productId/9n4wgh0z6vhq"
ring = "Retail"
lang = "en-US"
}
$Parameters = @{
Uri = "https://store.rg-adguard.net/api/GetFiles"
Method = "Post"
ContentType = "application/x-www-form-urlencoded"
Body = $Body
Verbose = $true
}
$Raw = Invoke-WebRequest @Parameters
# Parsing the page
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*x64*.appx*"} | ForEach-Object -Process {
$TempURL = ($_.Groups | Select-Object -Index 1).Value
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version)
{
Write-Verbose -Message $Localization.Patient -Verbose
Write-Verbose -Message $Localization.HEVCDownloading -Verbose
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = $TempURL
OutFile = "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx"
Verbose = $true
}
Invoke-WebRequest @Parameters
Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force $Parameters = @{
Uri = $TempURL
OutFile = "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx"
UseBasicParsing = $true
Verbose = $true
} }
} Invoke-WebRequest @Parameters
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force
}
} }
} }
catch [System.Net.WebException] catch [System.Net.WebException]
{ {
Write-Warning -Message $Localization.NoInternetConnection Write-Warning -Message ($Localization.NoResponse -f "https://store.rg-adguard.net/api/GetFiles")
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.NoResponse -f "https://store.rg-adguard.net/api/GetFiles") -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
} }
} }
"Manually" "Manually"
{ {
if ((-not (Get-AppxPackage -Name Microsoft.HEVCVideoExtension)) -and (Get-AppxPackage -Name Microsoft.Windows.Photos)) Start-Process -FilePath ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
{
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
Start-Process -FilePath ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
}
}
} }
} }
} }
@ -13629,7 +13607,7 @@ function UseStoreOpenWith
#region Update Policies #region Update Policies
<# <#
.SYNOPSIS .SYNOPSIS
Update Local Group Policy Editor (gpedit.msc) to make all manually created policy keys in the registry visible in the snap-in Display all policy registry keys (even manually created ones) in the Local Group Policy Editor snap-in (gpedit.msc)
.EXAMPLE .EXAMPLE
UpdateLGPEPolicies UpdateLGPEPolicies
@ -13639,6 +13617,7 @@ function UseStoreOpenWith
.NOTES .NOTES
Machine-wide user Machine-wide user
Current user
#> #>
function UpdateLGPEPolicies function UpdateLGPEPolicies
{ {

163
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -10159,21 +10159,44 @@ function HEIF
$Manually $Manually
) )
# Check whether the extension is already installed
if (-not (Get-AppxPackage -Name Microsoft.Windows.Photos))
{
return
}
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
switch ($PSCmdlet.ParameterSetName) switch ($PSCmdlet.ParameterSetName)
{ {
"Install" "Install"
{ {
# Check whether the extension is already installed
if (-not ((Get-AppxPackage -Name Microsoft.HEVCVideoExtension) -and (Get-AppxPackage -Name Microsoft.Windows.Photos)))
{
return
}
try try
{ {
# Check the internet connection # Check whether https://store.rg-adguard.net is alive
$Parameters = @{ $Parameters = @{
Uri = "https://www.google.com" Uri = "https://store.rg-adguard.net/api/GetFiles"
Method = "Head" Method = "Head"
DisableKeepAlive = $true DisableKeepAlive = $true
UseBasicParsing = $true UseBasicParsing = $true
@ -10183,103 +10206,58 @@ function HEIF
return return
} }
try $Body = @{
{ type = "url"
# Check whether https://store.rg-adguard.net is alive url = "https://www.microsoft.com/store/productId/9n4wgh0z6vhq"
$Parameters = @{ ring = "Retail"
Uri = "https://store.rg-adguard.net/api/GetFiles" lang = "en-US"
Method = "Head" }
DisableKeepAlive = $true $Parameters = @{
UseBasicParsing = $true Uri = "https://store.rg-adguard.net/api/GetFiles"
} Method = "Post"
if (-not (Invoke-WebRequest @Parameters).StatusDescription) ContentType = "application/x-www-form-urlencoded"
Body = $Body
UseBasicParsing = $true
Verbose = $true
}
$Raw = Invoke-WebRequest @Parameters
# Parsing the page
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*x64*.appx*"} | ForEach-Object -Process {
$TempURL = ($_.Groups | Select-Object -Index 1).Value
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version)
{ {
return Write-Verbose -Message $Localization.Patient -Verbose
} Write-Verbose -Message $Localization.HEVCDownloading -Verbose
$Body = @{
type = "url"
url = "https://www.microsoft.com/store/productId/9n4wgh0z6vhq"
ring = "Retail"
lang = "en-US"
}
$Parameters = @{
Uri = "https://store.rg-adguard.net/api/GetFiles"
Method = "Post"
ContentType = "application/x-www-form-urlencoded"
Body = $Body
Verbose = $true
}
$Raw = Invoke-WebRequest @Parameters
# Parsing the page
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*x64*.appx*"} | ForEach-Object -Process {
$TempURL = ($_.Groups | Select-Object -Index 1).Value
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer" $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version) $Parameters = @{
{ Uri = $TempURL
Write-Verbose -Message $Localization.Patient -Verbose OutFile = "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx"
Write-Verbose -Message $Localization.HEVCDownloading -Verbose UseBasicParsing = $true
Verbose = $true
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = $TempURL
OutFile = "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx"
Verbose = $true
}
Invoke-WebRequest @Parameters
Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force
} }
} Invoke-WebRequest @Parameters
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force
}
} }
} }
catch [System.Net.WebException] catch [System.Net.WebException]
{ {
Write-Warning -Message $Localization.NoInternetConnection Write-Warning -Message ($Localization.NoResponse -f "https://store.rg-adguard.net/api/GetFiles")
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.NoResponse -f "https://store.rg-adguard.net/api/GetFiles") -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
} }
} }
"Manually" "Manually"
{ {
if ((-not (Get-AppxPackage -Name Microsoft.HEVCVideoExtension)) -and (Get-AppxPackage -Name Microsoft.Windows.Photos)) Start-Process -FilePath ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
{
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
Start-Process -FilePath ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
}
}
} }
} }
} }
@ -12994,7 +12972,7 @@ function Windows10ContextMenu
#region Update Policies #region Update Policies
<# <#
.SYNOPSIS .SYNOPSIS
Update Local Group Policy Editor (gpedit.msc) to make all manually created policy keys in the registry visible in the snap-in Display all policy registry keys (even manually created ones) in the Local Group Policy Editor snap-in (gpedit.msc)
.EXAMPLE .EXAMPLE
UpdateLGPEPolicies UpdateLGPEPolicies
@ -13004,6 +12982,7 @@ function Windows10ContextMenu
.NOTES .NOTES
Machine-wide user Machine-wide user
Current user
#> #>
function UpdateLGPEPolicies function UpdateLGPEPolicies
{ {

163
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -10197,21 +10197,44 @@ function HEIF
$Manually $Manually
) )
# Check whether the extension is already installed
if (-not (Get-AppxPackage -Name Microsoft.Windows.Photos))
{
return
}
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
return
}
switch ($PSCmdlet.ParameterSetName) switch ($PSCmdlet.ParameterSetName)
{ {
"Install" "Install"
{ {
# Check whether the extension is already installed
if (-not ((Get-AppxPackage -Name Microsoft.HEVCVideoExtension) -and (Get-AppxPackage -Name Microsoft.Windows.Photos)))
{
return
}
try try
{ {
# Check the internet connection # Check whether https://store.rg-adguard.net is alive
$Parameters = @{ $Parameters = @{
Uri = "https://www.google.com" Uri = "https://store.rg-adguard.net/api/GetFiles"
Method = "Head" Method = "Head"
DisableKeepAlive = $true DisableKeepAlive = $true
UseBasicParsing = $true UseBasicParsing = $true
@ -10221,103 +10244,58 @@ function HEIF
return return
} }
try $Body = @{
{ type = "url"
# Check whether https://store.rg-adguard.net is alive url = "https://www.microsoft.com/store/productId/9n4wgh0z6vhq"
$Parameters = @{ ring = "Retail"
Uri = "https://store.rg-adguard.net/api/GetFiles" lang = "en-US"
Method = "Head" }
DisableKeepAlive = $true $Parameters = @{
UseBasicParsing = $true Uri = "https://store.rg-adguard.net/api/GetFiles"
} Method = "Post"
if (-not (Invoke-WebRequest @Parameters).StatusDescription) ContentType = "application/x-www-form-urlencoded"
Body = $Body
UseBasicParsing = $true
Verbose = $true
}
$Raw = Invoke-WebRequest @Parameters
# Parsing the page
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*x64*.appx*"} | ForEach-Object -Process {
$TempURL = ($_.Groups | Select-Object -Index 1).Value
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version)
{ {
return Write-Verbose -Message $Localization.Patient -Verbose
} Write-Verbose -Message $Localization.HEVCDownloading -Verbose
$Body = @{
type = "url"
url = "https://www.microsoft.com/store/productId/9n4wgh0z6vhq"
ring = "Retail"
lang = "en-US"
}
$Parameters = @{
Uri = "https://store.rg-adguard.net/api/GetFiles"
Method = "Post"
ContentType = "application/x-www-form-urlencoded"
Body = $Body
Verbose = $true
}
$Raw = Invoke-WebRequest @Parameters
# Parsing the page
$Raw | Select-String -Pattern '<tr style.*<a href=\"(?<url>.*)"\s.*>(?<text>.*)<\/a>' -AllMatches | ForEach-Object -Process {$_.Matches} | Where-Object -FilterScript {$_.Value -like "*x64*.appx*"} | ForEach-Object -Process {
$TempURL = ($_.Groups | Select-Object -Index 1).Value
$HEVCPackageName = ($_.Groups | Select-Object -Index 2).Value.Split("_") | Select-Object -Index 1
# Installing "HEVC Video Extensions from Device Manufacturer" $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
if ([System.Version]$HEVCPackageName -gt [System.Version](Get-AppxPackage -Name Microsoft.HEVCVideoExtension).Version) $Parameters = @{
{ Uri = $TempURL
Write-Verbose -Message $Localization.Patient -Verbose OutFile = "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx"
Write-Verbose -Message $Localization.HEVCDownloading -Verbose UseBasicParsing = $true
Verbose = $true
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = $TempURL
OutFile = "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx"
Verbose = $true
}
Invoke-WebRequest @Parameters
Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force
} }
} Invoke-WebRequest @Parameters
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://github.com")
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue Add-AppxPackage -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Verbose
Remove-Item -Path "$DownloadsFolder\Microsoft.HEVCVideoExtension_8wekyb3d8bbwe.appx" -Force
}
} }
} }
catch [System.Net.WebException] catch [System.Net.WebException]
{ {
Write-Warning -Message $Localization.NoInternetConnection Write-Warning -Message ($Localization.NoResponse -f "https://store.rg-adguard.net/api/GetFiles")
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue Write-Error -Message ($Localization.NoResponse -f "https://store.rg-adguard.net/api/GetFiles") -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
} }
} }
"Manually" "Manually"
{ {
if ((-not (Get-AppxPackage -Name Microsoft.HEVCVideoExtension)) -and (Get-AppxPackage -Name Microsoft.Windows.Photos)) Start-Process -FilePath ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
{
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
Start-Process -FilePath ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line) -ErrorAction SilentlyContinue
}
}
} }
} }
} }
@ -13031,7 +13009,7 @@ function Windows10ContextMenu
#region Update Policies #region Update Policies
<# <#
.SYNOPSIS .SYNOPSIS
Update Local Group Policy Editor (gpedit.msc) to make all manually created policy keys in the registry visible in the snap-in Display all policy registry keys (even manually created ones) in the Local Group Policy Editor snap-in (gpedit.msc)
.EXAMPLE .EXAMPLE
UpdateLGPEPolicies UpdateLGPEPolicies
@ -13041,6 +13019,7 @@ function Windows10ContextMenu
.NOTES .NOTES
Machine-wide user Machine-wide user
Current user
#> #>
function UpdateLGPEPolicies function UpdateLGPEPolicies
{ {

Loading…
Cancel
Save