pscript

package
v1.0.0-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2026 License: ISC Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const FirewallRuleApplyScript = `` /* 1213-byte string literal not displayed */
View Source
const FirewallRuleCheckScript = `` /* 932-byte string literal not displayed */
View Source
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.

View Source
const PackageApplyScript = `` /* 1578-byte string literal not displayed */
View Source
const PackageCheckScript = `` /* 773-byte string literal not displayed */
View Source
const PowerPlanApplyScript = `` /* 2644-byte string literal not displayed */
View Source
const PowerPlanCheckScript = `` /* 1911-byte string literal not displayed */
View Source
const PowerPlanModuleApplyScript = `` /* 2834-byte string literal not displayed */
View Source
const PowerPlanModuleCheckScript = `` /* 2599-byte string literal not displayed */
View Source
const RegistryApplyScript = `` /* 1342-byte string literal not displayed */
View Source
const RegistryCheckScript = `` /* 2785-byte string literal not displayed */
View Source
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.

View Source
const RegistryModuleCheckScript = `` /* 2786-byte string literal not displayed */
View Source
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.

View Source
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'
`
View Source
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'
`
View Source
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.

View Source
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.

View Source
const ScheduledTaskApplyScript = `` /* 3950-byte string literal not displayed */
View Source
const ScheduledTaskCheckScript = `` /* 3987-byte string literal not displayed */
View Source
const ServiceApplyScript = `` /* 667-byte string literal not displayed */
View Source
const ServiceCheckScript = `` /* 947-byte string literal not displayed */
View Source
const ShortcutApplyScript = `` /* 671-byte string literal not displayed */
View Source
const ShortcutCheckScript = `` /* 662-byte string literal not displayed */
View Source
const UserApplyScript = `` /* 900-byte string literal not displayed */
View Source
const UserCheckScript = `` /* 678-byte string literal not displayed */
View Source
const WindowsFeatureApplyScript = `` /* 306-byte string literal not displayed */
View Source
const WindowsFeatureCheckScript = `` /* 411-byte string literal not displayed */
View Source
const WindowsFeatureModuleCheckScript = `` /* 401-byte string literal not displayed */
View Source
const WingetPackageApplyScript = `` /* 2041-byte string literal not displayed */
View Source
const WingetPackageCheckScript = `` /* 1333-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL