mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-02 19:13:30 -05:00
Compare commits
21 Commits
Runspace-C
...
a37e435949
Author | SHA1 | Date | |
---|---|---|---|
a37e435949 | |||
2fbe40a3ee | |||
42d13ad735 | |||
744fee6c40 | |||
6d4db7dc7a | |||
32e98c0264 | |||
26e117c5bf | |||
1d35d06c84 | |||
8069364777 | |||
bac37a186b | |||
090aecc8b0 | |||
9a58c9e70e | |||
5248954e77 | |||
367485c993 | |||
440f8922bb | |||
369f8a6179 | |||
6ebf40d373 | |||
739bb49796 | |||
c34c804037 | |||
aed92704a8 | |||
b659acb3b3 |
@ -18,28 +18,23 @@ function Test-CompatibleImage() {
|
|||||||
<#
|
<#
|
||||||
|
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks the version of a Windows image and determines whether or not it is compatible depending on the Major property
|
Checks the version of a Windows image and determines whether or not it is compatible with a specific feature depending on a desired version
|
||||||
|
|
||||||
.PARAMETER imgVersion
|
.PARAMETER Name
|
||||||
The version of the Windows image
|
imgVersion - The version of the Windows image
|
||||||
|
desiredVersion - The version to compare the image version with
|
||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)] [string] $imgVersion
|
[Parameter(Mandatory = $true, Position=0)] [string] $imgVersion,
|
||||||
|
[Parameter(Mandatory = $true, Position=1)] [Version] $desiredVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$version = [Version]$imgVersion
|
$version = [Version]$imgVersion
|
||||||
if ($version.Major -ge 10)
|
return $version -ge $desiredVersion
|
||||||
{
|
|
||||||
return $True
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return $False
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
return $False
|
return $False
|
||||||
}
|
}
|
||||||
@ -247,7 +242,7 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
|
|||||||
|
|
||||||
foreach($itemToDelete in $itemsToDelete)
|
foreach($itemToDelete in $itemsToDelete)
|
||||||
{
|
{
|
||||||
$status = "Deleteing $($itemToDelete)"
|
$status = "Deleting $($itemToDelete)"
|
||||||
Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100)
|
Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100)
|
||||||
|
|
||||||
if (Test-Path -Path "$($itemToDelete)" -PathType Container)
|
if (Test-Path -Path "$($itemToDelete)" -PathType Container)
|
||||||
@ -321,7 +316,7 @@ function New-Unattend {
|
|||||||
<unattend xmlns="urn:schemas-microsoft-com:unattend"
|
<unattend xmlns="urn:schemas-microsoft-com:unattend"
|
||||||
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
|
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<#REPLACEME#>
|
||||||
<settings pass="auditUser">
|
<settings pass="auditUser">
|
||||||
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<RunSynchronous>
|
<RunSynchronous>
|
||||||
@ -362,6 +357,26 @@ function New-Unattend {
|
|||||||
</settings>
|
</settings>
|
||||||
</unattend>
|
</unattend>
|
||||||
'@
|
'@
|
||||||
|
$specPass = @'
|
||||||
|
<settings pass="specialize">
|
||||||
|
<component name="Microsoft-Windows-SQMApi" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<CEIPEnabled>0</CEIPEnabled>
|
||||||
|
</component>
|
||||||
|
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>
|
||||||
|
</component>
|
||||||
|
</settings>
|
||||||
|
'@
|
||||||
|
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,22000,1))) -eq $false)
|
||||||
|
{
|
||||||
|
# Replace the placeholder text with an empty string to make it valid for Windows 10 Setup
|
||||||
|
$unattend = $unattend.Replace("<#REPLACEME#>", "").Trim()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# Replace the placeholder text with the Specialize pass
|
||||||
|
$unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim()
|
||||||
|
}
|
||||||
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force
|
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class PowerManagement {
|
|||||||
$imgVersion = (Get-WindowsImage -ImagePath $mountDir\sources\install.wim -Index $index).Version
|
$imgVersion = (Get-WindowsImage -ImagePath $mountDir\sources\install.wim -Index $index).Version
|
||||||
|
|
||||||
# Detect image version to avoid performing MicroWin processing on Windows 8 and earlier
|
# Detect image version to avoid performing MicroWin processing on Windows 8 and earlier
|
||||||
if ((Test-CompatibleImage $imgVersion) -eq $false)
|
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,10240,0))) -eq $false)
|
||||||
{
|
{
|
||||||
$msg = "This image is not compatible with MicroWin processing. Make sure it isn't a Windows 8 or earlier image."
|
$msg = "This image is not compatible with MicroWin processing. Make sure it isn't a Windows 8 or earlier image."
|
||||||
$dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."
|
$dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."
|
||||||
|
46
winutil.ps1
46
winutil.ps1
@ -10,7 +10,6 @@
|
|||||||
Author : Chris Titus @christitustech
|
Author : Chris Titus @christitustech
|
||||||
Runspace Author: @DeveloperDurp
|
Runspace Author: @DeveloperDurp
|
||||||
GitHub : https://github.com/ChrisTitusTech
|
GitHub : https://github.com/ChrisTitusTech
|
||||||
Version : 24.02.22
|
|
||||||
#>
|
#>
|
||||||
param (
|
param (
|
||||||
[switch]$Debug,
|
[switch]$Debug,
|
||||||
@ -751,28 +750,23 @@ function Test-CompatibleImage() {
|
|||||||
<#
|
<#
|
||||||
|
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks the version of a Windows image and determines whether or not it is compatible depending on the Major property
|
Checks the version of a Windows image and determines whether or not it is compatible with a specific feature depending on a desired version
|
||||||
|
|
||||||
.PARAMETER imgVersion
|
.PARAMETER Name
|
||||||
The version of the Windows image
|
imgVersion - The version of the Windows image
|
||||||
|
desiredVersion - The version to compare the image version with
|
||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true)] [string] $imgVersion
|
[Parameter(Mandatory = $true, Position=0)] [string] $imgVersion,
|
||||||
|
[Parameter(Mandatory = $true, Position=1)] [Version] $desiredVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$version = [Version]$imgVersion
|
$version = [Version]$imgVersion
|
||||||
if ($version.Major -ge 10)
|
return $version -ge $desiredVersion
|
||||||
{
|
|
||||||
return $True
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return $False
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
return $False
|
return $False
|
||||||
}
|
}
|
||||||
@ -980,7 +974,7 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
|
|||||||
|
|
||||||
foreach($itemToDelete in $itemsToDelete)
|
foreach($itemToDelete in $itemsToDelete)
|
||||||
{
|
{
|
||||||
$status = "Deleteing $($itemToDelete)"
|
$status = "Deleting $($itemToDelete)"
|
||||||
Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100)
|
Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100)
|
||||||
|
|
||||||
if (Test-Path -Path "$($itemToDelete)" -PathType Container)
|
if (Test-Path -Path "$($itemToDelete)" -PathType Container)
|
||||||
@ -1054,7 +1048,7 @@ function New-Unattend {
|
|||||||
<unattend xmlns="urn:schemas-microsoft-com:unattend"
|
<unattend xmlns="urn:schemas-microsoft-com:unattend"
|
||||||
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
|
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<#REPLACEME#>
|
||||||
<settings pass="auditUser">
|
<settings pass="auditUser">
|
||||||
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<RunSynchronous>
|
<RunSynchronous>
|
||||||
@ -1095,6 +1089,26 @@ function New-Unattend {
|
|||||||
</settings>
|
</settings>
|
||||||
</unattend>
|
</unattend>
|
||||||
'@
|
'@
|
||||||
|
$specPass = @'
|
||||||
|
<settings pass="specialize">
|
||||||
|
<component name="Microsoft-Windows-SQMApi" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<CEIPEnabled>0</CEIPEnabled>
|
||||||
|
</component>
|
||||||
|
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>
|
||||||
|
</component>
|
||||||
|
</settings>
|
||||||
|
'@
|
||||||
|
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,22000,1))) -eq $false)
|
||||||
|
{
|
||||||
|
# Replace the placeholder text with an empty string to make it valid for Windows 10 Setup
|
||||||
|
$unattend = $unattend.Replace("<#REPLACEME#>", "").Trim()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# Replace the placeholder text with the Specialize pass
|
||||||
|
$unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim()
|
||||||
|
}
|
||||||
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force
|
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3430,7 +3444,7 @@ public class PowerManagement {
|
|||||||
$imgVersion = (Get-WindowsImage -ImagePath $mountDir\sources\install.wim -Index $index).Version
|
$imgVersion = (Get-WindowsImage -ImagePath $mountDir\sources\install.wim -Index $index).Version
|
||||||
|
|
||||||
# Detect image version to avoid performing MicroWin processing on Windows 8 and earlier
|
# Detect image version to avoid performing MicroWin processing on Windows 8 and earlier
|
||||||
if ((Test-CompatibleImage $imgVersion) -eq $false)
|
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,10240,0))) -eq $false)
|
||||||
{
|
{
|
||||||
$msg = "This image is not compatible with MicroWin processing. Make sure it isn't a Windows 8 or earlier image."
|
$msg = "This image is not compatible with MicroWin processing. Make sure it isn't a Windows 8 or earlier image."
|
||||||
$dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."
|
$dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."
|
||||||
|
Reference in New Issue
Block a user