Documentation
¶
Index ¶
Constants ¶
const FirewallRuleApplyScript = `` /* 1213-byte string literal not displayed */
const FirewallRuleCheckScript = `` /* 932-byte string literal not displayed */
const ModuleRemoveAppxApplyScript = `` /* 2234-byte string literal not displayed */
ModuleRemoveAppxApplyScript preserves the module-side apply flow, including iterating raw installed package results before skipping empty PackageFullName entries with output.
const PackageApplyScript = `` /* 1819-byte string literal not displayed */
const PackageCheckScript = `` /* 773-byte string literal not displayed */
const PowerPlanApplyScript = `` /* 2644-byte string literal not displayed */
const PowerPlanCheckScript = `` /* 1911-byte string literal not displayed */
const PowerPlanModuleApplyScript = `` /* 2834-byte string literal not displayed */
const PowerPlanModuleCheckScript = `` /* 2599-byte string literal not displayed */
const RegistryApplyScript = `` /* 1342-byte string literal not displayed */
const RegistryCheckScript = `` /* 2785-byte string literal not displayed */
const RegistryEnsureScript = `` /* 3915-byte string literal not displayed */
RegistryEnsureScript combines check and apply in one PowerShell invocation. It outputs "ok", "changed", or "would-change" (dry-run). $__pf_dry_run must be injected by the caller before $params.
const RegistryModuleCheckScript = `` /* 2786-byte string literal not displayed */
const RemoveAppxApplyScript = RemoveAppxHelperFunctions + `
foreach ($spec in $pkgs) {
$name = [string]$spec.name
$scope = if ($spec.scope) { [string]$spec.scope } else { 'both' }
$hasWildcard = [WildcardPattern]::ContainsWildcardCharacters($name)
Write-Output ("processing appx package " + $name + " (" + $scope + ")")
if ($scope -ne 'provisioned') {
foreach ($pkg in (Get-InstalledAppxMatches $scope $name)) {
if ($null -eq $pkg) { continue }
$packageFullName = [string]$pkg.PackageFullName
if ([string]::IsNullOrWhiteSpace($packageFullName)) {
Write-Output ("skipping appx package " + $name + " because PackageFullName is empty")
continue
}
if ($scope -eq 'current_user') {
Remove-AppxPackage -Package $packageFullName -ErrorAction SilentlyContinue
} else {
try {
Remove-AppxPackage -Package $packageFullName -AllUsers -ErrorAction Stop
} catch {
Remove-AppxPackage -Package $packageFullName -ErrorAction SilentlyContinue
}
}
}
}
if ($scope -eq 'provisioned' -or $scope -eq 'both') {
@(Get-ProvisionedAppxMatches $scope $name $hasWildcard) | ForEach-Object {
Remove-AppxProvisionedPackage -Online -PackageName $_.PackageName -ErrorAction SilentlyContinue | Out-Null
}
}
}
`
RemoveAppxApplyScript calls Get-AppxProvisionedPackage -Online once before the loop and filters the cached list per package. Removed packages may still appear in the cached list but Remove-AppxProvisionedPackage with -ErrorAction SilentlyContinue handles that gracefully.
const RemoveAppxCheckScript = RemoveAppxHelperFunctions + `
foreach ($spec in $pkgs) {
$name = [string]$spec.name
$scope = if ($spec.scope) { [string]$spec.scope } else { 'both' }
$hasWildcard = [WildcardPattern]::ContainsWildcardCharacters($name)
$installed = Get-InstalledAppxMatches $scope $name
$provisioned = Get-ProvisionedAppxMatches $scope $name $hasWildcard
if (($installed.Count + $provisioned.Count) -gt 0) { Write-Output 'true'; exit 0 }
}
Write-Output 'false'
`
const RemoveAppxCheckScriptWithOutput = RemoveAppxHelperFunctions + `
foreach ($spec in $pkgs) {
$name = [string]$spec.name
$scope = if ($spec.scope) { [string]$spec.scope } else { 'both' }
$hasWildcard = [WildcardPattern]::ContainsWildcardCharacters($name)
Write-Output ("checking appx package " + $name + " (" + $scope + ")")
$installed = Get-InstalledAppxMatches $scope $name
$provisioned = Get-ProvisionedAppxMatches $scope $name $hasWildcard
if (($installed.Count + $provisioned.Count) -gt 0) { Write-Output 'true'; exit 0 }
}
Write-Output 'false'
`
const RemoveAppxEnsureScript = RemoveAppxHelperFunctions + `
$needs = $false
foreach ($spec in $pkgs) {
$name = [string]$spec.name
$scope = if ($spec.scope) { [string]$spec.scope } else { 'both' }
$hasWildcard = [WildcardPattern]::ContainsWildcardCharacters($name)
if ((Get-InstalledAppxMatches $scope $name).Count -gt 0) { $needs = $true; break }
if ((Get-ProvisionedAppxMatches $scope $name $hasWildcard).Count -gt 0) { $needs = $true; break }
}
if (-not $needs) { Write-Output 'ok'; exit 0 }
if ($__pf_dry_run) { Write-Output 'would-change'; exit 0 }
foreach ($spec in $pkgs) {
$name = [string]$spec.name
$scope = if ($spec.scope) { [string]$spec.scope } else { 'both' }
$hasWildcard = [WildcardPattern]::ContainsWildcardCharacters($name)
if ($scope -ne 'provisioned') {
foreach ($pkg in (Get-InstalledAppxMatches $scope $name)) {
if ($null -eq $pkg) { continue }
$packageFullName = [string]$pkg.PackageFullName
if ([string]::IsNullOrWhiteSpace($packageFullName)) { continue }
if ($scope -eq 'current_user') {
Remove-AppxPackage -Package $packageFullName -ErrorAction SilentlyContinue
} else {
try {
Remove-AppxPackage -Package $packageFullName -AllUsers -ErrorAction Stop
} catch {
Remove-AppxPackage -Package $packageFullName -ErrorAction SilentlyContinue
}
}
}
}
if ($scope -eq 'provisioned' -or $scope -eq 'both') {
@(Get-ProvisionedAppxMatches $scope $name $hasWildcard) | ForEach-Object {
Remove-AppxProvisionedPackage -Online -PackageName $_.PackageName -ErrorAction SilentlyContinue | Out-Null
}
}
}
Write-Output 'changed'
`
RemoveAppxEnsureScript combines check and apply in one invocation, calling Get-AppxProvisionedPackage -Online exactly once regardless of outcome. Outputs "ok", "would-change" (dry-run), or "changed". $__pf_dry_run must be set before $params by the caller.
const RemoveAppxHelperFunctions = `` /* 1428-byte string literal not displayed */
RemoveAppxHelperFunctions is shared preamble for all remove_appx_packages scripts. Get-AppxProvisionedPackage -Online is a slow DISM call; $allProvisioned caches it once per script invocation rather than once per package.
const ScheduledTaskApplyScript = `` /* 3950-byte string literal not displayed */
const ScheduledTaskCheckScript = `` /* 3987-byte string literal not displayed */
const ServiceApplyScript = `` /* 667-byte string literal not displayed */
const ServiceCheckScript = `` /* 947-byte string literal not displayed */
const ShortcutApplyScript = `` /* 671-byte string literal not displayed */
const ShortcutCheckScript = `` /* 662-byte string literal not displayed */
const UserApplyScript = `` /* 900-byte string literal not displayed */
const UserCheckScript = `` /* 678-byte string literal not displayed */
const WindowsFeatureApplyScript = `` /* 306-byte string literal not displayed */
const WindowsFeatureCheckScript = `` /* 411-byte string literal not displayed */
const WindowsFeatureModuleCheckScript = `` /* 401-byte string literal not displayed */
const WingetPackageApplyScript = `` /* 3307-byte string literal not displayed */
const WingetPackageCheckScript = `` /* 2358-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
This section is empty.