mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
Code Formatting Changes
This commit is contained in:
parent
03e32279bb
commit
1d6d0d600c
@ -57,9 +57,9 @@ function ConvertTo-Icon {
|
|||||||
|
|
||||||
#>
|
#>
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true, position=0)]
|
[Parameter(Mandatory, position=0)]
|
||||||
[string]$bitmapPath,
|
[string]$bitmapPath,
|
||||||
[Parameter(Mandatory=$true, position=1)]
|
[Parameter(Mandatory, position=1)]
|
||||||
[string]$iconPath,
|
[string]$iconPath,
|
||||||
[Parameter(position=2)]
|
[Parameter(position=2)]
|
||||||
[bool]$overrideIconFile = $true
|
[bool]$overrideIconFile = $true
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
function Get-Oscdimg {
|
function Get-Oscdimg {
|
||||||
<#
|
<#
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This function will download oscdimg file from github Release folders and put it into env:temp folder
|
This function will download oscdimg file from github Release folders and put it into env:temp folder
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Get-Oscdimg
|
Get-Oscdimg
|
||||||
#>
|
#>
|
||||||
param( [Parameter(Mandatory=$true)]
|
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory, position=0)]
|
||||||
[string]$oscdimgPath
|
[string]$oscdimgPath
|
||||||
)
|
)
|
||||||
|
|
||||||
$oscdimgPath = "$env:TEMP\oscdimg.exe"
|
$oscdimgPath = "$env:TEMP\oscdimg.exe"
|
||||||
$downloadUrl = "https://github.com/ChrisTitusTech/winutil/raw/main/releases/oscdimg.exe"
|
$downloadUrl = "https://github.com/ChrisTitusTech/winutil/raw/main/releases/oscdimg.exe"
|
||||||
Invoke-RestMethod -Uri $downloadUrl -OutFile $oscdimgPath
|
Invoke-RestMethod -Uri $downloadUrl -OutFile $oscdimgPath
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
function Get-TabXaml {
|
function Get-TabXaml {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Generates XAML for a tab in the WinUtil GUI
|
Generates XAML for a tab in the WinUtil GUI
|
||||||
This function is used to generate the XAML for the applications tab in the WinUtil GUI
|
This function is used to generate the XAML for the applications tab in the WinUtil GUI
|
||||||
It takes the tabname and the number of columns to display the applications in as input and returns the XAML for the tab as output
|
It takes the tabname and the number of columns to display the applications in as input and returns the XAML for the tab as output
|
||||||
.PARAMETER tabname
|
|
||||||
The name of the tab to generate XAML for
|
.PARAMETER tabname
|
||||||
Note: the 'tabname' parameter must equal one of the json files found in $sync.configs variable
|
The name of the tab to generate XAML for
|
||||||
Otherwise, it'll throw an exception
|
Note: the 'tabname' parameter must equal one of the json files found in $sync.configs variable
|
||||||
.PARAMETER columncount
|
Otherwise, it'll throw an exception
|
||||||
The number of columns to display the applications in, default is 0
|
|
||||||
.OUTPUTS
|
.PARAMETER columncount
|
||||||
The XAML for the tab
|
The number of columns to display the applications in, default is 0
|
||||||
.EXAMPLE
|
|
||||||
Get-TabXaml "applications" 3
|
.OUTPUTS
|
||||||
|
The XAML for the tab
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-TabXaml "applications" 3
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,27 +1,31 @@
|
|||||||
function Get-WPFObjectName {
|
function Get-WPFObjectName {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
This is a helper function that generates an objectname with the prefix WPF that can be used as a Powershell Variable after compilation.
|
This is a helper function that generates an objectname with the prefix WPF that can be used as a Powershell Variable after compilation.
|
||||||
To achieve this, all characters that are not a-z, A-Z or 0-9 are simply removed from the name.
|
To achieve this, all characters that are not a-z, A-Z or 0-9 are simply removed from the name.
|
||||||
.PARAMETER type
|
|
||||||
The type of object for which the name should be generated. (e.g. Label, Button, CheckBox...)
|
|
||||||
.PARAMETER name
|
|
||||||
The name or description to be used for the object. (invalid characters are removed)
|
|
||||||
.OUTPUTS
|
|
||||||
A string that can be used as a object/variable name in powershell.
|
|
||||||
For example: WPFLabelMicrosoftTools
|
|
||||||
|
|
||||||
.EXAMPLE
|
.PARAMETER type
|
||||||
Get-WPFObjectName -type Label -name "Microsoft Tools"
|
The type of object for which the name should be generated. (e.g. Label, Button, CheckBox...)
|
||||||
|
|
||||||
|
.PARAMETER name
|
||||||
|
The name or description to be used for the object. (invalid characters are removed)
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
A string that can be used as a object/variable name in powershell.
|
||||||
|
For example: WPFLabelMicrosoftTools
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-WPFObjectName -type Label -name "Microsoft Tools"
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param( [Parameter(Mandatory=$true)]
|
param(
|
||||||
$type,
|
[Parameter(Mandatory, position=0)]
|
||||||
$name
|
[string]$type,
|
||||||
)
|
|
||||||
|
|
||||||
$Output = $("WPF"+$type+$name) -replace '[^a-zA-Z0-9]', ''
|
[Parameter(position=1)]
|
||||||
|
[string]$name
|
||||||
return $Output
|
)
|
||||||
|
|
||||||
|
$Output = $("WPF"+$type+$name) -replace '[^a-zA-Z0-9]', ''
|
||||||
|
return $Output
|
||||||
}
|
}
|
@ -1,48 +1,45 @@
|
|||||||
function Test-CompatibleImage() {
|
function Test-CompatibleImage() {
|
||||||
<#
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Checks the version of a Windows image and determines whether or not it is compatible with a specific feature depending on a desired version
|
||||||
|
|
||||||
.SYNOPSIS
|
.PARAMETER Name
|
||||||
Checks the version of a Windows image and determines whether or not it is compatible with a specific feature depending on a desired version
|
imgVersion - The version of the Windows image
|
||||||
|
desiredVersion - The version to compare the image version with
|
||||||
|
#>
|
||||||
|
|
||||||
.PARAMETER Name
|
param
|
||||||
imgVersion - The version of the Windows image
|
(
|
||||||
desiredVersion - The version to compare the image version with
|
[Parameter(Mandatory, position=0)]
|
||||||
|
[string]$imgVersion,
|
||||||
|
|
||||||
#>
|
[Parameter(Mandatory, position=1)]
|
||||||
|
[Version]$desiredVersion
|
||||||
|
)
|
||||||
|
|
||||||
param
|
try {
|
||||||
(
|
$version = [Version]$imgVersion
|
||||||
[Parameter(Mandatory = $true, Position=0)] [string] $imgVersion,
|
return $version -ge $desiredVersion
|
||||||
[Parameter(Mandatory = $true, Position=1)] [Version] $desiredVersion
|
} catch {
|
||||||
)
|
return $False
|
||||||
|
}
|
||||||
try {
|
|
||||||
$version = [Version]$imgVersion
|
|
||||||
return $version -ge $desiredVersion
|
|
||||||
} catch {
|
|
||||||
return $False
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender = $false) {
|
function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender = $false) {
|
||||||
<#
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Removes certain features from ISO image
|
||||||
|
|
||||||
.SYNOPSIS
|
.PARAMETER Name
|
||||||
Removes certain features from ISO image
|
dumpFeatures - Dumps all features found in the ISO into a file called allfeaturesdump.txt. This file can be examined and used to decide what to remove.
|
||||||
|
keepDefender - Should Defender be removed from the ISO?
|
||||||
|
|
||||||
.PARAMETER Name
|
.EXAMPLE
|
||||||
dumpFeatures - Dumps all features found in the ISO into a file called allfeaturesdump.txt. This file can be examined and used to decide what to remove.
|
Remove-Features -keepDefender:$false
|
||||||
keepDefender - Should Defender be removed from the ISO?
|
#>
|
||||||
|
try {
|
||||||
.EXAMPLE
|
|
||||||
Remove-Features -keepDefender:$false
|
|
||||||
|
|
||||||
#>
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$featlist = (Get-WindowsOptionalFeature -Path $scratchDir).FeatureName
|
$featlist = (Get-WindowsOptionalFeature -Path $scratchDir).FeatureName
|
||||||
if ($dumpFeatures)
|
if ($dumpFeatures) {
|
||||||
{
|
|
||||||
$featlist > allfeaturesdump.txt
|
$featlist > allfeaturesdump.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +54,7 @@ function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender
|
|||||||
|
|
||||||
if ($keepDefender) { $featlist = $featlist | Where-Object { $_ -NotLike "*Defender*" }}
|
if ($keepDefender) { $featlist = $featlist | Where-Object { $_ -NotLike "*Defender*" }}
|
||||||
|
|
||||||
foreach($feature in $featlist)
|
foreach($feature in $featlist) {
|
||||||
{
|
|
||||||
$status = "Removing feature $feature"
|
$status = "Removing feature $feature"
|
||||||
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$featlist.Count*100)
|
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$featlist.Count*100)
|
||||||
Write-Debug "Removing feature $feature"
|
Write-Debug "Removing feature $feature"
|
||||||
@ -67,16 +63,13 @@ function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender
|
|||||||
Write-Progress -Activity "Removing features" -Status "Ready" -Completed
|
Write-Progress -Activity "Removing features" -Status "Ready" -Completed
|
||||||
Write-Host "You can re-enable the disabled features at any time, using either Windows Update or the SxS folder in <installation media>\Sources."
|
Write-Host "You can re-enable the disabled features at any time, using either Windows Update or the SxS folder in <installation media>\Sources."
|
||||||
}
|
}
|
||||||
catch
|
catch {
|
||||||
{
|
|
||||||
Write-Host "Unable to get information about the features. MicroWin processing will continue, but features will not be processed"
|
Write-Host "Unable to get information about the features. MicroWin processing will continue, but features will not be processed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Remove-Packages
|
function Remove-Packages {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
$pkglist = (Get-WindowsPackage -Path "$scratchDir").PackageName
|
$pkglist = (Get-WindowsPackage -Path "$scratchDir").PackageName
|
||||||
|
|
||||||
$pkglist = $pkglist | Where-Object {
|
$pkglist = $pkglist | Where-Object {
|
||||||
@ -117,8 +110,7 @@ function Remove-Packages
|
|||||||
$_ -NotLike "*UI.XaML*"
|
$_ -NotLike "*UI.XaML*"
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($pkg in $pkglist)
|
foreach ($pkg in $pkglist) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
$status = "Removing $pkg"
|
$status = "Removing $pkg"
|
||||||
Write-Progress -Activity "Removing Apps" -Status $status -PercentComplete ($counter++/$pkglist.Count*100)
|
Write-Progress -Activity "Removing Apps" -Status $status -PercentComplete ($counter++/$pkglist.Count*100)
|
||||||
@ -132,26 +124,22 @@ function Remove-Packages
|
|||||||
}
|
}
|
||||||
Write-Progress -Activity "Removing Apps" -Status "Ready" -Completed
|
Write-Progress -Activity "Removing Apps" -Status "Ready" -Completed
|
||||||
}
|
}
|
||||||
catch
|
catch {
|
||||||
{
|
|
||||||
Write-Host "Unable to get information about the packages. MicroWin processing will continue, but packages will not be processed"
|
Write-Host "Unable to get information about the packages. MicroWin processing will continue, but packages will not be processed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Remove-ProvisionedPackages([switch] $keepSecurity = $false)
|
function Remove-ProvisionedPackages([switch] $keepSecurity = $false) {
|
||||||
{
|
<#
|
||||||
<#
|
.SYNOPSIS
|
||||||
|
Removes AppX packages from a Windows image during MicroWin processing
|
||||||
|
|
||||||
.SYNOPSIS
|
.PARAMETER Name
|
||||||
Removes AppX packages from a Windows image during MicroWin processing
|
keepSecurity - Boolean that determines whether to keep "Microsoft.SecHealthUI" (Windows Security) in the Windows image
|
||||||
|
|
||||||
.PARAMETER Name
|
.EXAMPLE
|
||||||
keepSecurity - Boolean that determines whether to keep "Microsoft.SecHealthUI" (Windows Security) in the Windows image
|
Remove-ProvisionedPackages -keepSecurity:$false
|
||||||
|
#>
|
||||||
.EXAMPLE
|
|
||||||
Remove-ProvisionedPackages -keepSecurity:$false
|
|
||||||
|
|
||||||
#>
|
|
||||||
$appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object {
|
$appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object {
|
||||||
$_.PackageName -NotLike "*AppInstaller*" -AND
|
$_.PackageName -NotLike "*AppInstaller*" -AND
|
||||||
$_.PackageName -NotLike "*Store*" -and
|
$_.PackageName -NotLike "*Store*" -and
|
||||||
@ -165,14 +153,12 @@ function Remove-ProvisionedPackages([switch] $keepSecurity = $false)
|
|||||||
$_.PackageName -NotLike "*Foundation*"
|
$_.PackageName -NotLike "*Foundation*"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($?)
|
if ($?) {
|
||||||
{
|
if ($keepSecurity) { $appxProvisionedPackages = $appxProvisionedPackages | Where-Object { $_.PackageName -NotLike "*SecHealthUI*" }}
|
||||||
if ($keepSecurity) { $appxProvisionedPackages = $appxProvisionedPackages | Where-Object { $_.PackageName -NotLike "*SecHealthUI*" }}
|
$counter = 0
|
||||||
$counter = 0
|
foreach ($appx in $appxProvisionedPackages) {
|
||||||
foreach ($appx in $appxProvisionedPackages)
|
$status = "Removing Provisioned $($appx.PackageName)"
|
||||||
{
|
Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100)
|
||||||
$status = "Removing Provisioned $($appx.PackageName)"
|
|
||||||
Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100)
|
|
||||||
try {
|
try {
|
||||||
Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName -ErrorAction SilentlyContinue
|
Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
@ -180,17 +166,15 @@ function Remove-ProvisionedPackages([switch] $keepSecurity = $false)
|
|||||||
Write-Host "Application $($appx.PackageName) could not be removed"
|
Write-Host "Application $($appx.PackageName) could not be removed"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed
|
Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
Write-Host "Could not get Provisioned App information. Skipping process..."
|
||||||
Write-Host "Could not get Provisioned App information. Skipping process..."
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Copy-ToUSB([string] $fileToCopy)
|
function Copy-ToUSB([string] $fileToCopy) {
|
||||||
{
|
|
||||||
foreach ($volume in Get-Volume) {
|
foreach ($volume in Get-Volume) {
|
||||||
if ($volume -and $volume.FileSystemLabel -ieq "ventoy") {
|
if ($volume -and $volume.FileSystemLabel -ieq "ventoy") {
|
||||||
$destinationPath = "$($volume.DriveLetter):\"
|
$destinationPath = "$($volume.DriveLetter):\"
|
||||||
@ -214,8 +198,7 @@ function Copy-ToUSB([string] $fileToCopy)
|
|||||||
Write-Host "Ventoy USB Key is not inserted"
|
Write-Host "Ventoy USB Key is not inserted"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [switch] $Directory = $false)
|
function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [switch] $Directory = $false) {
|
||||||
{
|
|
||||||
if(([string]::IsNullOrEmpty($pathToDelete))) { return }
|
if(([string]::IsNullOrEmpty($pathToDelete))) { return }
|
||||||
if (-not (Test-Path -Path "$($pathToDelete)")) { return }
|
if (-not (Test-Path -Path "$($pathToDelete)")) { return }
|
||||||
|
|
||||||
@ -240,25 +223,21 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
|
|||||||
|
|
||||||
$itemsToDelete = [System.Collections.ArrayList]::new()
|
$itemsToDelete = [System.Collections.ArrayList]::new()
|
||||||
|
|
||||||
if ($mask -eq "")
|
if ($mask -eq "") {
|
||||||
{
|
|
||||||
Write-Debug "Adding $($pathToDelete) to array."
|
Write-Debug "Adding $($pathToDelete) to array."
|
||||||
[void]$itemsToDelete.Add($pathToDelete)
|
[void]$itemsToDelete.Add($pathToDelete)
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Write-Debug "Adding $($pathToDelete) to array and mask is $($mask)"
|
Write-Debug "Adding $($pathToDelete) to array and mask is $($mask)"
|
||||||
if ($Directory) { $itemsToDelete = Get-ChildItem $pathToDelete -Include $mask -Recurse -Directory }
|
if ($Directory) { $itemsToDelete = Get-ChildItem $pathToDelete -Include $mask -Recurse -Directory }
|
||||||
else { $itemsToDelete = Get-ChildItem $pathToDelete -Include $mask -Recurse }
|
else { $itemsToDelete = Get-ChildItem $pathToDelete -Include $mask -Recurse }
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($itemToDelete in $itemsToDelete)
|
foreach($itemToDelete in $itemsToDelete) {
|
||||||
{
|
|
||||||
$status = "Deleting $($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) {
|
||||||
{
|
|
||||||
$status = "Deleting directory: $($itemToDelete)"
|
$status = "Deleting directory: $($itemToDelete)"
|
||||||
|
|
||||||
takeown /r /d $yesNo[0] /a /f "$($itemToDelete)"
|
takeown /r /d $yesNo[0] /a /f "$($itemToDelete)"
|
||||||
@ -267,8 +246,7 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
|
|||||||
icacls $itemToDelete /grant "*S-1-5-32-544:(OI)(CI)F" /t /c /q
|
icacls $itemToDelete /grant "*S-1-5-32-544:(OI)(CI)F" /t /c /q
|
||||||
Remove-Item -Force -Recurse "$($itemToDelete)"
|
Remove-Item -Force -Recurse "$($itemToDelete)"
|
||||||
}
|
}
|
||||||
elseif (Test-Path -Path "$($itemToDelete)" -PathType Leaf)
|
elseif (Test-Path -Path "$($itemToDelete)" -PathType Leaf) {
|
||||||
{
|
|
||||||
$status = "Deleting file: $($itemToDelete)"
|
$status = "Deleting file: $($itemToDelete)"
|
||||||
|
|
||||||
takeown /a /f "$($itemToDelete)"
|
takeown /a /f "$($itemToDelete)"
|
||||||
@ -285,42 +263,42 @@ function New-Unattend {
|
|||||||
|
|
||||||
# later if we wont to remove even more bloat EU requires MS to remove everything from English(world)
|
# later if we wont to remove even more bloat EU requires MS to remove everything from English(world)
|
||||||
# Below is an example how to do it we probably should create a drop down with common locals
|
# Below is an example how to do it we probably should create a drop down with common locals
|
||||||
# <settings pass="specialize">
|
# <settings pass="specialize">
|
||||||
# <!-- Specify English (World) locale -->
|
# <!-- Specify English (World) locale -->
|
||||||
# <component name="Microsoft-Windows-International-Core" 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-International-Core" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
# <SetupUILanguage>
|
# <SetupUILanguage>
|
||||||
# <UILanguage>en-US</UILanguage>
|
# <UILanguage>en-US</UILanguage>
|
||||||
# </SetupUILanguage>
|
# </SetupUILanguage>
|
||||||
# <InputLocale>en-US</InputLocale>
|
# <InputLocale>en-US</InputLocale>
|
||||||
# <SystemLocale>en-US</SystemLocale>
|
# <SystemLocale>en-US</SystemLocale>
|
||||||
# <UILanguage>en-US</UILanguage>
|
# <UILanguage>en-US</UILanguage>
|
||||||
# <UserLocale>en-US</UserLocale>
|
# <UserLocale>en-US</UserLocale>
|
||||||
# </component>
|
# </component>
|
||||||
# </settings>
|
# </settings>
|
||||||
|
|
||||||
# <settings pass="oobeSystem">
|
# <settings pass="oobeSystem">
|
||||||
# <!-- Specify English (World) locale -->
|
# <!-- Specify English (World) locale -->
|
||||||
# <component name="Microsoft-Windows-International-Core" 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-International-Core" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
# <InputLocale>en-US</InputLocale>
|
# <InputLocale>en-US</InputLocale>
|
||||||
# <SystemLocale>en-US</SystemLocale>
|
# <SystemLocale>en-US</SystemLocale>
|
||||||
# <UILanguage>en-US</UILanguage>
|
# <UILanguage>en-US</UILanguage>
|
||||||
# <UserLocale>en-US</UserLocale>
|
# <UserLocale>en-US</UserLocale>
|
||||||
# </component>
|
# </component>
|
||||||
# </settings>
|
# </settings>
|
||||||
# using here string to embedd unattend
|
# using here string to embedd unattend
|
||||||
# <RunSynchronousCommand wcm:action="add">
|
# <RunSynchronousCommand wcm:action="add">
|
||||||
# <Order>1</Order>
|
# <Order>1</Order>
|
||||||
# <Path>net user administrator /active:yes</Path>
|
# <Path>net user administrator /active:yes</Path>
|
||||||
# </RunSynchronousCommand>
|
# </RunSynchronousCommand>
|
||||||
|
|
||||||
# this section doesn't work in win10/????
|
# this section doesn't work in win10/????
|
||||||
# <settings pass="specialize">
|
# <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">
|
# <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>
|
# <CEIPEnabled>0</CEIPEnabled>
|
||||||
# </component>
|
# </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">
|
# <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>
|
# <ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>
|
||||||
# </component>
|
# </component>
|
||||||
# </settings>
|
# </settings>
|
||||||
|
|
||||||
$unattend = @'
|
$unattend = @'
|
||||||
@ -328,7 +306,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#>
|
<#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>
|
||||||
@ -343,9 +321,9 @@ function New-Unattend {
|
|||||||
<settings pass="oobeSystem">
|
<settings pass="oobeSystem">
|
||||||
<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">
|
<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">
|
||||||
<OOBE>
|
<OOBE>
|
||||||
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
|
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
|
||||||
<SkipUserOOBE>false</SkipUserOOBE>
|
<SkipUserOOBE>false</SkipUserOOBE>
|
||||||
<SkipMachineOOBE>false</SkipMachineOOBE>
|
<SkipMachineOOBE>false</SkipMachineOOBE>
|
||||||
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
|
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
|
||||||
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
|
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
|
||||||
<HideEULAPage>true</HideEULAPage>
|
<HideEULAPage>true</HideEULAPage>
|
||||||
@ -369,26 +347,24 @@ function New-Unattend {
|
|||||||
</settings>
|
</settings>
|
||||||
</unattend>
|
</unattend>
|
||||||
'@
|
'@
|
||||||
$specPass = @'
|
$specPass = @'
|
||||||
<settings pass="specialize">
|
<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">
|
<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>
|
<CEIPEnabled>0</CEIPEnabled>
|
||||||
</component>
|
</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">
|
<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>
|
<ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>
|
||||||
</component>
|
</component>
|
||||||
</settings>
|
</settings>
|
||||||
'@
|
'@
|
||||||
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,22000,1))) -eq $false)
|
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
|
||||||
# Replace the placeholder text with an empty string to make it valid for Windows 10 Setup
|
$unattend = $unattend.Replace("<#REPLACEME#>", "").Trim()
|
||||||
$unattend = $unattend.Replace("<#REPLACEME#>", "").Trim()
|
}
|
||||||
}
|
else {
|
||||||
else
|
# Replace the placeholder text with the Specialize pass
|
||||||
{
|
$unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim()
|
||||||
# Replace the placeholder text with the Specialize pass
|
}
|
||||||
$unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim()
|
|
||||||
}
|
|
||||||
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force -Encoding utf8
|
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force -Encoding utf8
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,8 +448,7 @@ function New-FirstRun {
|
|||||||
$firstRun = @'
|
$firstRun = @'
|
||||||
# Set the global error action preference to continue
|
# Set the global error action preference to continue
|
||||||
$ErrorActionPreference = "Continue"
|
$ErrorActionPreference = "Continue"
|
||||||
function Remove-RegistryValue
|
function Remove-RegistryValue {
|
||||||
{
|
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$RegistryPath,
|
[string]$RegistryPath,
|
||||||
@ -483,30 +458,25 @@ function New-FirstRun {
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Check if the registry path exists
|
# Check if the registry path exists
|
||||||
if (Test-Path -Path $RegistryPath)
|
if (Test-Path -Path $RegistryPath) {
|
||||||
{
|
|
||||||
$registryValue = Get-ItemProperty -Path $RegistryPath -Name $ValueName -ErrorAction SilentlyContinue
|
$registryValue = Get-ItemProperty -Path $RegistryPath -Name $ValueName -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
# Check if the registry value exists
|
# Check if the registry value exists
|
||||||
if ($registryValue)
|
if ($registryValue) {
|
||||||
{
|
|
||||||
# Remove the registry value
|
# Remove the registry value
|
||||||
Remove-ItemProperty -Path $RegistryPath -Name $ValueName -Force
|
Remove-ItemProperty -Path $RegistryPath -Name $ValueName -Force
|
||||||
Write-Host "Registry value '$ValueName' removed from '$RegistryPath'."
|
Write-Host "Registry value '$ValueName' removed from '$RegistryPath'."
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Write-Host "Registry value '$ValueName' not found in '$RegistryPath'."
|
Write-Host "Registry value '$ValueName' not found in '$RegistryPath'."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Write-Host "Registry path '$RegistryPath' not found."
|
Write-Host "Registry path '$RegistryPath' not found."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Stop-UnnecessaryServices
|
function Stop-UnnecessaryServices {
|
||||||
{
|
|
||||||
$servicesToExclude = @(
|
$servicesToExclude = @(
|
||||||
"AudioSrv",
|
"AudioSrv",
|
||||||
"AudioEndpointBuilder",
|
"AudioEndpointBuilder",
|
||||||
@ -573,9 +543,8 @@ function New-FirstRun {
|
|||||||
)
|
)
|
||||||
|
|
||||||
$runningServices = Get-Service | Where-Object { $servicesToExclude -notcontains $_.Name }
|
$runningServices = Get-Service | Where-Object { $servicesToExclude -notcontains $_.Name }
|
||||||
foreach($service in $runningServices)
|
foreach($service in $runningServices) {
|
||||||
{
|
Stop-Service -Name $service.Name -PassThru
|
||||||
Stop-Service -Name $service.Name -PassThru
|
|
||||||
Set-Service $service.Name -StartupType Manual
|
Set-Service $service.Name -StartupType Manual
|
||||||
"Stopping service $($service.Name)" | Out-File -FilePath c:\windows\LogFirstRun.txt -Append -NoClobber
|
"Stopping service $($service.Name)" | Out-File -FilePath c:\windows\LogFirstRun.txt -Append -NoClobber
|
||||||
}
|
}
|
||||||
@ -613,10 +582,8 @@ function New-FirstRun {
|
|||||||
# Delete Edge Icon from the desktop
|
# Delete Edge Icon from the desktop
|
||||||
$edgeShortcutFiles = Get-ChildItem -Path $desktopPath -Filter "*Edge*.lnk"
|
$edgeShortcutFiles = Get-ChildItem -Path $desktopPath -Filter "*Edge*.lnk"
|
||||||
# Check if Edge shortcuts exist on the desktop
|
# Check if Edge shortcuts exist on the desktop
|
||||||
if ($edgeShortcutFiles)
|
if ($edgeShortcutFiles) {
|
||||||
{
|
foreach ($shortcutFile in $edgeShortcutFiles) {
|
||||||
foreach ($shortcutFile in $edgeShortcutFiles)
|
|
||||||
{
|
|
||||||
# Remove each Edge shortcut
|
# Remove each Edge shortcut
|
||||||
Remove-Item -Path $shortcutFile.FullName -Force
|
Remove-Item -Path $shortcutFile.FullName -Force
|
||||||
Write-Host "Edge shortcut '$($shortcutFile.Name)' removed from the desktop."
|
Write-Host "Edge shortcut '$($shortcutFile.Name)' removed from the desktop."
|
||||||
@ -639,8 +606,7 @@ function New-FirstRun {
|
|||||||
# Create a shortcut object
|
# Create a shortcut object
|
||||||
$shortcut = $shell.CreateShortcut($shortcutPath)
|
$shortcut = $shell.CreateShortcut($shortcutPath)
|
||||||
|
|
||||||
if (Test-Path -Path "c:\Windows\cttlogo.png")
|
if (Test-Path -Path "c:\Windows\cttlogo.png") {
|
||||||
{
|
|
||||||
$shortcut.IconLocation = "c:\Windows\cttlogo.png"
|
$shortcut.IconLocation = "c:\Windows\cttlogo.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,11 +616,11 @@ function New-FirstRun {
|
|||||||
# Save the shortcut
|
# Save the shortcut
|
||||||
$shortcut.Save()
|
$shortcut.Save()
|
||||||
|
|
||||||
# Make the shortcut have 'Run as administrator' property on
|
# Make the shortcut have 'Run as administrator' property on
|
||||||
$bytes = [System.IO.File]::ReadAllBytes($shortcutPath)
|
$bytes = [System.IO.File]::ReadAllBytes($shortcutPath)
|
||||||
# Set byte value at position 0x15 in hex, or 21 in decimal, from the value 0x00 to 0x20 in hex
|
# Set byte value at position 0x15 in hex, or 21 in decimal, from the value 0x00 to 0x20 in hex
|
||||||
$bytes[0x15] = $bytes[0x15] -bor 0x20
|
$bytes[0x15] = $bytes[0x15] -bor 0x20
|
||||||
[System.IO.File]::WriteAllBytes($shortcutPath, $bytes)
|
[System.IO.File]::WriteAllBytes($shortcutPath, $bytes)
|
||||||
|
|
||||||
Write-Host "Shortcut created at: $shortcutPath"
|
Write-Host "Shortcut created at: $shortcutPath"
|
||||||
#
|
#
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
function Set-WinUtilUITheme {
|
function Set-WinUtilUITheme {
|
||||||
<#
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Sets the theme of the XAML file
|
||||||
|
|
||||||
.SYNOPSIS
|
.PARAMETER inputXML
|
||||||
Sets the theme of the XAML file
|
A string representing the XAML object to modify
|
||||||
|
|
||||||
.PARAMETER inputXML
|
.PARAMETER themeName
|
||||||
A string representing the XAML object to modify
|
The name of the theme to set the XAML to. Defaults to 'matrix'
|
||||||
|
|
||||||
.PARAMETER themeName
|
|
||||||
The name of the theme to set the XAML to. Defaults to 'matrix'
|
|
||||||
|
|
||||||
.EXAMPLE
|
|
||||||
Set-WinUtilUITheme -inputXAML $inputXAML
|
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Set-WinUtilUITheme -inputXAML $inputXAML
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory=$true, Position=0)]
|
[Parameter(Mandatory, position=0)]
|
||||||
[string] $inputXML,
|
[string] $inputXML,
|
||||||
[Parameter(Mandatory=$false, Position=1)]
|
[Parameter(position=1)]
|
||||||
[string] $themeName = 'matrix'
|
[string] $themeName = 'matrix'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user