\d+))?(\-(?[0-9A-Za-z\-\.]+))?(\+(?[0-9A-Za-z\-\.]+))?$" | Out-Null
+function Get-SemVer($version) {
+ $version -match '^(?\d+)(\.(?\d+))?(\.(?\d+))?(\-(?[0-9A-Za-z\-\.]+))?(\+(?[0-9A-Za-z\-\.]+))?$' | Out-Null
$major = [int]$matches['major']
$minor = [int]$matches['minor']
$patch = [int]$matches['patch']
-
+
if ($null -eq $matches['pre']) { $pre = @() }
- else { $pre = $matches['pre'].Split(".") }
+ else { $pre = $matches['pre'].Split('.') }
$revision = 0
- if ($pre.Length -gt 1)
- {
+ if ($pre.Length -gt 1) {
$revision = Get-HighestRevision -InputArray $pre
}
- return [version]$version = "$major.$minor.$patch.$revision"
+ return [version]$version = "$major.$minor.$patch.$revision"
}
-function Get-HighestRevision
-{
+function Get-HighestRevision {
param (
[Parameter(Mandatory = $true)]
[array]$InputArray
@@ -236,18 +204,14 @@ function Get-HighestRevision
}
# Return the highest integer
- if ($integers.Count -gt 0)
- {
+ if ($integers.Count -gt 0) {
return ($integers | Measure-Object -Maximum).Maximum
- }
- else
- {
+ } else {
return $null
}
}
-function Install-DotNetToolPackage
-{
+function Install-DotNetToolPackage {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
@@ -265,8 +229,7 @@ function Install-DotNetToolPackage
Invoke-DotNet -Command $arguments
}
-function Update-DotNetToolPackage
-{
+function Update-DotNetToolPackage {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
@@ -284,20 +247,17 @@ function Update-DotNetToolPackage
Invoke-DotNet -Command $arguments
}
-function Assert-DotNetToolDowngrade
-{
+function Assert-DotNetToolDowngrade {
[version]$version = Invoke-DotNet -Command '--version'
- if ($version.Build -lt 200)
- {
+ if ($version.Build -lt 200) {
return $false
}
return $true
}
-function Uninstall-DotNetToolPackage
-{
+function Uninstall-DotNetToolPackage {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
@@ -306,25 +266,21 @@ function Uninstall-DotNetToolPackage
)
$installArgument = Get-DotNetToolArguments @PSBoundParameters
- $arguments = "tool uninstall $installArgument"
+ $arguments = "tool uninstall $installArgument"
Write-Verbose -Message "Uninstalling dotnet tool package with arguments: $arguments"
-
+
Invoke-DotNet -Command $arguments
}
-function Invoke-DotNet
-{
+function Invoke-DotNet {
param (
[Parameter(Mandatory = $true)]
[string] $Command
)
- try
- {
+ try {
Invoke-Expression "& `"$DotNetCliPath`" $Command"
- }
- catch
- {
+ } catch {
throw "Executing dotnet.exe with {$Command} failed."
}
}
@@ -365,25 +321,24 @@ $DotNetCliPath = Get-DotNetPath
This example gets the current state of the .NET tool package 'GitVersion.Tool' in the default directory.
.EXAMPLE
- PS C:\> Invoke-DscResource -ModuleName Microsoft.DotNet.Dsc -Name DotNetToolPackage -Method Set -Property @{
- PackageId = 'GitVersion.Tool';
- Version = '5.6.8';
+ PS C:\> Invoke-DscResource -ModuleName Microsoft.DotNet.Dsc -Name DotNetToolPackage -Method Set -Property @{
+ PackageId = 'GitVersion.Tool';
+ Version = '5.6.8';
}
-
+
This example installs the .NET tool package 'GitVersion.Tool' version 5.6.8 in the default directory.
.EXAMPLE
- PS C:\> Invoke-DscResource -ModuleName Microsoft.DotNet.Dsc -Name DotNetToolPackage -Method Set -Property @{
- PackageId = 'PowerShell';
- Prerelease = $true;
- ToolPathDirectory = 'C:\tools';
+ PS C:\> Invoke-DscResource -ModuleName Microsoft.DotNet.Dsc -Name DotNetToolPackage -Method Set -Property @{
+ PackageId = 'PowerShell';
+ Prerelease = $true;
+ ToolPathDirectory = 'C:\tools';
}
This example installs the prerelease version of the .NET tool package 'PowerShell' in the 'C:\tools' directory.
#>
[DSCResource()]
-class DotNetToolPackage
-{
+class DotNetToolPackage {
[DscProperty(Key)]
[string] $PackageId
@@ -404,13 +359,11 @@ class DotNetToolPackage
static [hashtable] $InstalledPackages
- DotNetToolPackage()
- {
+ DotNetToolPackage() {
[DotNetToolPackage]::GetInstalledPackages()
}
- DotNetToolPackage([string] $PackageId, [string] $Version, [string[]] $Commands, [bool] $PreRelease, [string] $ToolPathDirectory, [bool] $Exist)
- {
+ DotNetToolPackage([string] $PackageId, [string] $Version, [string[]] $Commands, [bool] $PreRelease, [string] $ToolPathDirectory, [bool] $Exist) {
$this.PackageId = $PackageId
$this.Version = $Version
$this.Commands = $Commands
@@ -419,8 +372,7 @@ class DotNetToolPackage
$this.Exist = $Exist
}
- [DotNetToolPackage] Get()
- {
+ [DotNetToolPackage] Get() {
# get the properties of the object currently set
$properties = $this.ToHashTable()
@@ -430,23 +382,20 @@ class DotNetToolPackage
# current state
$currentState = [DotNetToolPackage]::InstalledPackages[$this.PackageId]
- if ($null -ne $currentState)
- {
- if ($this.Version -and ($this.Version -ne $currentState.Version))
- {
+ if ($null -ne $currentState) {
+ if ($this.Version -and ($this.Version -ne $currentState.Version)) {
# See treatment: https://learn.microsoft.com/en-us/nuget/concepts/package-versioning?tabs=semver20sort#normalized-version-numbers
# in this case, we misuse revision if beta,alpha, rc are present and grab the highest revision
- $installedVersion = Get-Semver -Version $currentState.Version
- $currentVersion = Get-Semver -Version $this.Version
- if ($currentVersion -ne $installedVersion)
- {
+ $installedVersion = Get-SemVer -version $currentState.Version
+ $currentVersion = Get-SemVer -version $this.Version
+ if ($currentVersion -ne $installedVersion) {
$currentState.Exist = $false
}
}
return $currentState
}
-
+
return [DotNetToolPackage]@{
PackageId = $this.PackageId
Version = $this.Version
@@ -457,155 +406,123 @@ class DotNetToolPackage
}
}
- Set()
- {
- if ($this.Test())
- {
+ Set() {
+ if ($this.Test()) {
return
}
$currentPackage = [DotNetToolPackage]::InstalledPackages[$this.PackageId]
- if ($currentPackage -and $this.Exist)
- {
- if ($this.Version -lt $currentPackage.Version)
- {
+ if ($currentPackage -and $this.Exist) {
+ if ($this.Version -lt $currentPackage.Version) {
$this.ReInstall($false)
- }
- else
- {
+ } else {
$this.Upgrade($false)
}
- }
- elseif ($this.Exist)
- {
+ } elseif ($this.Exist) {
$this.Install($false)
- }
- else
- {
+ } else {
$this.Uninstall($false)
}
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if ($currentState.Exist -ne $this.Exist)
- {
+ if ($currentState.Exist -ne $this.Exist) {
return $false
}
- if ($null -ne $this.Version -or $this.Version -ne $currentState.Version -and $this.PreRelease -ne $currentState.PreRelease)
- {
+ if ($null -ne $this.Version -or $this.Version -ne $currentState.Version -and $this.PreRelease -ne $currentState.PreRelease) {
return $false
}
return $true
}
- static [DotNetToolPackage[]] Export()
- {
+ static [DotNetToolPackage[]] Export() {
return [DotNetToolPackage]::Export(@{})
}
- static [DotNetToolPackage[]] Export([hashtable] $filterProperties)
- {
+ static [DotNetToolPackage[]] Export([hashtable] $filterProperties) {
$packages = Get-InstalledDotNetToolPackages @filterProperties
return $packages
}
#region DotNetToolPackage helper functions
- static [void] GetInstalledPackages()
- {
+ static [void] GetInstalledPackages() {
[DotNetToolPackage]::InstalledPackages = @{}
- foreach ($extension in [DotNetToolPackage]::Export())
- {
+ foreach ($extension in [DotNetToolPackage]::Export()) {
[DotNetToolPackage]::InstalledPackages[$extension.PackageId] = $extension
}
}
- static [void] GetInstalledPackages([hashtable] $filterProperties)
- {
+ static [void] GetInstalledPackages([hashtable] $filterProperties) {
[DotNetToolPackage]::InstalledPackages = @{}
- foreach ($extension in [DotNetToolPackage]::Export($filterProperties))
- {
+ foreach ($extension in [DotNetToolPackage]::Export($filterProperties)) {
[DotNetToolPackage]::InstalledPackages[$extension.PackageId] = $extension
}
}
- [void] Upgrade([bool] $preTest)
- {
- if ($preTest -and $this.Test())
- {
+ [void] Upgrade([bool] $preTest) {
+ if ($preTest -and $this.Test()) {
return
}
- $params = $this.ToHashTable()
+ $params = $this.ToHashTable()
- Update-DotNetToolpackage @params
+ Update-DotNetToolPackage @params
[DotNetToolPackage]::GetInstalledPackages()
}
- [void] ReInstall([bool] $preTest)
- {
- if ($preTest -and $this.Test())
- {
+ [void] ReInstall([bool] $preTest) {
+ if ($preTest -and $this.Test()) {
return
}
-
+
$this.Uninstall($false)
$this.Install($false)
[DotNetToolPackage]::GetInstalledPackages()
}
- [void] Install([bool] $preTest)
- {
- if ($preTest -and $this.Test())
- {
+ [void] Install([bool] $preTest) {
+ if ($preTest -and $this.Test()) {
return
}
- $params = $this.ToHashTable()
+ $params = $this.ToHashTable()
- Install-DotNetToolpackage @params
+ Install-DotNetToolPackage @params
[DotNetToolPackage]::GetInstalledPackages()
}
- [void] Install()
- {
+ [void] Install() {
$this.Install($true)
}
- [void] Uninstall([bool] $preTest)
- {
+ [void] Uninstall([bool] $preTest) {
$params = $this.ToHashTable()
$uninstallParams = @{
PackageId = $this.PackageId
}
- if ($params.ContainsKey('ToolPathDirectory'))
- {
+ if ($params.ContainsKey('ToolPathDirectory')) {
$uninstallParams.Add('ToolPathDirectory', $params['ToolPathDirectory'])
}
- Uninstall-DotNetToolpackage @uninstallParams
+ Uninstall-DotNetToolPackage @uninstallParams
[DotNetToolPackage]::GetInstalledPackages()
}
- [void] Uninstall()
- {
+ [void] Uninstall() {
$this.Uninstall($true)
}
- [hashtable] ToHashTable()
- {
+ [hashtable] ToHashTable() {
$parameters = @{}
- foreach ($property in $this.PSObject.Properties)
- {
- if (-not ([string]::IsNullOrEmpty($property.Value)))
- {
+ foreach ($property in $this.PSObject.Properties) {
+ if (-not ([string]::IsNullOrEmpty($property.Value))) {
$parameters[$property.Name] = $property.Value
}
}
@@ -614,4 +531,4 @@ class DotNetToolPackage
}
#endregion DotNetToolPackage helper functions
}
-#endregion Classes
\ No newline at end of file
+#endregion Classes
diff --git a/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psd1 b/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psd1
index b04d7a3f..0df7d574 100644
--- a/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psd1
+++ b/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psd1
@@ -1,21 +1,21 @@
@{
- RootModule = 'Microsoft.VSCode.Dsc.psm1'
- ModuleVersion = '0.1.0'
- GUID = 'baf2c585-d931-4089-8500-93a5b8de1741'
- Author = 'Microsoft Corporation'
- CompanyName = 'Microsoft Corporation'
- Copyright = '(c) Microsoft Corporation. All rights reserved.'
- Description = 'DSC Resource for Visual Studio Code'
- PowerShellVersion = '7.2'
+ RootModule = 'Microsoft.VSCode.Dsc.psm1'
+ ModuleVersion = '0.1.0'
+ GUID = 'baf2c585-d931-4089-8500-93a5b8de1741'
+ Author = 'Microsoft Corporation'
+ CompanyName = 'Microsoft Corporation'
+ Copyright = '(c) Microsoft Corporation. All rights reserved.'
+ Description = 'DSC Resource for Visual Studio Code'
+ PowerShellVersion = '7.2'
DscResourcesToExport = @(
'VSCodeExtension'
)
- PrivateData = @{
+ PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
- Tags = @(
+ Tags = @(
'PSDscResource_VSCodeExtension'
- )
+ )
# Prerelease string of this module
Prerelease = 'alpha'
diff --git a/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1 b/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1
index cf70bd41..ea43f49d 100644
--- a/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1
+++ b/resources/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.psm1
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
-$ErrorActionPreference = "Stop"
+$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
#region Functions
@@ -11,49 +11,42 @@ function Get-VSCodeCLIPath {
)
# Product Codes for VSCode and VSCode Insider:
- $vsCodeUserProductCode = "{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1"
- $vsCodeMachineProductCode = "{EA457B21-F73E-494C-ACAB-524FDE069978}_is1"
+ $vsCodeUserProductCode = '{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1'
+ $vsCodeMachineProductCode = '{EA457B21-F73E-494C-ACAB-524FDE069978}_is1'
- $vsCodeInsidersUserProductCode = "{217B4C08-948D-4276-BFBB-BEE930AE5A2C}_is1"
- $vsCodeInsidersMachineProductCode = "{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1"
+ $vsCodeInsidersUserProductCode = '{217B4C08-948D-4276-BFBB-BEE930AE5A2C}_is1'
+ $vsCodeInsidersMachineProductCode = '{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1'
# Note: WOW6432 registry not checked as no uninstall entry was found.
- $userUninstallRegistry = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
- $machineUninstallRegistry = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
- $installLocationProperty = "InstallLocation"
+ $userUninstallRegistry = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall'
+ $machineUninstallRegistry = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall'
+ $installLocationProperty = 'InstallLocation'
- if ($Insiders)
- {
- $cmdPath = "bin\code-insiders.cmd"
+ if ($Insiders) {
+ $cmdPath = 'bin\code-insiders.cmd'
$insidersUserInstallLocation = TryGetRegistryValue -Key "$($userUninstallRegistry)\$($vsCodeInsidersUserProductCode)" -Property $installLocationProperty
- if ($insidersUserInstallLocation)
- {
+ if ($insidersUserInstallLocation) {
return $insidersUserInstallLocation + $cmdPath
}
$insidersMachineInstallLocation = TryGetRegistryValue -Key "$($machineUninstallRegistry)\$($vsCodeInsidersMachineProductCode)" -Property $installLocationProperty
- if ($insidersMachineInstallLocation)
- {
+ if ($insidersMachineInstallLocation) {
return $insidersMachineInstallLocation + $cmdPath
}
- }
- else
- {
- $cmdPath = "bin\code.cmd"
+ } else {
+ $cmdPath = 'bin\code.cmd'
$codeUserInstallLocation = TryGetRegistryValue -Key "$($userUninstallRegistry)\$($vsCodeUserProductCode)" -Property $installLocationProperty
- if ($codeUserInstallLocation)
- {
+ if ($codeUserInstallLocation) {
return $codeUserInstallLocation + $cmdPath
}
$codeMachineInstallLocation = TryGetRegistryValue -Key "$($machineUninstallRegistry)\$($vsCodeMachineProductCode)" -Property $installLocationProperty
- if ($codeMachineInstallLocation)
- {
+ if ($codeMachineInstallLocation) {
return $codeMachineInstallLocation + $cmdPath
}
}
- throw "VSCode is not installed."
+ throw 'VSCode is not installed.'
}
function Install-VSCodeExtension {
@@ -64,11 +57,11 @@ function Install-VSCodeExtension {
[Parameter(ValueFromPipelineByPropertyName)]
[string]$Version
)
-
+
begin {
function Get-VSCodeExtensionInstallArgument {
param([string]$Name, [string]$Version)
-
+
if ([string]::IsNullOrEmpty($Version)) {
return $Name
}
@@ -79,7 +72,7 @@ function Install-VSCodeExtension {
) -join '@'
}
}
-
+
process {
$installArgument = Get-VSCodeExtensionInstallArgument @PSBoundParameters
Invoke-VSCode -Command "--install-extension $installArgument"
@@ -92,7 +85,7 @@ function Uninstall-VSCodeExtension {
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[string]$Name
)
-
+
Invoke-VSCode -Command "--uninstall-extension $($this.Name)"
}
@@ -104,35 +97,28 @@ function Invoke-VSCode {
try {
Invoke-Expression "& `"$VSCodeCLIPath`" $Command"
- }
- catch {
+ } catch {
throw ("Executing {0} with {$Command} failed." -f $VSCodeCLIPath)
}
}
-function TryGetRegistryValue{
+function TryGetRegistryValue {
param (
[Parameter(Mandatory = $true)]
[string]$Key,
[Parameter(Mandatory = $true)]
[string]$Property
- )
+ )
- if (Test-Path -Path $Key)
- {
- try
- {
- return (Get-ItemProperty -Path $Key | Select-Object -ExpandProperty $Property)
- }
- catch
- {
+ if (Test-Path -Path $Key) {
+ try {
+ return (Get-ItemProperty -Path $Key | Select-Object -ExpandProperty $Property)
+ } catch {
Write-Verbose "Property `"$($Property)`" could not be found."
}
- }
- else
- {
- Write-Verbose "Registry key does not exist."
+ } else {
+ Write-Verbose 'Registry key does not exist.'
}
}
#endregion Functions
@@ -187,7 +173,7 @@ function TryGetRegistryValue{
Insiders = $true
}
PS C:\> Invoke-DscResource -Name VSCodeExtension -Method Set -Property $params -ModuleName Microsoft.VSCode.Dsc
-
+
This installs the latest version of the Visual Studio Code extension 'ms-python.python' for the Insiders version of Visual Studio Code
#>
[DSCResource()]
@@ -214,21 +200,18 @@ class VSCodeExtension {
$this.Version = $Version
}
- [VSCodeExtension[]] Export([bool]$Insiders)
- {
+ [VSCodeExtension[]] Export([bool]$Insiders) {
if ($Insiders) {
$script:VSCodeCLIPath = Get-VSCodeCLIPath -Insiders
- }
- else {
+ } else {
$script:VSCodeCLIPath = Get-VSCodeCLIPath
}
- $extensionList = (Invoke-VSCode -Command "--list-extensions --show-versions") -Split [Environment]::NewLine
+ $extensionList = (Invoke-VSCode -Command '--list-extensions --show-versions') -Split [Environment]::NewLine
$results = [VSCodeExtension[]]::new($extensionList.length)
-
- for ($i = 0; $i -lt $extensionList.length; $i++)
- {
+
+ for ($i = 0; $i -lt $extensionList.length; $i++) {
$extensionName, $extensionVersion = $extensionList[$i] -Split '@'
$results[$i] = [VSCodeExtension]::new($extensionName, $extensionVersion)
}
@@ -243,11 +226,11 @@ class VSCodeExtension {
if ($null -ne $currentState) {
return [VSCodeExtension]::InstalledExtensions[$this.Name]
}
-
+
return [VSCodeExtension]@{
- Name = $this.Name
- Version = $this.Version
- Exist = $false
+ Name = $this.Name
+ Version = $this.Version
+ Exist = $false
Insiders = $this.Insiders
}
}
@@ -272,14 +255,13 @@ class VSCodeExtension {
if ($this.Exist) {
$this.Install($false)
- }
- else {
+ } else {
$this.Uninstall($false)
}
}
-#region VSCodeExtension helper functions
- static [void] GetInstalledExtensions([bool]$Insiders) {
+ #region VSCodeExtension helper functions
+ static [void] GetInstalledExtensions([bool]$Insiders) {
[VSCodeExtension]::InstalledExtensions = @{}
$extension = [VSCodeExtension]::new()
@@ -310,6 +292,6 @@ class VSCodeExtension {
[void] Uninstall() {
$this.Uninstall($true)
}
-#endregion VSCodeExtension helper functions
+ #endregion VSCodeExtension helper functions
}
#endregion DSCResources
diff --git a/resources/Microsoft.Windows.Developer/Microsoft.Windows.Developer.psm1 b/resources/Microsoft.Windows.Developer/Microsoft.Windows.Developer.psm1
index 7eedeacb..40fd1ecd 100644
--- a/resources/Microsoft.Windows.Developer/Microsoft.Windows.Developer.psm1
+++ b/resources/Microsoft.Windows.Developer/Microsoft.Windows.Developer.psm1
@@ -1,39 +1,34 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
-$ErrorActionPreference = "Stop"
+$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
-enum Ensure
-{
+enum Ensure {
Absent
Present
}
-enum Alignment
-{
+enum Alignment {
KeepCurrentValue
Left
Middle
}
-enum ShowHideFeature
-{
+enum ShowHideFeature {
KeepCurrentValue
Hide
Show
}
-enum HideTaskBarLabelsBehavior
-{
+enum HideTaskBarLabelsBehavior {
KeepCurrentValue
Always
WhenFull
Never
}
-enum SearchBoxMode
-{
+enum SearchBoxMode {
KeepCurrentValue
Hide
ShowIconOnly
@@ -41,8 +36,7 @@ enum SearchBoxMode
ShowIconAndLabel
}
-enum AdminConsentPromptBehavior
-{
+enum AdminConsentPromptBehavior {
KeepCurrentValue
NoCredOrConsentRequired
RequireCredOnSecureDesktop
@@ -54,8 +48,7 @@ enum AdminConsentPromptBehavior
#region DSCResources
[DSCResource()]
-class DeveloperMode
-{
+class DeveloperMode {
# Key required. Do not set.
[DscProperty(Key)]
[string]$SID
@@ -66,8 +59,7 @@ class DeveloperMode
[DscProperty(NotConfigurable)]
[bool] $IsEnabled
- [DeveloperMode] Get()
- {
+ [DeveloperMode] Get() {
$this.IsEnabled = IsDeveloperModeEnabled
return @{
@@ -76,29 +68,22 @@ class DeveloperMode
}
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if ($currentState.Ensure -eq [Ensure]::Present)
- {
+ if ($currentState.Ensure -eq [Ensure]::Present) {
return $currentState.IsEnabled
- }
- else
- {
+ } else {
return $currentState.IsEnabled -eq $false
}
}
- [void] Set()
- {
- if (!$this.Test())
- {
+ [void] Set() {
+ if (!$this.Test()) {
$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = New-Object -TypeName 'System.Security.Principal.WindowsPrincipal' -ArgumentList @( $windowsIdentity )
-
- if (-not $windowsPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
- {
- throw "Toggling Developer Mode requires this resource to be run as an Administrator."
+
+ if (-not $windowsPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)) {
+ throw 'Toggling Developer Mode requires this resource to be run as an Administrator.'
}
$shouldEnable = $this.Ensure -eq [Ensure]::Present
@@ -109,8 +94,7 @@ class DeveloperMode
}
[DSCResource()]
-class OsVersion
-{
+class OsVersion {
# Key required. Do not set.
[DscProperty(Key)]
[string]$SID
@@ -121,11 +105,9 @@ class OsVersion
[DscProperty(NotConfigurable)]
[string] $OsVersion
- [OsVersion] Get()
- {
+ [OsVersion] Get() {
$parsedVersion = $null
- if (![System.Version]::TryParse($this.MinVersion, [ref]$parsedVersion))
- {
+ if (![System.Version]::TryParse($this.MinVersion, [ref]$parsedVersion)) {
throw "'$($this.MinVersion)' is not a valid Version string."
}
@@ -137,34 +119,28 @@ class OsVersion
}
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
return [System.Version]$currentState.OsVersion -ge [System.Version]$currentState.MinVersion
}
- [void] Set()
- {
+ [void] Set() {
# This resource is only for asserting the os version requirement.
}
}
-if ([string]::IsNullOrEmpty($env:TestRegistryPath))
-{
+if ([string]::IsNullOrEmpty($env:TestRegistryPath)) {
$global:ExplorerRegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\'
$global:PersonalizeRegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\'
$global:SearchRegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search\'
$global:UACRegistryPath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\'
$global:RemoteDesktopRegistryPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server'
-}
-else
-{
+} else {
$global:ExplorerRegistryPath = $global:PersonalizeRegistryPath = $global:SearchRegistryPath = $global:UACRegistryPath = $global:RemoteDesktopRegistryPath = $env:TestRegistryPath
}
[DSCResource()]
-class Taskbar
-{
+class Taskbar {
[DscProperty()] [Alignment] $Alignment = [Alignment]::KeepCurrentValue
[DscProperty()] [HideTaskBarLabelsBehavior] $HideLabelsMode = [HideTaskBarLabelsBehavior]::KeepCurrentValue
[DscProperty()] [SearchBoxMode] $SearchboxMode = [SearchBoxMode]::KeepCurrentValue
@@ -181,31 +157,23 @@ class Taskbar
hidden [string] $ShowTaskViewButton = 'ShowTaskViewButton'
hidden [string] $TaskbarDa = 'TaskbarDa'
- [Taskbar] Get()
- {
+ [Taskbar] Get() {
$currentState = [Taskbar]::new()
# Alignment
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.TaskbarAl))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.TaskbarAl)) {
$currentState.Alignment = [Alignment]::Middle
- }
- else
- {
+ } else {
$value = [int](Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.TaskbarAl)
$currentState.Alignment = $value -eq 0 ? [Alignment]::Left : [Alignment]::Middle
}
# HideTaskBarLabels
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.TaskbarGlomLevel))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.TaskbarGlomLevel)) {
$currentState.HideLabelsMode = [HideTaskBarLabelsBehavior]::Always
- }
- else
- {
+ } else {
$value = [int](Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.TaskbarGlomLevel)
- $currentState.HideLabelsMode = switch ($value)
- {
+ $currentState.HideLabelsMode = switch ($value) {
0 { [HideTaskBarLabelsBehavior]::Always }
1 { [HideTaskBarLabelsBehavior]::WhenFull }
2 { [HideTaskBarLabelsBehavior]::Never }
@@ -213,15 +181,11 @@ class Taskbar
}
# TaskbarSearchboxMode
- if (-not(DoesRegistryKeyPropertyExist -Path $global:SearchRegistryPath -Name $this.SearchboxTaskbarMode))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:SearchRegistryPath -Name $this.SearchboxTaskbarMode)) {
$currentState.SearchboxMode = [SearchBoxMode]::SearchBox
- }
- else
- {
+ } else {
$value = [int](Get-ItemPropertyValue -Path $global:SearchRegistryPath -Name $this.SearchboxTaskbarMode)
- $currentState.SearchboxMode = switch ($value)
- {
+ $currentState.SearchboxMode = switch ($value) {
0 { [SearchBoxMode]::Hide }
1 { [SearchBoxMode]::ShowIconOnly }
2 { [SearchBoxMode]::SearchBox }
@@ -230,25 +194,19 @@ class Taskbar
}
# TaskViewButton
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.ShowTaskViewButton))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.ShowTaskViewButton)) {
# Default behavior if registry key not found.
$currentState.TaskViewButton = [ShowHideFeature]::Show
- }
- else
- {
+ } else {
$value = [int](Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.ShowTaskViewButton)
$currentState.TaskViewButton = $value -eq 0 ? [ShowHideFeature]::Hide : [ShowHideFeature]::Show
}
# WidgetsButton
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.TaskbarDa))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.TaskbarDa)) {
# Default behavior if registry key not found.
$currentState.WidgetsButton = [ShowHideFeature]::Show
- }
- else
- {
+ } else {
$value = [int](Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.TaskbarDa)
$currentState.WidgetsButton = $value -eq 0 ? [ShowHideFeature]::Hide : [ShowHideFeature]::Show
}
@@ -256,50 +214,40 @@ class Taskbar
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
-
- if ($this.Alignment -ne [Alignment]::KeepCurrentValue -and $currentState.Alignment -ne $this.Alignment)
- {
+
+ if ($this.Alignment -ne [Alignment]::KeepCurrentValue -and $currentState.Alignment -ne $this.Alignment) {
return $false
}
- if ($this.HideLabelsMode -ne [HideTaskBarLabelsBehavior]::KeepCurrentValue -and $currentState.HideLabelsMode -ne $this.HideLabelsMode)
- {
+ if ($this.HideLabelsMode -ne [HideTaskBarLabelsBehavior]::KeepCurrentValue -and $currentState.HideLabelsMode -ne $this.HideLabelsMode) {
return $false
}
- if ($this.SearchboxMode -ne [SearchBoxMode]::KeepCurrentValue -and $currentState.SearchboxMode -ne $this.SearchboxMode)
- {
+ if ($this.SearchboxMode -ne [SearchBoxMode]::KeepCurrentValue -and $currentState.SearchboxMode -ne $this.SearchboxMode) {
return $false
}
- if ($this.TaskViewButton -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.TaskViewButton -ne $this.TaskViewButton)
- {
+ if ($this.TaskViewButton -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.TaskViewButton -ne $this.TaskViewButton) {
return $false
}
- if ($this.WidgetsButton -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.WidgetsButton -ne $this.WidgetsButton)
- {
+ if ($this.WidgetsButton -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.WidgetsButton -ne $this.WidgetsButton) {
return $false
}
return $true
}
- [void] Set()
- {
- if ($this.Alignment -ne [Alignment]::KeepCurrentValue)
- {
+ [void] Set() {
+ if ($this.Alignment -ne [Alignment]::KeepCurrentValue) {
$desiredAlignment = $this.Alignment -eq [Alignment]::Left ? 0 : 1
Set-ItemProperty -Path $global:ExplorerRegistryPath -Name $this.TaskbarAl -Value $desiredAlignment
}
- if ($this.HideLabelsMode -ne [HideTaskBarLabelsBehavior]::KeepCurrentValue)
- {
- $desiredHideLabelsBehavior = switch ($this.HideLabelsMode)
- {
+ if ($this.HideLabelsMode -ne [HideTaskBarLabelsBehavior]::KeepCurrentValue) {
+ $desiredHideLabelsBehavior = switch ($this.HideLabelsMode) {
Always { 0 }
WhenFull { 1 }
Never { 2 }
@@ -308,33 +256,28 @@ class Taskbar
Set-ItemProperty -Path $global:ExplorerRegistryPath -Name $this.TaskbarGlomLevel -Value $desiredHideLabelsBehavior
}
- if ($this.SearchboxMode -ne [SearchBoxMode]::KeepCurrentValue)
- {
- $desiredSearchboxMode = switch ([SearchBoxMode]($this.SearchboxMode))
- {
+ if ($this.SearchboxMode -ne [SearchBoxMode]::KeepCurrentValue) {
+ $desiredSearchboxMode = switch ([SearchBoxMode]($this.SearchboxMode)) {
Hide { 0 }
ShowIconOnly { 1 }
SearchBox { 2 }
ShowIconAndLabel { 3 }
}
-
+
Set-ItemProperty -Path $global:SearchRegistryPath -Name $this.SearchboxTaskbarMode -Value $desiredSearchboxMode
}
- if ($this.TaskViewButton -ne [ShowHideFeature]::KeepCurrentValue)
- {
+ if ($this.TaskViewButton -ne [ShowHideFeature]::KeepCurrentValue) {
$desiredTaskViewButtonState = $this.TaskViewButton -eq [ShowHideFeature]::Show ? 1 : 0
Set-ItemProperty -Path $global:ExplorerRegistryPath -Name $this.ShowTaskViewButton -Value $desiredTaskViewButtonState
}
- if ($this.WidgetsButton -ne [ShowHideFeature]::KeepCurrentValue)
- {
+ if ($this.WidgetsButton -ne [ShowHideFeature]::KeepCurrentValue) {
$desiredWidgetsButtonState = $this.WidgetsButton -eq [ShowHideFeature]::Show ? 1 : 0
Set-ItemProperty -Path $global:ExplorerRegistryPath -Name $this.TaskBarDa -Value $desiredWidgetsButtonState
}
- if ($this.RestartExplorer)
- {
+ if ($this.RestartExplorer) {
# Explorer needs to be restarted to enact the changes for HideLabelsMode.
taskkill /F /IM explorer.exe
Start-Process explorer.exe
@@ -343,8 +286,7 @@ class Taskbar
}
[DSCResource()]
-class WindowsExplorer
-{
+class WindowsExplorer {
[DscProperty()] [ShowHideFeature] $FileExtensions = [ShowHideFeature]::KeepCurrentValue
[DscProperty()] [ShowHideFeature] $HiddenFiles = [ShowHideFeature]::KeepCurrentValue
[DscProperty()] [ShowHideFeature] $ItemCheckBoxes = [ShowHideFeature]::KeepCurrentValue
@@ -357,39 +299,29 @@ class WindowsExplorer
hidden [string] $Hidden = 'Hidden'
hidden [string] $AutoCheckSelect = 'AutoCheckSelect'
- [WindowsExplorer] Get()
- {
+ [WindowsExplorer] Get() {
$currentState = [WindowsExplorer]::new()
# FileExtensions
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.HideFileExt))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.HideFileExt)) {
$currentState.FileExtensions = [ShowHideFeature]::Show
- }
- else
- {
+ } else {
$value = Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.HideFileExt
$currentState.FileExtensions = $value -eq 1 ? [ShowHideFeature]::Hide : [ShowHideFeature]::Show
}
# HiddenFiles
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.Hidden))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.Hidden)) {
$currentState.HiddenFiles = [ShowHideFeature]::Show
- }
- else
- {
+ } else {
$value = Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.Hidden
$currentState.HiddenFiles = $value -eq 1 ? [ShowHideFeature]::Show : [ShowHideFeature]::Hide
}
# ItemCheckboxes
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.AutoCheckSelect))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.AutoCheckSelect)) {
$currentState.ItemCheckBoxes = [ShowHideFeature]::Show
- }
- else
- {
+ } else {
$value = Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.AutoCheckSelect
$currentState.ItemCheckBoxes = $value -eq 1 ? [ShowHideFeature]::Show : [ShowHideFeature]::Hide
}
@@ -398,50 +330,41 @@ class WindowsExplorer
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
-
- if ($this.FileExtensions -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.FileExtensions -ne $this.FileExtensions)
- {
+
+ if ($this.FileExtensions -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.FileExtensions -ne $this.FileExtensions) {
return $false
}
- if ($this.HiddenFiles -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.HiddenFiles -ne $this.HiddenFiles)
- {
+ if ($this.HiddenFiles -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.HiddenFiles -ne $this.HiddenFiles) {
return $false
}
- if ($this.ItemCheckBoxes -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.ItemCheckBoxes -ne $this.ItemCheckBoxes)
- {
+ if ($this.ItemCheckBoxes -ne [ShowHideFeature]::KeepCurrentValue -and $currentState.ItemCheckBoxes -ne $this.ItemCheckBoxes) {
return $false
}
return $true
}
- [void] Set()
- {
- if ($this.FileExtensions -ne [ShowHideFeature]::KeepCurrentValue)
- {
+ [void] Set() {
+ if ($this.FileExtensions -ne [ShowHideFeature]::KeepCurrentValue) {
$desiredFileExtensions = $this.FileExtensions -eq [ShowHideFeature]::Show ? 0 : 1
Set-ItemProperty -Path $global:ExplorerRegistryPath -Name $this.HideFileExt -Value $desiredFileExtensions
}
- if ($this.HiddenFiles -ne [ShowHideFeature]::KeepCurrentValue)
- {
+ if ($this.HiddenFiles -ne [ShowHideFeature]::KeepCurrentValue) {
$desiredHiddenFiles = $this.HiddenFiles -eq [ShowHideFeature]::Show ? 1 : 0
Set-ItemProperty -Path $global:ExplorerRegistryPath -Name $this.Hidden -Value $desiredHiddenFiles
}
- if ($this.ItemCheckBoxes -ne [ShowHideFeature]::KeepCurrentValue)
- {
+ if ($this.ItemCheckBoxes -ne [ShowHideFeature]::KeepCurrentValue) {
$desiredItemCheckBoxes = $this.ItemCheckBoxes -eq [ShowHideFeature]::Show ? 1 : 0
Set-ItemProperty -Path $global:ExplorerRegistryPath -Name $this.AutoCheckSelect -Value $desiredItemCheckBoxes
}
- if ($this.RestartExplorer)
- {
+ if ($this.RestartExplorer) {
# Explorer needs to be restarted to enact the changes.
taskkill /F /IM explorer.exe
Start-Process explorer.exe
@@ -450,8 +373,7 @@ class WindowsExplorer
}
[DSCResource()]
-class UserAccessControl
-{
+class UserAccessControl {
# Key required. Do not set.
[DscProperty(Key)]
[string]$SID
@@ -463,19 +385,14 @@ class UserAccessControl
# NOTE: 'EnableLUA' is another registry key that disables UAC prompts, but requires a reboot and opens everything in admin mode.
- [UserAccessControl] Get()
- {
+ [UserAccessControl] Get() {
$currentState = [UserAccessControl]::new()
- if (-not(DoesRegistryKeyPropertyExist -Path $global:UACRegistryPath -Name $this.ConsentPromptBehaviorAdmin))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:UACRegistryPath -Name $this.ConsentPromptBehaviorAdmin)) {
$currentState.AdminConsentPromptBehavior = [AdminConsentPromptBehavior]::RequireConsentForNonWindowsBinaries
- }
- else
- {
+ } else {
$value = [int](Get-ItemPropertyValue -Path $global:UACRegistryPath -Name $this.ConsentPromptBehaviorAdmin)
- $currentState.AdminConsentPromptBehavior = switch ($value)
- {
+ $currentState.AdminConsentPromptBehavior = switch ($value) {
0 { [AdminConsentPromptBehavior]::NoCredOrConsentRequired }
1 { [AdminConsentPromptBehavior]::RequireCredOnSecureDesktop }
2 { [AdminConsentPromptBehavior]::RequireConsentOnSecureDesktop }
@@ -488,24 +405,19 @@ class UserAccessControl
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if ($this.AdminConsentPromptBehavior -ne [AdminConsentPromptBehavior]::KeepCurrentValue -and $currentState.AdminConsentPromptBehavior -ne $this.AdminConsentPromptBehavior)
- {
+ if ($this.AdminConsentPromptBehavior -ne [AdminConsentPromptBehavior]::KeepCurrentValue -and $currentState.AdminConsentPromptBehavior -ne $this.AdminConsentPromptBehavior) {
return $false
}
return $true
}
- [void] Set()
- {
- if ($this.AdminConsentPromptBehavior -ne [AdminConsentPromptBehavior]::KeepCurrentValue)
- {
- $desiredState = switch ([AdminConsentPromptBehavior]($this.AdminConsentPromptBehavior))
- {
+ [void] Set() {
+ if ($this.AdminConsentPromptBehavior -ne [AdminConsentPromptBehavior]::KeepCurrentValue) {
+ $desiredState = switch ([AdminConsentPromptBehavior]($this.AdminConsentPromptBehavior)) {
NoCredOrConsentRequired { 0 }
RequireCredOnSecureDesktop { 1 }
RequireConsentOnSecureDesktop { 2 }
@@ -520,8 +432,7 @@ class UserAccessControl
}
[DSCResource()]
-class EnableDarkMode
-{
+class EnableDarkMode {
# Key required. Do not set.
[DscProperty(Key)]
[string]$SID
@@ -535,40 +446,35 @@ class EnableDarkMode
hidden [string] $AppsUseLightTheme = 'AppsUseLightTheme'
hidden [string] $SystemUsesLightTheme = 'SystemUsesLightTheme'
- [EnableDarkMode] Get()
- {
+ [EnableDarkMode] Get() {
$exists = (DoesRegistryKeyPropertyExist -Path $global:PersonalizeRegistryPath -Name $this.AppsUseLightTheme) -and (DoesRegistryKeyPropertyExist -Path $global:PersonalizeRegistryPath -Name $this.SystemUsesLightTheme)
- if (-not($exists))
- {
+ if (-not($exists)) {
return @{
Ensure = [Ensure]::Absent
}
}
- $appsUseLightModeValue = Get-ItemPropertyValue -Path $global:PersonalizeRegistryPath -Name $this.AppsUseLightTheme
- $systemUsesLightModeValue = Get-ItemPropertyValue -Path $global:PersonalizeRegistryPath -Name $this.SystemUsesLightTheme
+ $appsUseLightModeValue = Get-ItemPropertyValue -Path $global:PersonalizeRegistryPath -Name $this.AppsUseLightTheme
+ $systemUsesLightModeValue = Get-ItemPropertyValue -Path $global:PersonalizeRegistryPath -Name $this.SystemUsesLightTheme
$isDarkModeEnabled = if ($appsUseLightModeValue -eq 0 -and $systemUsesLightModeValue -eq 0) { [Ensure]::Present } else { [Ensure]::Absent }
-
+
return @{
Ensure = $isDarkModeEnabled
}
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
return $currentState.Ensure -eq $this.Ensure
}
- [void] Set()
- {
+ [void] Set() {
$value = if ($this.Ensure -eq [Ensure]::Present) { 0 } else { 1 }
Set-ItemProperty -Path $global:PersonalizeRegistryPath -Name $this.AppsUseLightTheme -Value $value
Set-ItemProperty -Path $global:PersonalizeRegistryPath -Name $this.SystemUsesLightTheme -Value $value
- if ($this.RestartExplorer)
- {
+ if ($this.RestartExplorer) {
# Explorer needs to be restarted to enact the changes.
Stop-Process -ProcessName Explorer
}
@@ -576,8 +482,7 @@ class EnableDarkMode
}
[DSCResource()]
-class ShowSecondsInClock
-{
+class ShowSecondsInClock {
# Key required. Do not set.
[DscProperty(Key)]
[string]$SID
@@ -587,39 +492,34 @@ class ShowSecondsInClock
hidden [string] $ShowSecondsInSystemClock = 'ShowSecondsInSystemClock'
- [ShowSecondsInClock] Get()
- {
+ [ShowSecondsInClock] Get() {
$exists = DoesRegistryKeyPropertyExist -Path $global:ExplorerRegistryPath -Name $this.ShowSecondsInSystemClock
- if (-not($exists))
- {
+ if (-not($exists)) {
return @{
Ensure = [Ensure]::Absent
}
}
- $registryValue = Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.ShowSecondsInSystemClock
-
+ $registryValue = Get-ItemPropertyValue -Path $global:ExplorerRegistryPath -Name $this.ShowSecondsInSystemClock
+
return @{
Ensure = $registryValue ? [Ensure]::Present : [Ensure]::Absent
}
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
return $currentState.Ensure -eq $this.Ensure
}
- [void] Set()
- {
+ [void] Set() {
$value = ($this.Ensure -eq [Ensure]::Present) ? 1 : 0
Set-ItemProperty -Path $global:ExplorerRegistryPath -Name $this.ShowSecondsInSystemClock -Value $value
}
}
[DSCResource()]
-class EnableRemoteDesktop
-{
+class EnableRemoteDesktop {
# Key required. Do not set.
[DscProperty(Key)]
[string]$SID
@@ -629,32 +529,28 @@ class EnableRemoteDesktop
hidden [string] $RemoteDesktopKey = 'fDenyTSConnections'
- [EnableRemoteDesktop] Get()
- {
+ [EnableRemoteDesktop] Get() {
$exists = DoesRegistryKeyPropertyExist -Path $global:RemoteDesktopRegistryPath -Name $this.RemoteDesktopKey
- if (-not($exists))
- {
+ if (-not($exists)) {
return @{
Ensure = [Ensure]::Absent
}
}
- $registryValue = Get-ItemPropertyValue -Path $global:RemoteDesktopRegistryPath -Name $this.RemoteDesktopKey
-
+ $registryValue = Get-ItemPropertyValue -Path $global:RemoteDesktopRegistryPath -Name $this.RemoteDesktopKey
+
# Since the key is a 'deny' type key, 0 == enabled == Present // 1 == disabled == Absent
return @{
Ensure = $registryValue ? [Ensure]::Absent : [Ensure]::Present
}
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
return $currentState.Ensure -eq $this.Ensure
}
- [void] Set()
- {
+ [void] Set() {
# Since the key is a 'deny' type key, 0 == enabled == Present // 1 == disabled == Absent
$value = ($this.Ensure -eq [Ensure]::Present) ? 0 : 1
Set-ItemProperty -Path $global:RemoteDesktopRegistryPath -Name $this.RemoteDesktopKey -Value $value
@@ -666,29 +562,23 @@ class EnableRemoteDesktop
$AppModelUnlockRegistryKeyPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock\'
$DeveloperModePropertyName = 'AllowDevelopmentWithoutDevLicense'
-function IsDeveloperModeEnabled
-{
- try
- {
+function IsDeveloperModeEnabled {
+ try {
$property = Get-ItemProperty -Path $AppModelUnlockRegistryKeyPath -Name $DeveloperModePropertyName
return $property.AllowDevelopmentWithoutDevLicense -eq 1
- }
- catch
- {
+ } catch {
# This will throw an exception if the registry path or property does not exist.
- return $false;
+ return $false
}
}
-function SetDeveloperMode
-{
+function SetDeveloperMode {
param (
[Parameter(Mandatory)]
[bool]$Enable
)
- if (-not (Test-Path -Path $AppModelUnlockRegistryKeyPath))
- {
+ if (-not (Test-Path -Path $AppModelUnlockRegistryKeyPath)) {
New-Item -Path $AppModelUnlockRegistryKeyPath -Force | Out-Null
}
@@ -696,8 +586,7 @@ function SetDeveloperMode
New-ItemProperty -Path $AppModelUnlockRegistryKeyPath -Name $DeveloperModePropertyName -Value $developerModeValue -PropertyType DWORD -Force | Out-Null
}
-function DoesRegistryKeyPropertyExist
-{
+function DoesRegistryKeyPropertyExist {
param (
[Parameter(Mandatory)]
[string]$Path,
@@ -707,8 +596,8 @@ function DoesRegistryKeyPropertyExist
)
# Get-ItemProperty will return $null if the registry key property does not exist.
- $itemProperty = Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue
+ $itemProperty = Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue
return $null -ne $itemProperty
}
-#endregion Functions
\ No newline at end of file
+#endregion Functions
diff --git a/resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psd1 b/resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psd1
index d22dda14..b7c18fa1 100644
--- a/resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psd1
+++ b/resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psd1
@@ -10,7 +10,7 @@
Description = 'DSC Module for Windows Accessibility'
PowerShellVersion = '7.2'
DscResourcesToExport = @(
- 'Text',
+ 'Text',
'Magnifier',
'MousePointer',
'VisualEffect',
@@ -24,7 +24,7 @@
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = @(
- 'PSDscResource_Text',
+ 'PSDscResource_Text',
'PSDscResource_Magnifier',
'PSDscResource_MousePointer',
'PSDscResource_VisualEffect',
@@ -34,7 +34,7 @@
'PSDscResource_ToggleKeys',
'PSDscResource_FilterKeys'
)
-
+
# Prerelease string of this module
Prerelease = 'alpha'
}
diff --git a/resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psm1 b/resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psm1
index 1ee78493..1e98a833 100644
--- a/resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psm1
+++ b/resources/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.psm1
@@ -1,11 +1,10 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
-$ErrorActionPreference = "Stop"
+$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
-enum TextSize
-{
+enum TextSize {
KeepCurrentValue
Small
Medium
@@ -13,8 +12,7 @@ enum TextSize
ExtraLarge
}
-enum MagnificationValue
-{
+enum MagnificationValue {
KeepCurrentValue
None
Low
@@ -22,8 +20,7 @@ enum MagnificationValue
High
}
-enum PointerSize
-{
+enum PointerSize {
KeepCurrentValue
Normal
Medium
@@ -31,8 +28,7 @@ enum PointerSize
ExtraLarge
}
-[Flags()] enum StickyKeysOptions
-{
+[Flags()] enum StickyKeysOptions {
# https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-stickykeys
None = 0x00000000 # 0
Active = 0x00000001 # 1
@@ -46,8 +42,7 @@ enum PointerSize
TwoKeysOff = 0x00000100 # 256
}
-[Flags()] enum ToggleKeysOptions
-{
+[Flags()] enum ToggleKeysOptions {
# https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-togglekeys
None = 0x00000000 # 0
Active = 0x00000001 # 1
@@ -58,8 +53,7 @@ enum PointerSize
VisualIndicator = 0x00000020 # 32
}
-[Flags()] enum FilterKeysOptions
-{
+[Flags()] enum FilterKeysOptions {
# https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-filterkeys
None = 0x00000000 # 0
Active = 0x00000001 # 1
@@ -71,8 +65,7 @@ enum PointerSize
AudibleFeedback = 0x00000040 # 64
}
-if ([string]::IsNullOrEmpty($env:TestRegistryPath))
-{
+if ([string]::IsNullOrEmpty($env:TestRegistryPath)) {
$global:AccessibilityRegistryPath = 'HKCU:\Software\Microsoft\Accessibility\'
$global:MagnifierRegistryPath = 'HKCU:\Software\Microsoft\ScreenMagnifier\'
$global:PointerRegistryPath = 'HKCU:\Control Panel\Cursors\'
@@ -85,42 +78,33 @@ if ([string]::IsNullOrEmpty($env:TestRegistryPath))
$global:StickyKeysRegistryPath = 'HKCU:\Control Panel\Accessibility\StickyKeys'
$global:ToggleKeysRegistryPath = 'HKCU:\Control Panel\Accessibility\ToggleKeys'
$global:FilterKeysRegistryPath = 'HKCU:\Control Panel\Accessibility\Keyboard Response'
-}
-else
-{
+} else {
$global:AccessibilityRegistryPath = $global:MagnifierRegistryPath = $global:PointerRegistryPath = $global:ControlPanelAccessibilityRegistryPath = $global:AudioRegistryPath = $global:PersonalizationRegistryPath = $global:NTAccessibilityRegistryPath = $global:CursorIndicatorAccessibilityRegistryPath = $global:ControlPanelDesktopRegistryPath = $global:StickyKeysRegistryPath = $global:ToggleKeysRegistryPath = $global:FilterKeysRegistryPath = $env:TestRegistryPath
}
-[DSCResource()]
-class Text
-{
+[DSCResource()]
+class Text {
[DscProperty(Key)] [TextSize] $Size = [TextSize]::KeepCurrentValue
[DscProperty(NotConfigurable)] [int] $SizeValue
hidden [string] $TextScaleFactor = 'TextScaleFactor'
- [Text] Get()
- {
+ [Text] Get() {
$currentState = [Text]::new()
- if (-not(DoesRegistryKeyPropertyExist -Path $global:AccessibilityRegistryPath -Name $this.TextScaleFactor))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:AccessibilityRegistryPath -Name $this.TextScaleFactor)) {
$currentState.Size = [TextSize]::Small
$currentState.SizeValue = 96
- }
- else
- {
+ } else {
$currentState.SizeValue = [int](Get-ItemPropertyValue -Path $global:AccessibilityRegistryPath -Name $this.TextScaleFactor)
- $currentSize = switch ($currentState.sizeValue)
- {
+ $currentSize = switch ($currentState.sizeValue) {
96 { [TextSize]::Small }
120 { [TextSize]::Medium }
144 { [TextSize]::Large }
256 { [TextSize]::ExtraLarge }
}
- if ($null -ne $currentSize)
- {
+ if ($null -ne $currentSize) {
$currentState.Size = $currentSize
}
}
@@ -128,23 +112,18 @@ class Text
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if ($this.Size -ne [TextSize]::KeepCurrentValue -and $this.Size -ne $currentState.Size)
- {
+ if ($this.Size -ne [TextSize]::KeepCurrentValue -and $this.Size -ne $currentState.Size) {
return $false
}
return $true
}
- [void] Set()
- {
- if ($this.Size -ne [TextSize]::KeepCurrentValue)
- {
- $desiredSize = switch ([TextSize]($this.Size))
- {
+ [void] Set() {
+ if ($this.Size -ne [TextSize]::KeepCurrentValue) {
+ $desiredSize = switch ([TextSize]($this.Size)) {
Small { 96 }
Medium { 120 }
Large { 144 }
@@ -152,13 +131,12 @@ class Text
}
Set-ItemProperty -Path $global:AccessibilityRegistryPath -Name $this.TextScaleFactor -Value $desiredSize -Type DWORD
- }
+ }
}
}
[DSCResource()]
-class Magnifier
-{
+class Magnifier {
[DscProperty(Key)] [MagnificationValue] $Magnification = [MagnificationValue]::KeepCurrentValue
[DscProperty(Mandatory)] [int] $ZoomIncrement = 25
[DscProperty()] [bool] $StartMagnify = $false
@@ -168,37 +146,29 @@ class Magnifier
hidden [string] $MagnificationProperty = 'Magnification'
hidden [string] $ZoomIncrementProperty = 'ZoomIncrement'
- [Magnifier] Get()
- {
+ [Magnifier] Get() {
$currentState = [Magnifier]::new()
- if (-not(DoesRegistryKeyPropertyExist -Path $global:MagnifierRegistryPath -Name $this.MagnificationProperty))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:MagnifierRegistryPath -Name $this.MagnificationProperty)) {
$currentState.Magnification = [MagnificationValue]::None
- $currentState.MagnificationLevel = 0
- }
- else
- {
+ $currentState.MagnificationLevel = 0
+ } else {
$currentState.MagnificationLevel = (Get-ItemProperty -Path $global:MagnifierRegistryPath -Name $this.MagnificationProperty).Magnification
- $currentMagnification = switch ($currentState.MagnificationLevel)
- {
+ $currentMagnification = switch ($currentState.MagnificationLevel) {
0 { [MagnificationValue]::None }
100 { [MagnificationValue]::Low }
200 { [MagnificationValue]::Medium }
300 { [MagnificationValue]::High }
default { [MagnificationValue]::KeepCurrentValue }
}
-
- $currentState.Magnification = $currentMagnification
+
+ $currentState.Magnification = $currentMagnification
}
- if (-not(DoesRegistryKeyPropertyExist -Path $global:MagnifierRegistryPath -Name $this.ZoomIncrementProperty))
- {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:MagnifierRegistryPath -Name $this.ZoomIncrementProperty)) {
$currentState.ZoomIncrement = 25
$currentState.ZoomIncrementLevel = 25
- }
- else
- {
+ } else {
$currentState.ZoomIncrementLevel = (Get-ItemProperty -Path $global:MagnifierRegistryPath -Name $this.ZoomIncrementProperty).ZoomIncrement
$currentState.ZoomIncrement = $currentState.ZoomIncrementLevel
}
@@ -206,37 +176,29 @@ class Magnifier
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if ($this.Magnification -ne [MagnificationValue]::KeepCurrentValue -and $this.Magnification -ne $currentState.Magnification)
- {
+ if ($this.Magnification -ne [MagnificationValue]::KeepCurrentValue -and $this.Magnification -ne $currentState.Magnification) {
return $false
}
- if ($this.ZoomIncrement -ne $currentState.ZoomIncrement)
- {
+ if ($this.ZoomIncrement -ne $currentState.ZoomIncrement) {
return $false
}
return $true
}
- [void] Set()
- {
- if ($this.Test())
- {
+ [void] Set() {
+ if ($this.Test()) {
return
}
- if (-not (Test-Path -Path $global:MagnifierRegistryPath))
- {
+ if (-not (Test-Path -Path $global:MagnifierRegistryPath)) {
New-Item -Path $global:MagnifierRegistryPath -Force | Out-Null
}
- if ($this.Magnification -ne [MagnificationValue]::KeepCurrentValue)
- {
- $desiredMagnification = switch ([MagnificationValue]($this.Magnification))
- {
+ if ($this.Magnification -ne [MagnificationValue]::KeepCurrentValue) {
+ $desiredMagnification = switch ([MagnificationValue]($this.Magnification)) {
None { 0 }
Low { 100 }
Medium { 200 }
@@ -248,78 +210,64 @@ class Magnifier
$currentState = $this.Get()
- if ($this.ZoomIncrement -ne $currentState.ZoomIncrement)
- {
+ if ($this.ZoomIncrement -ne $currentState.ZoomIncrement) {
Set-ItemProperty -Path $global:MagnifierRegistryPath -Name $this.ZoomIncrementProperty -Value $this.ZoomIncrement -Type DWORD
}
- if (($this.StartMagnify) -and (($null -eq (Get-Process -Name 'Magnify' -ErrorAction SilentlyContinue))))
- {
- Start-Process "C:\Windows\System32\Magnify.exe"
+ if (($this.StartMagnify) -and (($null -eq (Get-Process -Name 'Magnify' -ErrorAction SilentlyContinue)))) {
+ Start-Process 'C:\Windows\System32\Magnify.exe'
}
}
}
[DSCResource()]
-class MousePointer
-{
+class MousePointer {
[DscProperty(Key)] [PointerSize] $PointerSize = [PointerSize]::KeepCurrentValue
[DscProperty(NotConfigurable)] [string] $PointerSizeValue
hidden [string] $PointerSizeProperty = 'CursorBaseSize'
- [MousePointer] Get()
- {
+ [MousePointer] Get() {
$currentState = [MousePointer]::new()
-
- if (-not(DoesRegistryKeyPropertyExist -Path $global:PointerRegistryPath -Name $this.PointerSizeProperty))
- {
+
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:PointerRegistryPath -Name $this.PointerSizeProperty)) {
$currentState.PointerSize = [PointerSize]::Normal
$currentState.PointerSizeValue = '32'
- }
- else
- {
+ } else {
$currentState.PointerSizeValue = (Get-ItemProperty -Path $global:PointerRegistryPath -Name $this.PointerSizeProperty).CursorBaseSize
- $currentSize = switch ($currentState.PointerSizeValue)
- {
- '32' { [PointerSize]::Normal }
+ $currentSize = switch ($currentState.PointerSizeValue) {
+ '32' { [PointerSize]::Normal }
'96' { [PointerSize]::Medium }
'144' { [PointerSize]::Large }
'256' { [PointerSize]::ExtraLarge }
default { [PointerSize]::KeepCurrentValue }
}
-
- $currentState.PointerSize = $currentSize
+
+ $currentState.PointerSize = $currentSize
}
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if ($this.PointerSize -ne [PointerSize]::KeepCurrentValue -and $this.PointerSize -ne $currentState.PointerSize)
- {
+ if ($this.PointerSize -ne [PointerSize]::KeepCurrentValue -and $this.PointerSize -ne $currentState.PointerSize) {
return $false
}
return $true
}
- [void] Set()
- {
- if ($this.PointerSize -ne [PointerSize]::KeepCurrentValue)
- {
- $desiredSize = switch ([PointerSize]($this.PointerSize))
- {
+ [void] Set() {
+ if ($this.PointerSize -ne [PointerSize]::KeepCurrentValue) {
+ $desiredSize = switch ([PointerSize]($this.PointerSize)) {
Normal { '32' }
Medium { '96' }
Large { '144' }
ExtraLarge { '256' }
}
- if (-not (Test-Path -Path $global:PointerRegistryPath))
- {
+ if (-not (Test-Path -Path $global:PointerRegistryPath)) {
New-Item -Path $global:PointerRegistryPath -Force | Out-Null
}
@@ -329,8 +277,7 @@ class MousePointer
}
[DSCResource()]
-class VisualEffect
-{
+class VisualEffect {
# Key required. Do not set.
[DscProperty(Key)] [string] $SID
[DscProperty()] [nullable[bool]] $AlwaysShowScrollbars
@@ -341,171 +288,134 @@ class VisualEffect
static hidden [string] $TransparencySettingProperty = 'EnableTransparency'
static hidden [string] $MessageDurationProperty = 'MessageDuration'
- static [bool] GetShowDynamicScrollbarsStatus()
- {
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ControlPanelAccessibilityRegistryPath -Name ([VisualEffect]::DynamicScrollbarsProperty)))
- {
+ static [bool] GetShowDynamicScrollbarsStatus() {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ControlPanelAccessibilityRegistryPath -Name ([VisualEffect]::DynamicScrollbarsProperty))) {
return $false
- }
- else
- {
+ } else {
$dynamicScrollbarsValue = (Get-ItemProperty -Path $global:ControlPanelAccessibilityRegistryPath -Name ([VisualEffect]::DynamicScrollbarsProperty)).DynamicScrollbars
return ($dynamicScrollbarsValue -eq 0)
- }
+ }
}
- static [bool] GetTransparencyStatus()
- {
- if (-not(DoesRegistryKeyPropertyExist -Path $global:PersonalizationRegistryPath -Name ([VisualEffect]::TransparencySettingProperty)))
- {
+ static [bool] GetTransparencyStatus() {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:PersonalizationRegistryPath -Name ([VisualEffect]::TransparencySettingProperty))) {
return $false
- }
- else
- {
+ } else {
$TransparencySetting = (Get-ItemProperty -Path $global:PersonalizationRegistryPath -Name ([VisualEffect]::TransparencySettingProperty)).EnableTransparency
return ($TransparencySetting -eq 0)
}
}
- static [int] GetMessageDuration()
- {
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ControlPanelAccessibilityRegistryPath -Name ([VisualEffect]::MessageDurationProperty)))
- {
+ static [int] GetMessageDuration() {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ControlPanelAccessibilityRegistryPath -Name ([VisualEffect]::MessageDurationProperty))) {
return 5
- }
- else
- {
+ } else {
$MessageDurationSetting = (Get-ItemProperty -Path $global:ControlPanelAccessibilityRegistryPath -Name ([VisualEffect]::MessageDurationProperty)).MessageDuration
return $MessageDurationSetting
}
}
- [VisualEffect] Get()
- {
+ [VisualEffect] Get() {
$currentState = [VisualEffect]::new()
$currentState.AlwaysShowScrollbars = [VisualEffect]::GetShowDynamicScrollbarsStatus()
$currentState.TransparencyEffects = [VisualEffect]::GetTransparencyStatus()
$currentState.MessageDurationInSeconds = [VisualEffect]::GetMessageDuration()
-
+
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if (($null -ne $this.AlwaysShowScrollbars) -and ($this.AlwaysShowScrollbars -ne $currentState.AlwaysShowScrollbars))
- {
+ if (($null -ne $this.AlwaysShowScrollbars) -and ($this.AlwaysShowScrollbars -ne $currentState.AlwaysShowScrollbars)) {
return $false
}
- if (($null -ne $this.TransparencyEffects) -and ($this.TransparencyEffects -ne $currentState.TransparencyEffects))
- {
+ if (($null -ne $this.TransparencyEffects) -and ($this.TransparencyEffects -ne $currentState.TransparencyEffects)) {
return $false
}
- if ((0 -ne $this.MessageDurationInSeconds) -and ($this.MessageDurationInSeconds -ne $currentState.MessageDurationInSeconds))
- {
+ if ((0 -ne $this.MessageDurationInSeconds) -and ($this.MessageDurationInSeconds -ne $currentState.MessageDurationInSeconds)) {
return $false
}
return $true
}
- [void] Set()
- {
- if (-not $this.Test())
- {
- if (-not (Test-Path -Path $global:ControlPanelAccessibilityRegistryPath))
- {
+ [void] Set() {
+ if (-not $this.Test()) {
+ if (-not (Test-Path -Path $global:ControlPanelAccessibilityRegistryPath)) {
New-Item -Path $global:ControlPanelAccessibilityRegistryPath -Force | Out-Null
}
- if ($null -ne $this.AlwaysShowScrollbars)
- {
+ if ($null -ne $this.AlwaysShowScrollbars) {
$dynamicScrollbarValue = if ($this.AlwaysShowScrollbars) { 0 } else { 1 }
Set-ItemProperty -Path $global:ControlPanelAccessibilityRegistryPath -Name ([VisualEffect]::DynamicScrollbarsProperty) -Value $dynamicScrollbarValue
}
- if ($null -ne $this.TransparencyEffects)
- {
+ if ($null -ne $this.TransparencyEffects) {
$transparencyValue = if ($this.TransparencyEffects) { 0 } else { 1 }
-
- if (-not (DoesRegistryKeyPropertyExist -Path $global:PersonalizationRegistryPath -Name ([VisualEffect]::TransparencySettingProperty)))
- {
+
+ if (-not (DoesRegistryKeyPropertyExist -Path $global:PersonalizationRegistryPath -Name ([VisualEffect]::TransparencySettingProperty))) {
New-ItemProperty -Path $global:PersonalizationRegistryPath -Name ([VisualEffect]::TransparencySettingProperty) -Value $transparencyValue -PropertyType DWord
}
- Set-ItemProperty -Path $global:PersonalizationRegistryPath -Name ([VisualEffect]::TransparencySettingProperty) -Value $transparencyValue
+ Set-ItemProperty -Path $global:PersonalizationRegistryPath -Name ([VisualEffect]::TransparencySettingProperty) -Value $transparencyValue
}
- if (0 -ne $this.MessageDurationInSeconds)
- {
+ if (0 -ne $this.MessageDurationInSeconds) {
$min = 5
$max = 300
- if ($this.MessageDurationInSeconds -notin $min..$max)
- {
- throw "MessageDurationInSeconds must be between $min and $max. Value $($this.MessageDurationInSeconds) was provided."
+ if ($this.MessageDurationInSeconds -notin $min..$max) {
+ throw "MessageDurationInSeconds must be between $min and $max. Value $($this.MessageDurationInSeconds) was provided."
}
- Set-ItemProperty -Path $global:ControlPanelAccessibilityRegistryPath -Name ([VisualEffect]::MessageDurationProperty) -Value $this.MessageDurationInSeconds
+ Set-ItemProperty -Path $global:ControlPanelAccessibilityRegistryPath -Name ([VisualEffect]::MessageDurationProperty) -Value $this.MessageDurationInSeconds
}
}
}
}
[DSCResource()]
-class Audio
-{
+class Audio {
# Key required. Do not set.
[DscProperty(Key)] [string] $SID
[DscProperty()] [bool] $EnableMonoAudio = $false
static hidden [string] $EnableMonoAudioProperty = 'AccessibilityMonoMixState'
- static [bool] GetEnableMonoAudioStatus()
- {
- if (-not(DoesRegistryKeyPropertyExist -Path $global:AudioRegistryPath -Name ([Audio]::EnableMonoAudioProperty)))
- {
+ static [bool] GetEnableMonoAudioStatus() {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:AudioRegistryPath -Name ([Audio]::EnableMonoAudioProperty))) {
return $false
- }
- else
- {
+ } else {
$AudioMonoSetting = (Get-ItemProperty -Path $global:AudioRegistryPath -Name ([Audio]::EnableMonoAudioProperty)).AccessibilityMonoMixState
return ($AudioMonoSetting -eq 0)
- }
+ }
}
- [Audio] Get()
- {
+ [Audio] Get() {
$currentState = [Audio]::new()
$currentState.EnableMonoAudio = [Audio]::GetEnableMonoAudioStatus()
-
+
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if ($this.EnableMonoAudio -ne $currentState.EnableMonoAudio)
- {
+ if ($this.EnableMonoAudio -ne $currentState.EnableMonoAudio) {
return $false
}
return $true
}
- [void] Set()
- {
- if (-not $this.Test())
- {
- if (-not (Test-Path -Path $global:AudioRegistryPath))
- {
+ [void] Set() {
+ if (-not $this.Test()) {
+ if (-not (Test-Path -Path $global:AudioRegistryPath)) {
New-Item -Path $global:AudioRegistryPath -Force | Out-Null
}
$monoAudioValue = if ($this.EnableMonoAudio) { 0 } else { 1 }
- Set-ItemProperty -Path $global:AudioRegistryPath -Name ([Audio]::EnableMonoAudioProperty) -Value $monoAudioValue
+ Set-ItemProperty -Path $global:AudioRegistryPath -Name ([Audio]::EnableMonoAudioProperty) -Value $monoAudioValue
}
}
}
[DSCResource()]
-class TextCursor
-{
+class TextCursor {
# Key required. Do not set.
[DscProperty(Key)] [string] $SID
[DscProperty()] [nullable[bool]] $IndicatorStatus
@@ -520,157 +430,123 @@ class TextCursor
static hidden [string] $ThicknessProperty = 'CaretWidth'
- static [bool] GetIndicatorStatus()
- {
+ static [bool] GetIndicatorStatus() {
$indicatorStatusArgs = @{ Path = $global:NTAccessibilityRegistryPath; Name = ([TextCursor]::IndicatorStatusProperty) }
- if (-not(DoesRegistryKeyPropertyExist @indicatorStatusArgs))
- {
+ if (-not(DoesRegistryKeyPropertyExist @indicatorStatusArgs)) {
return $false
- }
- else
- {
+ } else {
$textCursorSetting = (Get-ItemProperty @indicatorStatusArgs).Configuration
return ($textCursorSetting -eq ([TextCursor]::IndicatorStatusValue))
- }
+ }
}
- static [int] GetIndicatorSize()
- {
+ static [int] GetIndicatorSize() {
$indicatorSizeArgs = @{ Path = $global:CursorIndicatorAccessibilityRegistryPath; Name = ([TextCursor]::IndicatorSizeProperty) }
- if (-not(DoesRegistryKeyPropertyExist @indicatorSizeArgs))
- {
+ if (-not(DoesRegistryKeyPropertyExist @indicatorSizeArgs)) {
return 1
- }
- else
- {
+ } else {
$textCursorSetting = (Get-ItemProperty @indicatorSizeArgs).IndicatorType
return $textCursorSetting
- }
+ }
}
- static [int] GetIndicatorColor()
- {
+ static [int] GetIndicatorColor() {
$indicatorColorArgs = @{ Path = $global:CursorIndicatorAccessibilityRegistryPath; Name = ([TextCursor]::IndicatorColorProperty) }
- if (-not(DoesRegistryKeyPropertyExist @indicatorColorArgs))
- {
+ if (-not(DoesRegistryKeyPropertyExist @indicatorColorArgs)) {
return $false
- }
- else
- {
+ } else {
$textCursorSetting = (Get-ItemProperty @indicatorColorArgs).IndicatorColor
return $textCursorSetting
- }
+ }
}
- static [int] GetThickness()
- {
+ static [int] GetThickness() {
$thicknessArgs = @{ Path = $global:ControlPanelDesktopRegistryPath; Name = ([TextCursor]::ThicknessProperty); }
- if (-not(DoesRegistryKeyPropertyExist @thicknessArgs))
- {
+ if (-not(DoesRegistryKeyPropertyExist @thicknessArgs)) {
return 1
- }
- else
- {
+ } else {
$textCursorSetting = (Get-ItemProperty @thicknessArgs).CaretWidth
return $textCursorSetting
- }
+ }
}
- [TextCursor] Get()
- {
+ [TextCursor] Get() {
$currentState = [TextCursor]::new()
$currentState.IndicatorStatus = [TextCursor]::GetIndicatorStatus()
$currentState.IndicatorSize = [TextCursor]::GetIndicatorSize()
$currentState.IndicatorColor = [TextCursor]::GetIndicatorColor()
$currentState.Thickness = [TextCursor]::GetThickness()
-
+
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if (($null -ne $this.IndicatorStatus) -and ($this.IndicatorStatus -ne $currentState.IndicatorStatus))
- {
+ if (($null -ne $this.IndicatorStatus) -and ($this.IndicatorStatus -ne $currentState.IndicatorStatus)) {
return $false
}
- if ((0 -ne $this.IndicatorSize) -and ($this.IndicatorSize -ne $currentState.IndicatorSize))
- {
+ if ((0 -ne $this.IndicatorSize) -and ($this.IndicatorSize -ne $currentState.IndicatorSize)) {
return $false
}
- if ((0 -ne $this.IndicatorColor) -and ($this.IndicatorColor -ne $currentState.IndicatorColor))
- {
+ if ((0 -ne $this.IndicatorColor) -and ($this.IndicatorColor -ne $currentState.IndicatorColor)) {
return $false
}
- if ((0 -ne $this.Thickness) -and ($this.Thickness -ne $currentState.Thickness))
- {
+ if ((0 -ne $this.Thickness) -and ($this.Thickness -ne $currentState.Thickness)) {
return $false
}
return $true
}
- [void] Set()
- {
- if (-not $this.Test())
- {
- if ($null -ne $this.IndicatorStatus)
- {
+ [void] Set() {
+ if (-not $this.Test()) {
+ if ($null -ne $this.IndicatorStatus) {
$indicatorStatusArgs = @{ Path = $global:NTAccessibilityRegistryPath; Name = ([TextCursor]::IndicatorStatusProperty); }
- $textCursorValue = if ($this.IndicatorStatus) { ([TextCursor]::IndicatorStatusValue) } else { "" }
+ $textCursorValue = if ($this.IndicatorStatus) { ([TextCursor]::IndicatorStatusValue) } else { '' }
Set-ItemProperty @indicatorStatusArgs -Value $textCursorValue
}
-
- if (0 -ne $this.IndicatorSize)
- {
+
+ if (0 -ne $this.IndicatorSize) {
$indicatorSizeArgs = @{ Path = $global:CursorIndicatorAccessibilityRegistryPath; Name = ([TextCursor]::IndicatorSizeProperty) }
$min = 1
$max = 20
- if ($this.IndicatorSize -notin $min..$max)
- {
- throw "IndicatorSize must be between $min and $max. Value $($this.IndicatorSize) was provided."
+ if ($this.IndicatorSize -notin $min..$max) {
+ throw "IndicatorSize must be between $min and $max. Value $($this.IndicatorSize) was provided."
}
- if (-not (DoesRegistryKeyPropertyExist @indicatorSizeArgs))
- {
+ if (-not (DoesRegistryKeyPropertyExist @indicatorSizeArgs)) {
New-ItemProperty @indicatorSizeArgs -Value $this.IndicatorSize -PropertyType DWord
}
- Set-ItemProperty @indicatorSizeArgs -Value $this.IndicatorSize
+ Set-ItemProperty @indicatorSizeArgs -Value $this.IndicatorSize
}
-
- if (0 -ne $this.IndicatorColor)
- {
+
+ if (0 -ne $this.IndicatorColor) {
$indicatorColorArgs = @{ Path = $global:CursorIndicatorAccessibilityRegistryPath; Name = ([TextCursor]::IndicatorColorProperty) }
$min = 1
$max = 99999999
- if ($this.IndicatorColor -notin $min..$max)
- {
- throw "IndicatorColor must be between $min and $max. Value $($this.IndicatorColor) was provided."
+ if ($this.IndicatorColor -notin $min..$max) {
+ throw "IndicatorColor must be between $min and $max. Value $($this.IndicatorColor) was provided."
}
- if (-not (DoesRegistryKeyPropertyExist @indicatorColorArgs))
- {
+ if (-not (DoesRegistryKeyPropertyExist @indicatorColorArgs)) {
New-ItemProperty @indicatorColorArgs -Value $this.IndicatorColor -PropertyType DWord
}
- Set-ItemProperty @indicatorColorArgs -Value $this.IndicatorColor
+ Set-ItemProperty @indicatorColorArgs -Value $this.IndicatorColor
}
-
- if (0 -ne $this.Thickness)
- {
+
+ if (0 -ne $this.Thickness) {
$thicknessArgs = @{ Path = $global:ControlPanelDesktopRegistryPath; Name = ([TextCursor]::ThicknessProperty); }
$min = 1
$max = 20
- if ($this.Thickness -notin $min..$max)
- {
- throw "Thickness must be between $min and $max. Value $($this.Thickness) was provided."
+ if ($this.Thickness -notin $min..$max) {
+ throw "Thickness must be between $min and $max. Value $($this.Thickness) was provided."
}
- Set-ItemProperty @thicknessArgs -Value $this.Thickness
+ Set-ItemProperty @thicknessArgs -Value $this.Thickness
}
}
}
}
[DSCResource()]
-class StickyKeys
-{
+class StickyKeys {
# Key required. Do not set.
[DscProperty(Key)] [string] $SID
[DscProperty()] [nullable[bool]] $Active
@@ -685,23 +561,18 @@ class StickyKeys
static hidden [string] $SettingsProperty = 'Flags'
- static [System.Enum] GetCurrentFlags()
- {
- if (-not(DoesRegistryKeyPropertyExist -Path $global:StickyKeysRegistryPath -Name ([StickyKeys]::SettingsProperty)))
- {
+ static [System.Enum] GetCurrentFlags() {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:StickyKeysRegistryPath -Name ([StickyKeys]::SettingsProperty))) {
return [StickyKeysOptions]::None
- }
- else
- {
+ } else {
$StickyKeysFlags = [System.Enum]::Parse('StickyKeysOptions', (Get-ItemPropertyValue -Path $global:StickyKeysRegistryPath -Name ([StickyKeys]::SettingsProperty)))
return $StickyKeysFlags
}
}
- [StickyKeys] Get()
- {
+ [StickyKeys] Get() {
$currentFlags = [StickyKeys]::GetCurrentFlags()
-
+
$currentState = [StickyKeys]::new()
$currentState.Active = $currentFlags.HasFlag([StickyKeysOptions]::Active)
$currentState.Available = $currentFlags.HasFlag([StickyKeysOptions]::Available)
@@ -712,112 +583,91 @@ class StickyKeys
$currentState.AudibleFeedback = $currentFlags.HasFlag([StickyKeysOptions]::AudibleFeedback)
$currentState.TriState = $currentFlags.HasFlag([StickyKeysOptions]::TriState)
$currentState.TwoKeysOff = $currentFlags.HasFlag([StickyKeysOptions]::TwoKeysOff)
-
+
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if (($null -ne $this.Active) -and ($this.Active -ne $currentState.Active))
- {
+ if (($null -ne $this.Active) -and ($this.Active -ne $currentState.Active)) {
return $false
}
- if (($null -ne $this.Available) -and ($this.Available -ne $currentState.Available))
- {
+ if (($null -ne $this.Available) -and ($this.Available -ne $currentState.Available)) {
return $false
}
- if (($null -ne $this.HotkeyActive) -and ($this.HotkeyActive -ne $currentState.HotkeyActive))
- {
+ if (($null -ne $this.HotkeyActive) -and ($this.HotkeyActive -ne $currentState.HotkeyActive)) {
return $false
}
- if (($null -ne $this.ConfirmOnHotkeyActivation) -and ($this.ConfirmOnHotkeyActivation -ne $currentState.ConfirmOnHotkeyActivation))
- {
+ if (($null -ne $this.ConfirmOnHotkeyActivation) -and ($this.ConfirmOnHotkeyActivation -ne $currentState.ConfirmOnHotkeyActivation)) {
return $false
}
- if (($null -ne $this.HotkeySound) -and ($this.HotkeySound -ne $currentState.HotkeySound))
- {
+ if (($null -ne $this.HotkeySound) -and ($this.HotkeySound -ne $currentState.HotkeySound)) {
return $false
}
- if (($null -ne $this.VisualIndicator) -and ($this.VisualIndicator -ne $currentState.VisualIndicator))
- {
+ if (($null -ne $this.VisualIndicator) -and ($this.VisualIndicator -ne $currentState.VisualIndicator)) {
return $false
}
- if (($null -ne $this.AudibleFeedback) -and ($this.AudibleFeedback -ne $currentState.AudibleFeedback))
- {
+ if (($null -ne $this.AudibleFeedback) -and ($this.AudibleFeedback -ne $currentState.AudibleFeedback)) {
return $false
}
- if (($null -ne $this.TriState) -and ($this.TriState -ne $currentState.TriState))
- {
+ if (($null -ne $this.TriState) -and ($this.TriState -ne $currentState.TriState)) {
return $false
}
- if (($null -ne $this.TwoKeysOff) -and ($this.TwoKeysOff -ne $currentState.TwoKeysOff))
- {
+ if (($null -ne $this.TwoKeysOff) -and ($this.TwoKeysOff -ne $currentState.TwoKeysOff)) {
return $false
}
return $true
}
- [void] Set()
- {
+ [void] Set() {
# Only make changes if changes are needed
- if (-not $this.Test())
- {
+ if (-not $this.Test()) {
# If a value isn't set in the DSC, it should remain unchanged, to do this we need the current flags
$flags = [StickyKeys]::GetCurrentFlags()
- if ($null -ne $this.Active)
- {
+ if ($null -ne $this.Active) {
$flags = $this.Active ? $flags -bor [StickyKeysOptions]::Active : $flags -band (-bnot [StickyKeysOptions]::Active)
}
- if ($null -ne $this.Available)
- {
+ if ($null -ne $this.Available) {
$flags = $this.Available ? $flags -bor [StickyKeysOptions]::Available : $flags -band (-bnot [StickyKeysOptions]::Available)
}
- if ($null -ne $this.HotkeyActive)
- {
+ if ($null -ne $this.HotkeyActive) {
$flags = $this.HotkeyActive ? $flags -bor [StickyKeysOptions]::HotkeyActive : $flags -band (-bnot [StickyKeysOptions]::HotkeyActive)
}
- if ($null -ne $this.ConfirmOnHotkeyActivation)
- {
+ if ($null -ne $this.ConfirmOnHotkeyActivation) {
$flags = $this.ConfirmOnHotkeyActivation ? $flags -bor [StickyKeysOptions]::ConfirmHotkey : $flags -band (-bnot [StickyKeysOptions]::ConfirmHotkey)
}
- if ($null -ne $this.HotkeySound)
- {
+ if ($null -ne $this.HotkeySound) {
$flags = $this.HotkeySound ? $flags -bor [StickyKeysOptions]::HotkeySound : $flags -band (-bnot [StickyKeysOptions]::HotkeySound)
}
- if ($null -ne $this.VisualIndicator)
- {
+ if ($null -ne $this.VisualIndicator) {
$flags = $this.VisualIndicator ? $flags -bor [StickyKeysOptions]::VisualIndicator : $flags -band (-bnot [StickyKeysOptions]::VisualIndicator)
}
- if ($null -ne $this.AudibleFeedback)
- {
+ if ($null -ne $this.AudibleFeedback) {
$flags = $this.AudibleFeedback ? $flags -bor [StickyKeysOptions]::AudibleFeedback : $flags -band (-bnot [StickyKeysOptions]::AudibleFeedback)
}
- if ($null -ne $this.TriState)
- {
+ if ($null -ne $this.TriState) {
$flags = $this.TriState ? $flags -bor [StickyKeysOptions]::TriState : $flags -band (-bnot [StickyKeysOptions]::TriState)
}
- if ($null -ne $this.TwoKeysOff)
- {
+ if ($null -ne $this.TwoKeysOff) {
$flags = $this.TwoKeysOff ? $flags -bor [StickyKeysOptions]::TwoKeysOff : $flags -band (-bnot [StickyKeysOptions]::TwoKeysOff)
}
@@ -828,8 +678,7 @@ class StickyKeys
}
[DSCResource()]
-class ToggleKeys
-{
+class ToggleKeys {
# Key required. Do not set.
[DscProperty(Key)] [string] $SID
[DscProperty()] [nullable[bool]] $Active
@@ -841,23 +690,18 @@ class ToggleKeys
static hidden [string] $SettingsProperty = 'Flags'
- static [System.Enum] GetCurrentFlags()
- {
- if (-not(DoesRegistryKeyPropertyExist -Path $global:ToggleKeysRegistryPath -Name ([ToggleKeys]::SettingsProperty)))
- {
+ static [System.Enum] GetCurrentFlags() {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:ToggleKeysRegistryPath -Name ([ToggleKeys]::SettingsProperty))) {
return [ToggleKeysOptions]::None
- }
- else
- {
+ } else {
$ToggleKeysFlags = [System.Enum]::Parse('ToggleKeysOptions', (Get-ItemPropertyValue -Path $global:StickyKeysRegistryPath -Name ([StickyKeys]::SettingsProperty)))
return $ToggleKeysFlags
}
}
- [ToggleKeys] Get()
- {
+ [ToggleKeys] Get() {
$currentFlags = [ToggleKeys]::GetCurrentFlags()
-
+
$currentState = [ToggleKeys]::new()
$currentState.Active = $currentFlags.HasFlag([ToggleKeysOptions]::Active)
$currentState.Available = $currentFlags.HasFlag([ToggleKeysOptions]::Available)
@@ -865,82 +709,67 @@ class ToggleKeys
$currentState.ConfirmOnHotkeyActivation = $currentFlags.HasFlag([ToggleKeysOptions]::ConfirmHotkey)
$currentState.HotkeySound = $currentFlags.HasFlag([ToggleKeysOptions]::HotkeySound)
$currentState.VisualIndicator = $currentFlags.HasFlag([ToggleKeysOptions]::VisualIndicator)
-
+
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if (($null -ne $this.Active) -and ($this.Active -ne $currentState.Active))
- {
+ if (($null -ne $this.Active) -and ($this.Active -ne $currentState.Active)) {
return $false
}
- if (($null -ne $this.Available) -and ($this.Available -ne $currentState.Available))
- {
+ if (($null -ne $this.Available) -and ($this.Available -ne $currentState.Available)) {
return $false
}
- if (($null -ne $this.HotkeyActive) -and ($this.HotkeyActive -ne $currentState.HotkeyActive))
- {
+ if (($null -ne $this.HotkeyActive) -and ($this.HotkeyActive -ne $currentState.HotkeyActive)) {
return $false
}
- if (($null -ne $this.ConfirmOnHotkeyActivation) -and ($this.ConfirmOnHotkeyActivation -ne $currentState.ConfirmOnHotkeyActivation))
- {
+ if (($null -ne $this.ConfirmOnHotkeyActivation) -and ($this.ConfirmOnHotkeyActivation -ne $currentState.ConfirmOnHotkeyActivation)) {
return $false
}
- if (($null -ne $this.HotkeySound) -and ($this.HotkeySound -ne $currentState.HotkeySound))
- {
+ if (($null -ne $this.HotkeySound) -and ($this.HotkeySound -ne $currentState.HotkeySound)) {
return $false
}
- if (($null -ne $this.VisualIndicator) -and ($this.VisualIndicator -ne $currentState.VisualIndicator))
- {
+ if (($null -ne $this.VisualIndicator) -and ($this.VisualIndicator -ne $currentState.VisualIndicator)) {
return $false
}
return $true
}
- [void] Set()
- {
+ [void] Set() {
# Only make changes if changes are needed
- if (-not $this.Test())
- {
+ if (-not $this.Test()) {
# If a value isn't set in the DSC, it should remain unchanged, to do this we need the current flags
$flags = [ToggleKeys]::GetCurrentFlags()
- if ($null -ne $this.Active)
- {
+ if ($null -ne $this.Active) {
$flags = $this.Active ? $flags -bor [ToggleKeysOptions]::Active : $flags -band (-bnot [ToggleKeysOptions]::Active)
}
- if ($null -ne $this.Available)
- {
+ if ($null -ne $this.Available) {
$flags = $this.Available ? $flags -bor [ToggleKeysOptions]::Available : $flags -band (-bnot [ToggleKeysOptions]::Available)
}
- if ($null -ne $this.HotkeyActive)
- {
+ if ($null -ne $this.HotkeyActive) {
$flags = $this.HotkeyActive ? $flags -bor [ToggleKeysOptions]::HotkeyActive : $flags -band (-bnot [ToggleKeysOptions]::HotkeyActive)
}
- if ($null -ne $this.ConfirmOnHotkeyActivation)
- {
+ if ($null -ne $this.ConfirmOnHotkeyActivation) {
$flags = $this.ConfirmOnHotkeyActivation ? $flags -bor [ToggleKeysOptions]::ConfirmHotkey : $flags -band (-bnot [ToggleKeysOptions]::ConfirmHotkey)
}
- if ($null -ne $this.HotkeySound)
- {
+ if ($null -ne $this.HotkeySound) {
$flags = $this.HotkeySound ? $flags -bor [ToggleKeysOptions]::HotkeySound : $flags -band (-bnot [ToggleKeysOptions]::HotkeySound)
}
- if ($null -ne $this.VisualIndicator)
- {
+ if ($null -ne $this.VisualIndicator) {
$flags = $this.VisualIndicator ? $flags -bor [ToggleKeysOptions]::VisualIndicator : $flags -band (-bnot [ToggleKeysOptions]::VisualIndicator)
}
@@ -951,8 +780,7 @@ class ToggleKeys
}
[DSCResource()]
-class FilterKeys
-{
+class FilterKeys {
# Key required. Do not set.
[DscProperty(Key)] [string] $SID
[DscProperty()] [nullable[bool]] $Active
@@ -965,23 +793,18 @@ class FilterKeys
static hidden [string] $SettingsProperty = 'Flags'
- static [System.Enum] GetCurrentFlags()
- {
- if (-not(DoesRegistryKeyPropertyExist -Path $global:FilterKeysRegistryPath -Name ([FilterKeys]::SettingsProperty)))
- {
+ static [System.Enum] GetCurrentFlags() {
+ if (-not(DoesRegistryKeyPropertyExist -Path $global:FilterKeysRegistryPath -Name ([FilterKeys]::SettingsProperty))) {
return [FilterKeysOptions]::None
- }
- else
- {
+ } else {
$FilterKeysFlags = [System.Enum]::Parse('FilterKeysOptions', (Get-ItemPropertyValue -Path $global:FilterKeysRegistryPath -Name ([FilterKeys]::SettingsProperty)))
return $FilterKeysFlags
}
}
- [FilterKeys] Get()
- {
+ [FilterKeys] Get() {
$currentFlags = [FilterKeys]::GetCurrentFlags()
-
+
$currentState = [FilterKeys]::new()
$currentState.Active = $currentFlags.HasFlag([FilterKeysOptions]::Active)
$currentState.Available = $currentFlags.HasFlag([FilterKeysOptions]::Available)
@@ -990,92 +813,75 @@ class FilterKeys
$currentState.HotkeySound = $currentFlags.HasFlag([FilterKeysOptions]::HotkeySound)
$currentState.VisualIndicator = $currentFlags.HasFlag([FilterKeysOptions]::VisualIndicator)
$currentState.AudibleFeedback = $currentFlags.HasFlag([FilterKeysOptions]::AudibleFeedback)
-
+
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if (($null -ne $this.Active) -and ($this.Active -ne $currentState.Active))
- {
+ if (($null -ne $this.Active) -and ($this.Active -ne $currentState.Active)) {
return $false
}
- if (($null -ne $this.Available) -and ($this.Available -ne $currentState.Available))
- {
+ if (($null -ne $this.Available) -and ($this.Available -ne $currentState.Available)) {
return $false
}
- if (($null -ne $this.HotkeyActive) -and ($this.HotkeyActive -ne $currentState.HotkeyActive))
- {
+ if (($null -ne $this.HotkeyActive) -and ($this.HotkeyActive -ne $currentState.HotkeyActive)) {
return $false
}
- if (($null -ne $this.ConfirmOnHotkeyActivation) -and ($this.ConfirmOnHotkeyActivation -ne $currentState.ConfirmOnHotkeyActivation))
- {
+ if (($null -ne $this.ConfirmOnHotkeyActivation) -and ($this.ConfirmOnHotkeyActivation -ne $currentState.ConfirmOnHotkeyActivation)) {
return $false
}
- if (($null -ne $this.HotkeySound) -and ($this.HotkeySound -ne $currentState.HotkeySound))
- {
+ if (($null -ne $this.HotkeySound) -and ($this.HotkeySound -ne $currentState.HotkeySound)) {
return $false
}
- if (($null -ne $this.VisualIndicator) -and ($this.VisualIndicator -ne $currentState.VisualIndicator))
- {
+ if (($null -ne $this.VisualIndicator) -and ($this.VisualIndicator -ne $currentState.VisualIndicator)) {
return $false
}
- if (($null -ne $this.AudibleFeedback) -and ($this.AudibleFeedback -ne $currentState.AudibleFeedback))
- {
+ if (($null -ne $this.AudibleFeedback) -and ($this.AudibleFeedback -ne $currentState.AudibleFeedback)) {
return $false
}
return $true
}
- [void] Set()
- {
+ [void] Set() {
# Only make changes if changes are needed
- if (-not $this.Test())
- {
+ if (-not $this.Test()) {
# If a value isn't set in the DSC, it should remain unchanged, to do this we need the current flags
$flags = [FilterKeys]::GetCurrentFlags()
- if ($null -ne $this.Active)
- {
+ if ($null -ne $this.Active) {
$flags = $this.Active ? $flags -bor [FilterKeysOptions]::Active : $flags -band (-bnot [FilterKeysOptions]::Active)
}
- if ($null -ne $this.Available)
- {
+ if ($null -ne $this.Available) {
$flags = $this.Available ? $flags -bor [FilterKeysOptions]::Available : $flags -band (-bnot [FilterKeysOptions]::Available)
}
- if ($null -ne $this.HotkeyActive)
- {
+ if ($null -ne $this.HotkeyActive) {
$flags = $this.HotkeyActive ? $flags -bor [FilterKeysOptions]::HotkeyActive : $flags -band (-bnot [FilterKeysOptions]::HotkeyActive)
}
- if ($null -ne $this.ConfirmOnHotkeyActivation)
- {
+ if ($null -ne $this.ConfirmOnHotkeyActivation) {
$flags = $this.ConfirmOnHotkeyActivation ? $flags -bor [FilterKeysOptions]::ConfirmHotkey : $flags -band (-bnot [FilterKeysOptions]::ConfirmHotkey)
}
- if ($null -ne $this.HotkeySound)
- {
+ if ($null -ne $this.HotkeySound) {
$flags = $this.HotkeySound ? $flags -bor [FilterKeysOptions]::HotkeySound : $flags -band (-bnot [FilterKeysOptions]::HotkeySound)
}
- if ($null -ne $this.VisualIndicator)
- {
+ if ($null -ne $this.VisualIndicator) {
$flags = $this.VisualIndicator ? $flags -bor [FilterKeysOptions]::VisualIndicator : $flags -band (-bnot [FilterKeysOptions]::VisualIndicator)
}
- if ($null -ne $this.AudibleFeedback)
- {
+ if ($null -ne $this.AudibleFeedback) {
$flags = $this.AudibleFeedback ? $flags -bor [FilterKeysOptions]::AudibleFeedback : $flags -band (-bnot [FilterKeysOptions]::AudibleFeedback)
}
@@ -1086,8 +892,7 @@ class FilterKeys
}
#region Functions
-function DoesRegistryKeyPropertyExist
-{
+function DoesRegistryKeyPropertyExist {
param (
[Parameter(Mandatory)]
[string]$Path,
@@ -1097,7 +902,7 @@ function DoesRegistryKeyPropertyExist
)
# Get-ItemProperty will return $null if the registry key property does not exist.
- $itemProperty = Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue
+ $itemProperty = Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue
return $null -ne $itemProperty
}
-#endregion Functions
\ No newline at end of file
+#endregion Functions
diff --git a/resources/Microsoft.WindowsSandbox.DSC/Microsoft.WindowsSandbox.DSC.psd1 b/resources/Microsoft.WindowsSandbox.DSC/Microsoft.WindowsSandbox.DSC.psd1
index f4ee5a25..b0540f92 100644
--- a/resources/Microsoft.WindowsSandbox.DSC/Microsoft.WindowsSandbox.DSC.psd1
+++ b/resources/Microsoft.WindowsSandbox.DSC/Microsoft.WindowsSandbox.DSC.psd1
@@ -8,126 +8,126 @@
@{
-# Script module or binary module file associated with this manifest.
-RootModule = 'Microsoft.WindowsSandbox.DSC.psm1'
+ # Script module or binary module file associated with this manifest.
+ RootModule = 'Microsoft.WindowsSandbox.DSC.psm1'
-# Version number of this module.
-ModuleVersion = '0.1.0'
+ # Version number of this module.
+ ModuleVersion = '0.1.0'
-# Supported PSEditions
-# CompatiblePSEditions = @()
+ # Supported PSEditions
+ # CompatiblePSEditions = @()
-# ID used to uniquely identify this module
-GUID = 'd5c78779-2fa7-4356-87cb-13bb41102e7e'
+ # ID used to uniquely identify this module
+ GUID = 'd5c78779-2fa7-4356-87cb-13bb41102e7e'
-# Author of this module
-Author = 'DscSamples'
+ # Author of this module
+ Author = 'DscSamples'
-# Company or vendor of this module
-# CompanyName = ''
+ # Company or vendor of this module
+ # CompanyName = ''
-# Copyright statement for this module
-# Copyright = ''
+ # Copyright statement for this module
+ # Copyright = ''
-# Description of the functionality provided by this module
-Description = 'DSC Resource for Windows Sandbox'
+ # Description of the functionality provided by this module
+ Description = 'DSC Resource for Windows Sandbox'
-# Minimum version of the PowerShell engine required by this module
-# PowerShellVersion = ''
+ # Minimum version of the PowerShell engine required by this module
+ # PowerShellVersion = ''
-# Name of the PowerShell host required by this module
-# PowerShellHostName = ''
+ # Name of the PowerShell host required by this module
+ # PowerShellHostName = ''
-# Minimum version of the PowerShell host required by this module
-# PowerShellHostVersion = ''
+ # Minimum version of the PowerShell host required by this module
+ # PowerShellHostVersion = ''
-# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
-# DotNetFrameworkVersion = ''
+ # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # DotNetFrameworkVersion = ''
-# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
-# ClrVersion = ''
+ # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # ClrVersion = ''
-# Processor architecture (None, X86, Amd64) required by this module
-# ProcessorArchitecture = ''
+ # Processor architecture (None, X86, Amd64) required by this module
+ # ProcessorArchitecture = ''
-# Modules that must be imported into the global environment prior to importing this module
-# RequiredModules = @()
+ # Modules that must be imported into the global environment prior to importing this module
+ # RequiredModules = @()
-# Assemblies that must be loaded prior to importing this module
-# RequiredAssemblies = @()
+ # Assemblies that must be loaded prior to importing this module
+ # RequiredAssemblies = @()
-# Script files (.ps1) that are run in the caller's environment prior to importing this module.
-# ScriptsToProcess = @()
+ # Script files (.ps1) that are run in the caller's environment prior to importing this module.
+ # ScriptsToProcess = @()
-# Type files (.ps1xml) to be loaded when importing this module
-# TypesToProcess = @()
+ # Type files (.ps1xml) to be loaded when importing this module
+ # TypesToProcess = @()
-# Format files (.ps1xml) to be loaded when importing this module
-# FormatsToProcess = @()
+ # Format files (.ps1xml) to be loaded when importing this module
+ # FormatsToProcess = @()
-# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
-# NestedModules = @()
+ # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+ # NestedModules = @()
-# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
-# FunctionsToExport = @()
+ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+ # FunctionsToExport = @()
-# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
-# CmdletsToExport = @()
+ # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+ # CmdletsToExport = @()
-# Variables to export from this module
-# VariablesToExport = '*'
+ # Variables to export from this module
+ # VariablesToExport = '*'
-# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
-# AliasesToExport = @()
+ # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+ # AliasesToExport = @()
-# DSC resources to export from this module
-DscResourcesToExport = @(
- 'WindowsSandbox'
-)
+ # DSC resources to export from this module
+ DscResourcesToExport = @(
+ 'WindowsSandbox'
+ )
-# List of all modules packaged with this module
-# ModuleList = @()
+ # List of all modules packaged with this module
+ # ModuleList = @()
-# List of all files packaged with this module
-# FileList = @()
+ # List of all files packaged with this module
+ # FileList = @()
-# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
-PrivateData = @{
+ # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+ PrivateData = @{
- PSData = @{
+ PSData = @{
- # Tags applied to this module. These help with module discovery in online galleries.
- Tags = @('PSDscResource_WindowsSandbox')
+ # Tags applied to this module. These help with module discovery in online galleries.
+ Tags = @('PSDscResource_WindowsSandbox')
- # A URL to the license for this module.
- # LicenseUri = ''
+ # A URL to the license for this module.
+ # LicenseUri = ''
- # A URL to the main website for this project.
- # ProjectUri = ''
+ # A URL to the main website for this project.
+ # ProjectUri = ''
- # A URL to an icon representing this module.
- # IconUri = ''
+ # A URL to an icon representing this module.
+ # IconUri = ''
- # ReleaseNotes of this module
- # ReleaseNotes = ''
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
- # Prerelease string of this module
- Prerelease = 'alpha'
+ # Prerelease string of this module
+ Prerelease = 'alpha'
- # Flag to indicate whether the module requires explicit user acceptance for install/update/save
- # RequireLicenseAcceptance = $false
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
- # External dependent modules of this module
- # ExternalModuleDependencies = @()
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
- } # End of PSData hashtable
+ } # End of PSData hashtable
-} # End of PrivateData hashtable
+ } # End of PrivateData hashtable
-# HelpInfo URI of this module
-# HelpInfoURI = ''
+ # HelpInfo URI of this module
+ # HelpInfoURI = ''
-# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
-# DefaultCommandPrefix = ''
+ # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+ # DefaultCommandPrefix = ''
}
diff --git a/resources/Microsoft.WindowsSandbox.DSC/Microsoft.WindowsSandbox.DSC.psm1 b/resources/Microsoft.WindowsSandbox.DSC/Microsoft.WindowsSandbox.DSC.psm1
index a22fb73f..b5902d7d 100644
--- a/resources/Microsoft.WindowsSandbox.DSC/Microsoft.WindowsSandbox.DSC.psm1
+++ b/resources/Microsoft.WindowsSandbox.DSC/Microsoft.WindowsSandbox.DSC.psm1
@@ -1,22 +1,19 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
-enum Ensure
-{
+enum Ensure {
Absent
Present
}
-$global:WindowsSandboxExePath = "C:\Windows\System32\WindowsSandbox.exe"
+$global:WindowsSandboxExePath = 'C:\Windows\System32\WindowsSandbox.exe'
-if (-not(Test-Path -Path $global:WindowsSandboxExePath))
-{
- throw "Windows Sandbox feature is not enabled."
+if (-not(Test-Path -Path $global:WindowsSandboxExePath)) {
+ throw 'Windows Sandbox feature is not enabled.'
}
#region DSCResources
[DSCResource()]
-class WindowsSandbox
-{
+class WindowsSandbox {
[DscProperty(Key)]
[Ensure]$Ensure = [Ensure]::Present
@@ -28,13 +25,13 @@ class WindowsSandbox
[DscProperty()]
[string]$SandboxFolder
-
+
[DscProperty()]
[string]$ReadOnly
[DscProperty()]
[string]$LogonCommand
-
+
[DscProperty()]
[nullable[Int64]]$MemoryInMB
@@ -59,49 +56,41 @@ class WindowsSandbox
[DscProperty()]
[nullable[bool]]$VideoInput
- [WindowsSandbox] Get()
- {
+ [WindowsSandbox] Get() {
$currentState = [WindowsSandbox]::new()
$currentState.WsbFilePath = $this.WsbFilePath
$windowsSandboxProcess = Get-Process WindowsSandbox -ErrorAction SilentlyContinue
$currentState.Ensure = $windowsSandboxProcess ? [Ensure]::Present : [Ensure]::Absent
-
+
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
return $currentState.Ensure -eq $this.Ensure
}
- [void] Set()
- {
+ [void] Set() {
# If ensure absent, stop the current Windows Sandbox process.
- if ($this.Ensure -eq [Ensure]::Absent)
- {
+ if ($this.Ensure -eq [Ensure]::Absent) {
Stop-Process -Name 'WindowsSandboxClient' -Force
return
}
- # Load the existing wsb file if it exists or create a new one.
- if ($this.WsbFilePath)
- {
- if (-not(Test-Path -Path $this.WsbFilePath))
- {
- throw "The provided wsb file does not exist."
+ # Load the existing WSB file if it exists or create a new one.
+ if ($this.WsbFilePath) {
+ if (-not(Test-Path -Path $this.WsbFilePath)) {
+ throw 'The provided WSB file does not exist.'
}
$xml = [xml](Get-Content -Path $this.WsbFilePath)
$root = $xml.Configuration
- }
- else
- {
+ } else {
$xml = New-Object -TypeName System.Xml.XmlDocument
- $root = $xml.CreateElement("Configuration")
+ $root = $xml.CreateElement('Configuration')
$xml.AppendChild($root)
}
-
+
<# Example Windows Sandbox configuration file (xml):
Disable
@@ -122,155 +111,131 @@ class WindowsSandbox
Disable
Enable
2048
-
+
#>
# Override existing configurations if exists.
- if ($this.HostFolder)
- {
- if (-not(Test-Path -Path $this.HostFolder))
- {
- throw "Specified host folder path does not exist."
+ if ($this.HostFolder) {
+ if (-not(Test-Path -Path $this.HostFolder)) {
+ throw 'Specified host folder path does not exist.'
}
# Remove existing mapped folder
- if ($root.MappedFolders)
- {
- $existingMappedFolders = $root.SelectSingleNode("MappedFolders")
+ if ($root.MappedFolders) {
+ $existingMappedFolders = $root.SelectSingleNode('MappedFolders')
$root.RemoveChild($existingMappedFolders)
}
# Create Mapped Folders element
- $mappedFoldersElement = $xml.CreateElement("MappedFolders")
- $mappedFolderElement = $xml.CreateElement("MappedFolder")
- $hostFolderElement = $xml.CreateElement("HostFolder")
+ $mappedFoldersElement = $xml.CreateElement('MappedFolders')
+ $mappedFolderElement = $xml.CreateElement('MappedFolder')
+ $hostFolderElement = $xml.CreateElement('HostFolder')
$mappedFolderElement.AppendChild($hostFolderElement)
$mappedFoldersElement.AppendChild($mappedFolderElement)
$root.AppendChild($mappedFoldersElement)
$root.MappedFolders.MappedFolder.HostFolder = $this.HostFolder
- if ($this.SandboxFolder)
- {
- $sandboxFolderElement = $xml.CreateElement("SandboxFolder")
+ if ($this.SandboxFolder) {
+ $sandboxFolderElement = $xml.CreateElement('SandboxFolder')
$mappedFolderElement.AppendChild($sandboxFolderElement)
$root.MappedFolders.MappedFolder.SandboxFolder = $this.SandboxFolder
}
- if ($this.ReadOnly)
- {
- $readOnlyElement = $xml.CreateElement("ReadOnly")
+ if ($this.ReadOnly) {
+ $readOnlyElement = $xml.CreateElement('ReadOnly')
$mappedFolderElement.AppendChild($readOnlyElement)
$root.MappedFolders.MappedFolder.ReadOnly = 'true'
}
}
- if ($this.LogonCommand)
- {
- if ($root.LogonCommand)
- {
+ if ($this.LogonCommand) {
+ if ($root.LogonCommand) {
$existingLogonCommand = $root.SelectSingleNode('LogonCommand')
$root.RemoveChild($existingLogonCommand)
}
$logonCommandElement = $xml.CreateElement('LogonCommand')
- $commandElement = $xml.CreateElement("Command")
+ $commandElement = $xml.CreateElement('Command')
$logonCommandElement.AppendChild($commandElement)
$root.AppendChild($logonCommandElement)
$root.LogonCommand.Command = $this.LogonCommand
}
- if ($this.MemoryInMB)
- {
- if ($null -eq $root.MemoryInMB)
- {
- $memoryElement = $xml.CreateElement("MemoryInMB")
+ if ($this.MemoryInMB) {
+ if ($null -eq $root.MemoryInMB) {
+ $memoryElement = $xml.CreateElement('MemoryInMB')
$root.AppendChild($memoryElement)
}
$root.MemoryInMB = $this.MemoryInMB
}
- if ($null -ne $this.vGPU)
- {
- if ($null -eq $root.vGPU)
- {
- $vGPUElement = $xml.CreateElement("vGPU")
+ if ($null -ne $this.vGPU) {
+ if ($null -eq $root.vGPU) {
+ $vGPUElement = $xml.CreateElement('vGPU')
$root.AppendChild($vGPUElement)
}
$root.vGPU = ConvertBoolToEnableDisable($this.vGPU)
}
- if ($null -ne $this.AudioInput)
- {
- if ($null -eq $root.AudioInput)
- {
- $audioInputElement = $xml.CreateElement("AudioInput")
+ if ($null -ne $this.AudioInput) {
+ if ($null -eq $root.AudioInput) {
+ $audioInputElement = $xml.CreateElement('AudioInput')
$root.AppendChild($audioInputElement)
}
$root.AudioInput = ConvertBoolToEnableDisable($this.AudioInput)
}
- if ($null -ne $this.ClipboardRedirection)
- {
- if ($null -eq $root.ClipboardRedirection)
- {
- $clipboardRedirectionElement = $xml.CreateElement("ClipboardRedirection")
+ if ($null -ne $this.ClipboardRedirection) {
+ if ($null -eq $root.ClipboardRedirection) {
+ $clipboardRedirectionElement = $xml.CreateElement('ClipboardRedirection')
$root.AppendChild($clipboardRedirectionElement)
}
$root.ClipboardRedirection = ConvertBoolToEnableDisable($this.ClipboardRedirection)
}
- if ($null -ne $this.Networking)
- {
- if ($null -eq $root.Networking)
- {
- $networkingElement = $xml.CreateElement("Networking")
+ if ($null -ne $this.Networking) {
+ if ($null -eq $root.Networking) {
+ $networkingElement = $xml.CreateElement('Networking')
$root.AppendChild($networkingElement)
}
$root.Networking = ConvertBoolToEnableDisable($this.Networking)
}
- if ($null -ne $this.PrinterRedirection)
- {
- if ($null -eq $root.PrinterRedirection)
- {
- $printerRedirectionElement = $xml.CreateElement("PrinterRedirection")
+ if ($null -ne $this.PrinterRedirection) {
+ if ($null -eq $root.PrinterRedirection) {
+ $printerRedirectionElement = $xml.CreateElement('PrinterRedirection')
$root.AppendChild($printerRedirectionElement)
}
$root.PrinterRedirection = ConvertBoolToEnableDisable($this.PrinterRedirection)
}
- if ($null -ne $this.ProtectedClient)
- {
- if ($null -eq $root.ProtectedClient)
- {
- $protectedClientElement = $xml.CreateElement("ProtectedClient")
+ if ($null -ne $this.ProtectedClient) {
+ if ($null -eq $root.ProtectedClient) {
+ $protectedClientElement = $xml.CreateElement('ProtectedClient')
$root.AppendChild($protectedClientElement)
}
$root.ProtectedClient = ConvertBoolToEnableDisable($this.ProtectedClient)
}
- if ($null -ne $this.VideoInput)
- {
- if ($null -eq $root.VideoInput)
- {
- $videoInputElement = $xml.CreateElement("VideoInput")
+ if ($null -ne $this.VideoInput) {
+ if ($null -eq $root.VideoInput) {
+ $videoInputElement = $xml.CreateElement('VideoInput')
$root.AppendChild($videoInputElement)
}
$root.VideoInput = ConvertBoolToEnableDisable($this.VideoInput)
}
- # Export wsb file and run.
+ # Export WSB file and run.
$windowsSandboxDscTempDir = "$($env:Temp)\WindowsSandboxDsc"
- if (-not (Test-Path -Path $windowsSandboxDscTempDir))
- {
+ if (-not (Test-Path -Path $windowsSandboxDscTempDir)) {
New-Item -ItemType Directory -Path $windowsSandboxDscTempDir
}
@@ -285,8 +250,7 @@ class WindowsSandbox
#region Functions
-function ConvertBoolToEnableDisable()
-{
+function ConvertBoolToEnableDisable() {
param (
[Parameter()]
[bool]$value
@@ -295,4 +259,4 @@ function ConvertBoolToEnableDisable()
return $value ? 'Enable' : 'Disable'
}
-#endregion Functions
\ No newline at end of file
+#endregion Functions
diff --git a/resources/NpmDsc/NpmDsc.psd1 b/resources/NpmDsc/NpmDsc.psd1
index 82f73dba..ad578a96 100644
--- a/resources/NpmDsc/NpmDsc.psd1
+++ b/resources/NpmDsc/NpmDsc.psd1
@@ -8,128 +8,128 @@
@{
-# Script module or binary module file associated with this manifest.
-RootModule = 'NpmDsc.psm1'
+ # Script module or binary module file associated with this manifest.
+ RootModule = 'NpmDsc.psm1'
-# Version number of this module.
-ModuleVersion = '0.1.0'
+ # Version number of this module.
+ ModuleVersion = '0.1.0'
-# Supported PSEditions
-# CompatiblePSEditions = @()
+ # Supported PSEditions
+ # CompatiblePSEditions = @()
-# ID used to uniquely identify this module
-GUID = '83174a20-df73-4d9f-8ddf-b4bf51da5089'
+ # ID used to uniquely identify this module
+ GUID = '83174a20-df73-4d9f-8ddf-b4bf51da5089'
-# Author of this module
-Author = 'DscSamples'
+ # Author of this module
+ Author = 'DscSamples'
-# Company or vendor of this module
-# CompanyName = ''
+ # Company or vendor of this module
+ # CompanyName = ''
-# Copyright statement for this module
-# Copyright = ''
+ # Copyright statement for this module
+ # Copyright = ''
-# Description of the functionality provided by this module
-Description = 'DSC Resource for Npm'
+ # Description of the functionality provided by this module
+ Description = 'DSC Resource for Npm'
-# Minimum version of the PowerShell engine required by this module
-# PowerShellVersion = ''
+ # Minimum version of the PowerShell engine required by this module
+ # PowerShellVersion = ''
-# Name of the PowerShell host required by this module
-# PowerShellHostName = ''
+ # Name of the PowerShell host required by this module
+ # PowerShellHostName = ''
-# Minimum version of the PowerShell host required by this module
-# PowerShellHostVersion = ''
+ # Minimum version of the PowerShell host required by this module
+ # PowerShellHostVersion = ''
-# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
-# DotNetFrameworkVersion = ''
+ # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # DotNetFrameworkVersion = ''
-# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
-# ClrVersion = ''
+ # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # ClrVersion = ''
-# Processor architecture (None, X86, Amd64) required by this module
-# ProcessorArchitecture = ''
+ # Processor architecture (None, X86, Amd64) required by this module
+ # ProcessorArchitecture = ''
-# Modules that must be imported into the global environment prior to importing this module
-# RequiredModules = @()
+ # Modules that must be imported into the global environment prior to importing this module
+ # RequiredModules = @()
-# Assemblies that must be loaded prior to importing this module
-# RequiredAssemblies = @()
+ # Assemblies that must be loaded prior to importing this module
+ # RequiredAssemblies = @()
-# Script files (.ps1) that are run in the caller's environment prior to importing this module.
-# ScriptsToProcess = @()
+ # Script files (.ps1) that are run in the caller's environment prior to importing this module.
+ # ScriptsToProcess = @()
-# Type files (.ps1xml) to be loaded when importing this module
-# TypesToProcess = @()
+ # Type files (.ps1xml) to be loaded when importing this module
+ # TypesToProcess = @()
-# Format files (.ps1xml) to be loaded when importing this module
-# FormatsToProcess = @()
+ # Format files (.ps1xml) to be loaded when importing this module
+ # FormatsToProcess = @()
-# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
-# NestedModules = @()
+ # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+ # NestedModules = @()
-# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
-# FunctionsToExport = @()
+ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+ # FunctionsToExport = @()
-# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
-# CmdletsToExport = @()
+ # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+ # CmdletsToExport = @()
-# Variables to export from this module
-# VariablesToExport = '*'
+ # Variables to export from this module
+ # VariablesToExport = '*'
-# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
-# AliasesToExport = @()
+ # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+ # AliasesToExport = @()
-# DSC resources to export from this module
-DscResourcesToExport = @(
- 'NpmPackage',
- 'NpmInstall'
-)
+ # DSC resources to export from this module
+ DscResourcesToExport = @(
+ 'NpmPackage',
+ 'NpmInstall'
+ )
-# List of all modules packaged with this module
-# ModuleList = @()
+ # List of all modules packaged with this module
+ # ModuleList = @()
-# List of all files packaged with this module
-# FileList = @()
+ # List of all files packaged with this module
+ # FileList = @()
-# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
-PrivateData = @{
+ # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+ PrivateData = @{
- PSData = @{
+ PSData = @{
- # Tags applied to this module. These help with module discovery in online galleries.
- Tags = @('PSDscResource_DSC_NpmPackage', 'PSDscResource_DSC_NpmInstall')
+ # Tags applied to this module. These help with module discovery in online galleries.
+ Tags = @('PSDscResource_DSC_NpmPackage', 'PSDscResource_DSC_NpmInstall')
- # A URL to the license for this module.
- # LicenseUri = ''
+ # A URL to the license for this module.
+ # LicenseUri = ''
- # A URL to the main website for this project.
- # ProjectUri = ''
+ # A URL to the main website for this project.
+ # ProjectUri = ''
- # A URL to an icon representing this module.
- # IconUri = ''
+ # A URL to an icon representing this module.
+ # IconUri = ''
- # ReleaseNotes of this module
- # ReleaseNotes = ''
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
- # Prerelease string of this module
- Prerelease = 'alpha'
+ # Prerelease string of this module
+ Prerelease = 'alpha'
- # Flag to indicate whether the module requires explicit user acceptance for install/update/save
- # RequireLicenseAcceptance = $false
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
- # External dependent modules of this module
- # ExternalModuleDependencies = @()
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
- } # End of PSData hashtable
+ } # End of PSData hashtable
-} # End of PrivateData hashtable
+ } # End of PrivateData hashtable
-# HelpInfo URI of this module
-# HelpInfoURI = ''
+ # HelpInfo URI of this module
+ # HelpInfoURI = ''
-# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
-# DefaultCommandPrefix = ''
+ # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+ # DefaultCommandPrefix = ''
}
diff --git a/resources/NpmDsc/NpmDsc.psm1 b/resources/NpmDsc/NpmDsc.psm1
index 58bab9cf..291da606 100644
--- a/resources/NpmDsc/NpmDsc.psm1
+++ b/resources/NpmDsc/NpmDsc.psm1
@@ -1,7 +1,6 @@
using namespace System.Collections.Generic
#Region '.\Enum\Ensure.ps1' 0
-enum Ensure
-{
+enum Ensure {
Absent
Present
}
@@ -9,8 +8,7 @@ enum Ensure
#Region '.\Classes\DSCResources\NpmInstall.ps1' 0
#using namespace System.Collections.Generic
[DSCResource()]
-class NpmInstall
-{
+class NpmInstall {
[DscProperty()]
[Ensure]$Ensure = [Ensure]::Present
@@ -26,12 +24,10 @@ class NpmInstall
[DscProperty()]
[string]$Arguments
- [NpmInstall] Get()
- {
+ [NpmInstall] Get() {
Assert-Npm
- if (-not([string]::IsNullOrEmpty($this.PackageDirectory)))
- {
+ if (-not([string]::IsNullOrEmpty($this.PackageDirectory))) {
Set-PackageDirectory -PackageDirectory $this.PackageDirectory
}
@@ -39,11 +35,9 @@ class NpmInstall
$currentState.Ensure = [Ensure]::Present
$errorResult = Get-InstalledNpmPackages -Global $this.Global | ConvertFrom-Json | Select-Object -ExpandProperty error
- if ($errorResult.PSobject.Properties.Name -contains 'code')
- {
+ if ($errorResult.PSobject.Properties.Name -contains 'code') {
$errorCode = $errorResult | Select-Object -ExpandProperty code
- if ($errorCode -eq 'ELSPROBLEMS')
- {
+ if ($errorCode -eq 'ELSPROBLEMS') {
$currentState.Ensure = [Ensure]::Absent
}
}
@@ -54,29 +48,21 @@ class NpmInstall
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
return $this.Ensure -eq $currentState.Ensure
}
- [void] Set()
- {
+ [void] Set() {
$inDesiredState = $this.Test()
- if ($this.Ensure -eq [Ensure]::Present)
- {
- if (-not $inDesiredState)
- {
+ if ($this.Ensure -eq [Ensure]::Present) {
+ if (-not $inDesiredState) {
Install-NpmPackage -Arguments $this.Arguments -Global $this.Global
}
- }
- else
- {
- if (-not $inDesiredState)
- {
+ } else {
+ if (-not $inDesiredState) {
$nodeModulesFolder = 'node_modules'
- if (Test-Path -Path $nodeModulesFolder)
- {
+ if (Test-Path -Path $nodeModulesFolder) {
Remove-Item $nodeModulesFolder -Recurse
}
}
@@ -86,8 +72,7 @@ class NpmInstall
#EndRegion '.\Classes\DSCResources\NpmInstall.ps1' 77
#Region '.\Classes\DSCResources\NpmPackage.ps1' 0
[DSCResource()]
-class NpmPackage
-{
+class NpmPackage {
[DscProperty()]
[Ensure]$Ensure = [Ensure]::Present
@@ -106,12 +91,10 @@ class NpmPackage
[DscProperty()]
[string]$Arguments
- [NpmPackage] Get()
- {
+ [NpmPackage] Get() {
Assert-Npm
- if (-not([string]::IsNullOrEmpty($this.PackageDirectory)))
- {
+ if (-not([string]::IsNullOrEmpty($this.PackageDirectory))) {
Set-PackageDirectory -PackageDirectory $this.PackageDirectory
}
@@ -119,21 +102,16 @@ class NpmPackage
$currentState.Ensure = [Ensure]::Absent
$installedPackages = Get-InstalledNpmPackages -Global $this.Global | ConvertFrom-Json | Select-Object -ExpandProperty dependencies
- if ($installedPackages.PSobject.Properties.Name -contains $this.Name)
- {
+ if ($installedPackages.PSobject.Properties.Name -contains $this.Name) {
$installedPackage = $installedPackages | Select-Object -ExpandProperty $this.Name
# Check if version matches if specified.
- if (-not([string]::IsNullOrEmpty($this.Version)))
- {
+ if (-not([string]::IsNullOrEmpty($this.Version))) {
$installedVersion = $installedPackage.Version
- if ([System.Version]$installedVersion -eq [System.Version]$this.Version)
- {
+ if ([System.Version]$installedVersion -eq [System.Version]$this.Version) {
$currentState.Ensure = [Ensure]::Present
}
- }
- else
- {
+ } else {
$currentState.Ensure = [Ensure]::Present
}
}
@@ -146,26 +124,19 @@ class NpmPackage
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
return $this.Ensure -eq $currentState.Ensure
}
- [void] Set()
- {
+ [void] Set() {
$inDesiredState = $this.Test()
- if ($this.Ensure -eq [Ensure]::Present)
- {
- if (-not $inDesiredState)
- {
+ if ($this.Ensure -eq [Ensure]::Present) {
+ if (-not $inDesiredState) {
Install-NpmPackage -PackageName $this.Name -Arguments $this.Arguments -Global $this.Global
}
- }
- else
- {
- if (-not $inDesiredState)
- {
+ } else {
+ if (-not $inDesiredState) {
Uninstall-NpmPackage -PackageName $this.Name -Arguments $this.Arguments -Global $this.Global
}
}
@@ -173,24 +144,19 @@ class NpmPackage
}
#EndRegion '.\Classes\DSCResources\NpmPackage.ps1' 87
#Region '.\Private\Assert-Npm.ps1' 0
-function Assert-Npm
-{
+function Assert-Npm {
# Refresh session $path value before invoking 'npm'
- $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
- try
- {
+ $env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'User')
+ try {
Invoke-Npm -Command 'help'
return
- }
- catch
- {
- throw "NodeJS is not installed"
+ } catch {
+ throw 'NodeJS is not installed'
}
}
#EndRegion '.\Private\Assert-Npm.ps1' 15
#Region '.\Private\Invoke-Npm.ps1' 0
-function Invoke-Npm
-{
+function Invoke-Npm {
param (
[Parameter(Mandatory = $true)]
[string]$Command
@@ -200,26 +166,21 @@ function Invoke-Npm
}
#EndRegion '.\Private\Invoke-Npm.ps1' 10
#Region '.\Private\Set-PackageDirectory.ps1' 0
-function Set-PackageDirectory
-{
+function Set-PackageDirectory {
param (
[Parameter(Mandatory = $true)]
[string]$PackageDirectory
)
- if (Test-Path -Path $PackageDirectory -PathType Container)
- {
+ if (Test-Path -Path $PackageDirectory -PathType Container) {
Set-Location -Path $PackageDirectory
- }
- else
- {
+ } else {
throw "$($PackageDirectory) does not point to a valid directory."
}
}
#EndRegion '.\Private\Set-PackageDirectory.ps1' 17
#Region '.\Public\Get-InstalledNpmPackages.ps1' 0
-function Get-InstalledNpmPackages
-{
+function Get-InstalledNpmPackages {
param (
[Parameter()]
[bool]$Global
@@ -229,17 +190,15 @@ function Get-InstalledNpmPackages
$command.Add('list')
$command.Add('--json')
- if ($Global)
- {
+ if ($Global) {
$command.Add('-g')
}
- return Invoke-Npm -command $command
+ return Invoke-Npm -Command $command
}
#EndRegion '.\Public\Get-InstalledNpmPackages.ps1' 19
#Region '.\Public\Install-NpmPackage.ps1' 0
-function Install-NpmPackage
-{
+function Install-NpmPackage {
param (
[Parameter()]
[string]$PackageName,
@@ -252,22 +211,20 @@ function Install-NpmPackage
)
$command = [List[string]]::new()
- $command.Add("install")
+ $command.Add('install')
$command.Add($PackageName)
- if ($Global)
- {
- $command.Add("-g")
+ if ($Global) {
+ $command.Add('-g')
}
$command.Add($Arguments)
- return Invoke-Npm -command $command
+ return Invoke-Npm -Command $command
}
#EndRegion '.\Public\Install-NpmPackage.ps1' 27
#Region '.\Public\Uninstall-NpmPackage.ps1' 0
-function Uninstall-NpmPackage
-{
+function Uninstall-NpmPackage {
param (
[Parameter(Mandatory = $true)]
[string]$PackageName,
@@ -280,16 +237,15 @@ function Uninstall-NpmPackage
)
$command = [List[string]]::new()
- $command.Add("uninstall")
+ $command.Add('uninstall')
$command.Add($PackageName)
- if ($Global)
- {
+ if ($Global) {
$command.Add('-g')
}
$command.Add($Arguments)
- return Invoke-Npm -command $command
+ return Invoke-Npm -Command $command
}
#EndRegion '.\Public\Uninstall-NpmPackage.ps1' 27
diff --git a/resources/PythonPip3Dsc/PythonPip3Dsc.psd1 b/resources/PythonPip3Dsc/PythonPip3Dsc.psd1
index cebf75ed..642af568 100644
--- a/resources/PythonPip3Dsc/PythonPip3Dsc.psd1
+++ b/resources/PythonPip3Dsc/PythonPip3Dsc.psd1
@@ -8,127 +8,127 @@
@{
-# Script module or binary module file associated with this manifest.
-RootModule = 'PythonPip3Dsc.psm1'
+ # Script module or binary module file associated with this manifest.
+ RootModule = 'PythonPip3Dsc.psm1'
-# Version number of this module.
-ModuleVersion = '0.1.0'
+ # Version number of this module.
+ ModuleVersion = '0.1.0'
-# Supported PSEditions
-# CompatiblePSEditions = @()
+ # Supported PSEditions
+ # CompatiblePSEditions = @()
-# ID used to uniquely identify this module
-GUID = 'bc1cab01-7e6f-4bba-a6ec-d77d0ffe91c7'
+ # ID used to uniquely identify this module
+ GUID = 'bc1cab01-7e6f-4bba-a6ec-d77d0ffe91c7'
-# Author of this module
-Author = 'DscSamples'
+ # Author of this module
+ Author = 'DscSamples'
-# Company or vendor of this module
-# CompanyName = ''
+ # Company or vendor of this module
+ # CompanyName = ''
-# Copyright statement for this module
-# Copyright = ''
+ # Copyright statement for this module
+ # Copyright = ''
-# Description of the functionality provided by this module
-Description = 'DSC Resource for Python pip3'
+ # Description of the functionality provided by this module
+ Description = 'DSC Resource for Python pip3'
-# Minimum version of the PowerShell engine required by this module
-# PowerShellVersion = ''
+ # Minimum version of the PowerShell engine required by this module
+ # PowerShellVersion = ''
-# Name of the PowerShell host required by this module
-# PowerShellHostName = ''
+ # Name of the PowerShell host required by this module
+ # PowerShellHostName = ''
-# Minimum version of the PowerShell host required by this module
-# PowerShellHostVersion = ''
+ # Minimum version of the PowerShell host required by this module
+ # PowerShellHostVersion = ''
-# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
-# DotNetFrameworkVersion = ''
+ # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # DotNetFrameworkVersion = ''
-# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
-# ClrVersion = ''
+ # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # ClrVersion = ''
-# Processor architecture (None, X86, Amd64) required by this module
-# ProcessorArchitecture = ''
+ # Processor architecture (None, X86, Amd64) required by this module
+ # ProcessorArchitecture = ''
-# Modules that must be imported into the global environment prior to importing this module
-# RequiredModules = @()
+ # Modules that must be imported into the global environment prior to importing this module
+ # RequiredModules = @()
-# Assemblies that must be loaded prior to importing this module
-# RequiredAssemblies = @()
+ # Assemblies that must be loaded prior to importing this module
+ # RequiredAssemblies = @()
-# Script files (.ps1) that are run in the caller's environment prior to importing this module.
-# ScriptsToProcess = @()
+ # Script files (.ps1) that are run in the caller's environment prior to importing this module.
+ # ScriptsToProcess = @()
-# Type files (.ps1xml) to be loaded when importing this module
-# TypesToProcess = @()
+ # Type files (.ps1xml) to be loaded when importing this module
+ # TypesToProcess = @()
-# Format files (.ps1xml) to be loaded when importing this module
-# FormatsToProcess = @()
+ # Format files (.ps1xml) to be loaded when importing this module
+ # FormatsToProcess = @()
-# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
-# NestedModules = @()
+ # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+ # NestedModules = @()
-# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
-# FunctionsToExport = @()
+ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+ # FunctionsToExport = @()
-# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
-# CmdletsToExport = @()
+ # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+ # CmdletsToExport = @()
-# Variables to export from this module
-# VariablesToExport = '*'
+ # Variables to export from this module
+ # VariablesToExport = '*'
-# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
-# AliasesToExport = @()
+ # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+ # AliasesToExport = @()
-# DSC resources to export from this module
-DscResourcesToExport = @(
- 'Pip3Package'
-)
+ # DSC resources to export from this module
+ DscResourcesToExport = @(
+ 'Pip3Package'
+ )
-# List of all modules packaged with this module
-# ModuleList = @()
+ # List of all modules packaged with this module
+ # ModuleList = @()
-# List of all files packaged with this module
-# FileList = @()
+ # List of all files packaged with this module
+ # FileList = @()
-# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
-PrivateData = @{
+ # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+ PrivateData = @{
- PSData = @{
+ PSData = @{
- # Tags applied to this module. These help with module discovery in online galleries.
- Tags = @('PSDscResource_Pip3Package')
+ # Tags applied to this module. These help with module discovery in online galleries.
+ Tags = @('PSDscResource_Pip3Package')
- # A URL to the license for this module.
- LicenseUri = 'https://github.com/microsoft/winget-dsc/blob/main/LICENSE'
+ # A URL to the license for this module.
+ LicenseUri = 'https://github.com/microsoft/winget-dsc/blob/main/LICENSE'
- # A URL to the main website for this project.
- ProjectUri = 'https://github.com/microsoft/winget-dsc'
+ # A URL to the main website for this project.
+ ProjectUri = 'https://github.com/microsoft/winget-dsc'
- # A URL to an icon representing this module.
- # IconUri = ''
+ # A URL to an icon representing this module.
+ # IconUri = ''
- # ReleaseNotes of this module
- # ReleaseNotes = ''
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
- # Prerelease string of this module
- Prerelease = 'alpha'
+ # Prerelease string of this module
+ Prerelease = 'alpha'
- # Flag to indicate whether the module requires explicit user acceptance for install/update/save
- # RequireLicenseAcceptance = $false
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
- # External dependent modules of this module
- # ExternalModuleDependencies = @()
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
- } # End of PSData hashtable
+ } # End of PSData hashtable
-} # End of PrivateData hashtable
+ } # End of PrivateData hashtable
-# HelpInfo URI of this module
-# HelpInfoURI = ''
+ # HelpInfo URI of this module
+ # HelpInfoURI = ''
-# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
-# DefaultCommandPrefix = ''
+ # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+ # DefaultCommandPrefix = ''
}
diff --git a/resources/PythonPip3Dsc/PythonPip3Dsc.psm1 b/resources/PythonPip3Dsc/PythonPip3Dsc.psm1
index 1a138b36..428fe494 100644
--- a/resources/PythonPip3Dsc/PythonPip3Dsc.psm1
+++ b/resources/PythonPip3Dsc/PythonPip3Dsc.psm1
@@ -4,97 +4,74 @@
using namespace System.Collections.Generic
#region Functions
-function Get-Pip3Path
-{
- if ($IsWindows)
- {
+function Get-Pip3Path {
+ if ($IsWindows) {
# Note: When installing 64-bit version, the registry key: HKLM:\SOFTWARE\Wow6432Node\Python\PythonCore\*\InstallPath was empty.
- $userUninstallRegistry = "HKCU:\SOFTWARE\Python\PythonCore\*\InstallPath"
- $machineUninstallRegistry = "HKLM:\SOFTWARE\Python\PythonCore\*\InstallPath"
- $installLocationProperty = "ExecutablePath"
+ $userUninstallRegistry = 'HKCU:\SOFTWARE\Python\PythonCore\*\InstallPath'
+ $machineUninstallRegistry = 'HKLM:\SOFTWARE\Python\PythonCore\*\InstallPath'
+ $installLocationProperty = 'ExecutablePath'
$pipExe = TryGetRegistryValue -Key $userUninstallRegistry -Property $installLocationProperty
- if ($null -ne $pipExe)
- {
- $userInstallLocation = Join-Path (Split-Path $pipExe -Parent) "Scripts\pip3.exe"
- if ($userInstallLocation)
- {
+ if ($null -ne $pipExe) {
+ $userInstallLocation = Join-Path (Split-Path $pipExe -Parent) 'Scripts\pip3.exe'
+ if ($userInstallLocation) {
return $userInstallLocation
}
}
$pipExe = TryGetRegistryValue -Key $machineUninstallRegistry -Property $installLocationProperty
- if ($null -ne $pipExe)
- {
- $machineInstallLocation = Join-Path (Split-Path $pipExe -Parent) "Scripts\pip3.exe"
- if ($machineInstallLocation)
- {
+ if ($null -ne $pipExe) {
+ $machineInstallLocation = Join-Path (Split-Path $pipExe -Parent) 'Scripts\pip3.exe'
+ if ($machineInstallLocation) {
return $machineInstallLocation
}
}
- }
- elseif ($IsMacOS)
- {
+ } elseif ($IsMacOS) {
$pipExe = Join-Path '/Library' 'Frameworks' 'Python.framework' 'Versions' 'Current' 'bin' 'python'
- if (Test-Path -Path $pipExe)
- {
+ if (Test-Path -Path $pipExe) {
return $pipExe
}
$pipExe = (Get-Command -Name 'pip3' -ErrorAction SilentlyContinue).Source
- if ($pipExe)
- {
+ if ($pipExe) {
return $pipExe
}
- }
- elseif ($IsLinux)
- {
+ } elseif ($IsLinux) {
$pipExe = Join-Path '/usr/bin' 'pip3'
- if (Test-Path $pipExe)
- {
+ if (Test-Path $pipExe) {
return $pipExe
}
$pipExe = (Get-Command -Name 'pip3' -ErrorAction SilentlyContinue).Source
- if ($pipExe)
- {
+ if ($pipExe) {
return $pipExe
}
- }
- else
- {
- throw "Operating system not supported."
+ } else {
+ throw 'Operating system not supported.'
}
}
-function Assert-Pip3
-{
+function Assert-Pip3 {
# Try invoking pip3 help with the alias. If it fails, switch to calling npm.cmd directly.
# This may occur if npm is installed in the same shell window and the alias is not updated until the shell window is restarted.
- try
- {
+ try {
Invoke-Pip3 -command 'help'
return
- }
- catch {}
+ } catch {}
- if (Test-Path -Path $global:pip3ExePath)
- {
- $global:usePip3Exe = $true;
+ if (Test-Path -Path $global:pip3ExePath) {
+ $global:usePip3Exe = $true
Write-Verbose "Calling pip3.exe from install location: $global:usePip3Exe"
- }
- else
- {
- throw "Python is not installed"
+ } else {
+ throw 'Python is not installed'
}
}
-function Get-PackageNameWithVersion
-{
+function Get-PackageNameWithVersion {
param (
[Parameter(Mandatory = $true)]
[string]$PackageName,
@@ -109,16 +86,14 @@ function Get-PackageNameWithVersion
[switch]$IsUpdate
)
- if ($PSBoundParameters.ContainsKey('Version') -and -not ([string]::IsNullOrEmpty($Version)))
- {
- $packageName = $PackageName + "==" + $Version
+ if ($PSBoundParameters.ContainsKey('Version') -and -not ([string]::IsNullOrEmpty($Version))) {
+ $packageName = $PackageName + '==' + $Version
}
return $packageName
}
-function Invoke-Pip3Install
-{
+function Invoke-Pip3Install {
param (
[Parameter()]
[string]$PackageName,
@@ -134,18 +109,16 @@ function Invoke-Pip3Install
)
$command = [List[string]]::new()
- $command.Add("install")
+ $command.Add('install')
$command.Add((Get-PackageNameWithVersion @PSBoundParameters))
- if ($IsUpdate.IsPresent)
- {
- $command.Add("--force-reinstall")
+ if ($IsUpdate.IsPresent) {
+ $command.Add('--force-reinstall')
}
$command.Add($Arguments)
return Invoke-Pip3 -command $command
}
-function Invoke-Pip3Uninstall
-{
+function Invoke-Pip3Uninstall {
param (
[Parameter()]
[string]$PackageName,
@@ -158,17 +131,16 @@ function Invoke-Pip3Uninstall
)
$command = [List[string]]::new()
- $command.Add("uninstall")
+ $command.Add('uninstall')
$command.Add((Get-PackageNameWithVersion @PSBoundParameters))
$command.Add($Arguments)
- # '--yes' is needed to ignore confrimation required for uninstalls
- $command.Add("--yes")
+ # '--yes' is needed to ignore confirmation required for uninstalls
+ $command.Add('--yes')
return Invoke-Pip3 -command $command
}
-function GetPip3CurrentState
-{
+function GetPip3CurrentState {
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
@@ -176,13 +148,12 @@ function GetPip3CurrentState
[hashtable[]] $Package,
[Parameter(Mandatory = $true)]
- [AllowNull()]
+ [AllowNull()]
[hashtable] $Parameters
)
# Filter out the installed packages from the parameters because it is not a valid parameter when calling .ToHashTable() in the class for comparison
- if ($Parameters.ContainsKey('InstalledPackages'))
- {
+ if ($Parameters.ContainsKey('InstalledPackages')) {
$Parameters.Remove('InstalledPackages')
}
@@ -194,16 +165,13 @@ function GetPip3CurrentState
InstalledPackages = $Package
}
- foreach ($entry in $Package)
- {
- if ($entry.PackageName -eq $Parameters.PackageName)
- {
+ foreach ($entry in $Package) {
+ if ($entry.PackageName -eq $Parameters.PackageName) {
Write-Verbose -Message "Package exist: $($entry.name)"
$out.Exist = $true
$out.Version = $entry.version
- if ($Parameters.ContainsKey('version') -and $entry.version -ne $Parameters.version)
- {
+ if ($Parameters.ContainsKey('version') -and $entry.version -ne $Parameters.version) {
Write-Verbose -Message "Package exist, but version is different: $($entry.version)"
$out.Exist = $false
}
@@ -213,19 +181,15 @@ function GetPip3CurrentState
return $out
}
-function GetInstalledPip3Packages
-{
+function GetInstalledPip3Packages {
$Arguments = [List[string]]::new()
- $Arguments.Add("list")
- $Arguments.Add("--format=json")
+ $Arguments.Add('list')
+ $Arguments.Add('--format=json')
- if ($global:usePip3Exe)
- {
+ if ($global:usePip3Exe) {
$command = "& '$global:pip3ExePath' " + $Arguments
- }
- else
- {
- $command = "& pip3 " + $Arguments
+ } else {
+ $command = '& pip3 ' + $Arguments
}
$res = Invoke-Expression -Command $command | ConvertFrom-Json
@@ -240,47 +204,36 @@ function GetInstalledPip3Packages
return $result
}
-function Invoke-Pip3
-{
+function Invoke-Pip3 {
param (
[Parameter(Mandatory)]
[string]$command
)
- if ($global:usePip3Exe)
- {
+ if ($global:usePip3Exe) {
return Start-Process -FilePath $global:pip3ExePath -ArgumentList $command -Wait -PassThru -WindowStyle Hidden
- }
- else
- {
+ } else {
return Start-Process -FilePath pip3 -ArgumentList $command -Wait -PassThru -WindowStyle hidden
}
}
-function TryGetRegistryValue
-{
+function TryGetRegistryValue {
param (
[Parameter(Mandatory = $true)]
[string]$Key,
[Parameter(Mandatory = $true)]
[string]$Property
- )
+ )
- if (Test-Path -Path $Key)
- {
- try
- {
- return (Get-ItemProperty -Path $Key | Select-Object -ExpandProperty $Property)
- }
- catch
- {
+ if (Test-Path -Path $Key) {
+ try {
+ return (Get-ItemProperty -Path $Key | Select-Object -ExpandProperty $Property)
+ } catch {
Write-Verbose "Property `"$($Property)`" could not be found."
}
- }
- else
- {
- Write-Verbose "Registry key does not exist."
+ } else {
+ Write-Verbose 'Registry key does not exist.'
}
}
@@ -333,8 +286,7 @@ Assert-Pip3
This example shows how Django can be removed from the system.
#>
[DSCResource()]
-class Pip3Package
-{
+class Pip3Package {
[DscProperty(Key, Mandatory)]
[string]$PackageName
@@ -350,26 +302,21 @@ class Pip3Package
[DscProperty(NotConfigurable)]
[hashtable[]]$InstalledPackages
- [Pip3Package] Get()
- {
+ [Pip3Package] Get() {
$this.InstalledPackages = GetInstalledPip3Packages
$currentState = GetPip3CurrentState -Package $this.InstalledPackages -Parameters $this.ToHashTable()
return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
$currentState = $this.Get()
- if ($currentState.Exist -ne $this.Exist)
- {
+ if ($currentState.Exist -ne $this.Exist) {
return $false
}
- if (-not ([string]::IsNullOrEmpty($this.Version)))
- {
- if ($this.Version -ne $currentState.Version)
- {
+ if (-not ([string]::IsNullOrEmpty($this.Version))) {
+ if ($this.Version -ne $currentState.Version) {
return $false
}
}
@@ -377,38 +324,29 @@ class Pip3Package
return $true
}
- [void] Set()
- {
- if ($this.Test())
- {
- return
+ [void] Set() {
+ if ($this.Test()) {
+ return
}
$currentPackage = $this.InstalledPackages | Where-Object { $_.PackageName -eq $this.PackageName }
- if ($currentPackage -and $currentPackage.Version -ne $this.Version -and $this.Exist)
- {
+ if ($currentPackage -and $currentPackage.Version -ne $this.Version -and $this.Exist) {
Invoke-Pip3Install -PackageName $this.PackageName -Version $this.Version -Arguments $this.Arguments -IsUpdate
- }
- elseif ($this.Exist)
- {
+ } elseif ($this.Exist) {
Invoke-Pip3Install -PackageName $this.PackageName -Version $this.Version -Arguments $this.Arguments
- }
- else
- {
+ } else {
Invoke-Pip3Uninstall -PackageName $this.PackageName -Version $this.Version -Arguments $this.Arguments
}
}
- static [Pip3Package[]] Export()
- {
+ static [Pip3Package[]] Export() {
$packages = GetInstalledPip3Packages
$out = [List[Pip3Package]]::new()
- foreach ($package in $packages)
- {
+ foreach ($package in $packages) {
$in = [Pip3Package]@{
- PackageName = $package.Packagename
+ PackageName = $package.PackageName
Version = $package.version
- Exist = $true
+ Exist = $true
Arguments = $null
InstalledPackages = $packages
}
@@ -420,13 +358,10 @@ class Pip3Package
}
#region Pip3Package Helper functions
- [hashtable] ToHashTable()
- {
+ [hashtable] ToHashTable() {
$parameters = @{}
- foreach ($property in $this.PSObject.Properties)
- {
- if (-not ([string]::IsNullOrEmpty($property.Value)))
- {
+ foreach ($property in $this.PSObject.Properties) {
+ if (-not ([string]::IsNullOrEmpty($property.Value))) {
$parameters[$property.Name] = $property.Value
}
}
diff --git a/resources/README.md b/resources/README.md
index 0ad02d36..60ea66a1 100644
--- a/resources/README.md
+++ b/resources/README.md
@@ -1,55 +1,55 @@
-# DSC Resources
-
-This folder contains the initial prototypes for various DSC resources that could be utilized in a configuration yaml.
-
-## Requirements
-
-Before you get started, install the [PSDesiredStateConfiguration v2.0.7](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7) PowerShell package:
-
-```powerShell
-Install-Module -Name PSDesiredStateConfiguration -RequiredVersion 2.0.7
-```
-
-> To verify that the package is installed, run `Get-InstalledModule` and check that the version is exactly 2.0.7.
-
-## Executing a DSC Resource
-
-PowerShell recursively searches for the module in any of the paths specified in `$env:PSModulePath`. This means you can either copy the DSC Resource module into one of those paths or you can [modify the environment variable](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_psmodulepath?view=powershell-7.3#modifying-psmodulepath) to point to the location of your module.
-
-Once the above step is complete, you should be able to see your loaded DSC resource by running `Get-DSCResource`.
-
-You should now be able to execute the loaded DSC resource by running `Invoke-DSCResource`. Here is a usage example for the Visual Studio DSC Resource to use as a reference for structuring your command:
-
-```powershell
-# Define the properties in a hashtable from Get-DscResource
-$properties = @{
- HttpsUrl = 'https://github.com/microsoft/winget-dsc.git'
- RootDirectory = 'C:\Source'
- Ensure = 'Present'
-}
-
-# Define the parameters for Invoke-DscResource
-$params = @{
- Name = 'GitClone'
- Method = 'Set'
- ModuleName = 'GitDsc'
- Property = $properties
-}
-
-# Invoke the DSC resource
-Invoke-DscResource @params
-```
-
-## Troubleshooting
-
-If you don't see your DSC Resource loaded, try the following:
-
-1. Try importing the module using `Import-Module`. If the module cannot be imported, then it cannot load the DSC resource.
-
- ```powershell
- Import-Module
- ```
-
-2. Restarting your shell.
-3. Verifying that your syntax in the module is correct. No warning is shown to the user if your PowerShell module file is invalid.
-4. Verifying the `$env:PSModulePath` contains the folder path where your module is located.
+# DSC Resources
+
+This folder contains the initial prototypes for various DSC resources that could be utilized in a configuration yaml.
+
+## Requirements
+
+Before you get started, install the [PSDesiredStateConfiguration v2.0.7](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7) PowerShell package:
+
+```powerShell
+Install-Module -Name PSDesiredStateConfiguration -RequiredVersion 2.0.7
+```
+
+> To verify that the package is installed, run `Get-InstalledModule` and check that the version is exactly 2.0.7.
+
+## Executing a DSC Resource
+
+PowerShell recursively searches for the module in any of the paths specified in `$env:PSModulePath`. This means you can either copy the DSC Resource module into one of those paths or you can [modify the environment variable](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_psmodulepath?view=powershell-7.3#modifying-psmodulepath) to point to the location of your module.
+
+Once the above step is complete, you should be able to see your loaded DSC resource by running `Get-DSCResource`.
+
+You should now be able to execute the loaded DSC resource by running `Invoke-DSCResource`. Here is a usage example for the Visual Studio DSC Resource to use as a reference for structuring your command:
+
+```powershell
+# Define the properties in a hashtable from Get-DscResource
+$properties = @{
+ HttpsUrl = 'https://github.com/microsoft/winget-dsc.git'
+ RootDirectory = 'C:\Source'
+ Ensure = 'Present'
+}
+
+# Define the parameters for Invoke-DscResource
+$params = @{
+ Name = 'GitClone'
+ Method = 'Set'
+ ModuleName = 'GitDsc'
+ Property = $properties
+}
+
+# Invoke the DSC resource
+Invoke-DscResource @params
+```
+
+## Troubleshooting
+
+If you don't see your DSC Resource loaded, try the following:
+
+1. Try importing the module using `Import-Module`. If the module cannot be imported, then it cannot load the DSC resource.
+
+ ```powershell
+ Import-Module
+ ```
+
+2. Restarting your shell.
+3. Verifying that your syntax in the module is correct. No warning is shown to the user if your PowerShell module file is invalid.
+4. Verifying the `$env:PSModulePath` contains the folder path where your module is located.
diff --git a/resources/YarnDsc/YarnDsc.psd1 b/resources/YarnDsc/YarnDsc.psd1
index 3a97bfec..9489d856 100644
--- a/resources/YarnDsc/YarnDsc.psd1
+++ b/resources/YarnDsc/YarnDsc.psd1
@@ -8,127 +8,127 @@
@{
-# Script module or binary module file associated with this manifest.
-RootModule = 'YarnDsc.psm1'
+ # Script module or binary module file associated with this manifest.
+ RootModule = 'YarnDsc.psm1'
-# Version number of this module.
-ModuleVersion = '0.1.0'
+ # Version number of this module.
+ ModuleVersion = '0.1.0'
-# Supported PSEditions
-# CompatiblePSEditions = @()
+ # Supported PSEditions
+ # CompatiblePSEditions = @()
-# ID used to uniquely identify this module
-GUID = '6aaf009e-013a-4e41-9edf-619c601e02ef'
+ # ID used to uniquely identify this module
+ GUID = '6aaf009e-013a-4e41-9edf-619c601e02ef'
-# Author of this module
-Author = 'DscSamples'
+ # Author of this module
+ Author = 'DscSamples'
-# Company or vendor of this module
-# CompanyName = ''
+ # Company or vendor of this module
+ # CompanyName = ''
-# Copyright statement for this module
-# Copyright = ''
+ # Copyright statement for this module
+ # Copyright = ''
-# Description of the functionality provided by this module
-Description = 'DSC Resource for Yarn'
+ # Description of the functionality provided by this module
+ Description = 'DSC Resource for Yarn'
-# Minimum version of the PowerShell engine required by this module
-# PowerShellVersion = ''
+ # Minimum version of the PowerShell engine required by this module
+ # PowerShellVersion = ''
-# Name of the PowerShell host required by this module
-# PowerShellHostName = ''
+ # Name of the PowerShell host required by this module
+ # PowerShellHostName = ''
-# Minimum version of the PowerShell host required by this module
-# PowerShellHostVersion = ''
+ # Minimum version of the PowerShell host required by this module
+ # PowerShellHostVersion = ''
-# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
-# DotNetFrameworkVersion = ''
+ # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # DotNetFrameworkVersion = ''
-# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
-# ClrVersion = ''
+ # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # ClrVersion = ''
-# Processor architecture (None, X86, Amd64) required by this module
-# ProcessorArchitecture = ''
+ # Processor architecture (None, X86, Amd64) required by this module
+ # ProcessorArchitecture = ''
-# Modules that must be imported into the global environment prior to importing this module
-# RequiredModules = @()
+ # Modules that must be imported into the global environment prior to importing this module
+ # RequiredModules = @()
-# Assemblies that must be loaded prior to importing this module
-# RequiredAssemblies = @()
+ # Assemblies that must be loaded prior to importing this module
+ # RequiredAssemblies = @()
-# Script files (.ps1) that are run in the caller's environment prior to importing this module.
-# ScriptsToProcess = @()
+ # Script files (.ps1) that are run in the caller's environment prior to importing this module.
+ # ScriptsToProcess = @()
-# Type files (.ps1xml) to be loaded when importing this module
-# TypesToProcess = @()
+ # Type files (.ps1xml) to be loaded when importing this module
+ # TypesToProcess = @()
-# Format files (.ps1xml) to be loaded when importing this module
-# FormatsToProcess = @()
+ # Format files (.ps1xml) to be loaded when importing this module
+ # FormatsToProcess = @()
-# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
-# NestedModules = @()
+ # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+ # NestedModules = @()
-# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
-# FunctionsToExport = @()
+ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+ # FunctionsToExport = @()
-# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
-# CmdletsToExport = @()
+ # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+ # CmdletsToExport = @()
-# Variables to export from this module
-# VariablesToExport = '*'
+ # Variables to export from this module
+ # VariablesToExport = '*'
-# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
-# AliasesToExport = @()
+ # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+ # AliasesToExport = @()
-# DSC resources to export from this module
-DscResourcesToExport = @(
- 'YarnInstall'
-)
+ # DSC resources to export from this module
+ DscResourcesToExport = @(
+ 'YarnInstall'
+ )
-# List of all modules packaged with this module
-# ModuleList = @()
+ # List of all modules packaged with this module
+ # ModuleList = @()
-# List of all files packaged with this module
-# FileList = @()
+ # List of all files packaged with this module
+ # FileList = @()
-# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
-PrivateData = @{
+ # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+ PrivateData = @{
- PSData = @{
+ PSData = @{
- # Tags applied to this module. These help with module discovery in online galleries.
- Tags = @('PSDscResource_YarnInstall')
+ # Tags applied to this module. These help with module discovery in online galleries.
+ Tags = @('PSDscResource_YarnInstall')
- # A URL to the license for this module.
- # LicenseUri = ''
+ # A URL to the license for this module.
+ # LicenseUri = ''
- # A URL to the main website for this project.
- # ProjectUri = ''
+ # A URL to the main website for this project.
+ # ProjectUri = ''
- # A URL to an icon representing this module.
- # IconUri = ''
+ # A URL to an icon representing this module.
+ # IconUri = ''
- # ReleaseNotes of this module
- # ReleaseNotes = ''
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
- # Prerelease string of this module
- Prerelease = 'alpha'
+ # Prerelease string of this module
+ Prerelease = 'alpha'
- # Flag to indicate whether the module requires explicit user acceptance for install/update/save
- # RequireLicenseAcceptance = $false
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
- # External dependent modules of this module
- # ExternalModuleDependencies = @()
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
- } # End of PSData hashtable
+ } # End of PSData hashtable
-} # End of PrivateData hashtable
+ } # End of PrivateData hashtable
-# HelpInfo URI of this module
-# HelpInfoURI = ''
+ # HelpInfo URI of this module
+ # HelpInfoURI = ''
-# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
-# DefaultCommandPrefix = ''
+ # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+ # DefaultCommandPrefix = ''
}
diff --git a/resources/YarnDsc/YarnDsc.psm1 b/resources/YarnDsc/YarnDsc.psm1
index 6bab1318..b5c35797 100644
--- a/resources/YarnDsc/YarnDsc.psm1
+++ b/resources/YarnDsc/YarnDsc.psm1
@@ -8,8 +8,7 @@ Assert-Yarn
#region DSCResources
[DSCResource()]
-class YarnInstall
-{
+class YarnInstall {
# DSCResource requires a key. Do not set.
[DscProperty(Key)]
[string]$SID
@@ -23,16 +22,11 @@ class YarnInstall
[DscProperty(NotConfigurable)]
[string[]]$Dependencies
- [YarnInstall] Get()
- {
- if (-not([string]::IsNullOrEmpty($this.PackageDirectory)))
- {
- if (Test-Path -Path $this.PackageDirectory -PathType Container)
- {
+ [YarnInstall] Get() {
+ if (-not([string]::IsNullOrEmpty($this.PackageDirectory))) {
+ if (Test-Path -Path $this.PackageDirectory -PathType Container) {
Set-Location -Path $this.PackageDirectory
- }
- else
- {
+ } else {
throw "$($this.PackageDirectory) does not point to a valid directory."
}
}
@@ -41,17 +35,15 @@ class YarnInstall
$currentState.Dependencies = Invoke-YarnInfo -Arguments '--name-only --json' | ConvertFrom-Json
$currentState.Arguments = $this.Arguments
$currentState.PackageDirectory = $this.PackageDirectory
- return $currentState;
+ return $currentState
}
- [bool] Test()
- {
+ [bool] Test() {
# Yarn install is inherently idempotent as it will also resolve package dependencies. Set to $false
return $false
}
- [void] Set()
- {
+ [void] Set() {
$currentState = $this.Get()
Invoke-YarnInstall -Arguments $currentState.Arguments
}
@@ -60,49 +52,42 @@ class YarnInstall
#endregion DSCResources
#region Functions
-function Assert-Yarn
-{
+function Assert-Yarn {
# Refresh session $path value before invoking 'npm'
- $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
- try
- {
+ $env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'User')
+ try {
Invoke-Yarn -Command 'help'
return
- }
- catch
- {
- throw "Yarn is not installed"
+ } catch {
+ throw 'Yarn is not installed'
}
}
-function Invoke-YarnInfo
-{
+function Invoke-YarnInfo {
param(
[Parameter()]
- [string]$Arguments
+ [string]$Arguments
)
$command = [List[string]]::new()
- $command.Add("info")
+ $command.Add('info')
$command.Add($Arguments)
return Invoke-Yarn -Command $command
}
-function Invoke-YarnInstall
-{
+function Invoke-YarnInstall {
param (
[Parameter()]
[string]$Arguments
)
$command = [List[string]]::new()
- $command.Add("install")
+ $command.Add('install')
$command.Add($Arguments)
return Invoke-Yarn -Command $command
}
-function Invoke-Yarn
-{
+function Invoke-Yarn {
param (
[Parameter(Mandatory = $true)]
[string]$Command
@@ -111,4 +96,4 @@ function Invoke-Yarn
return Invoke-Expression -Command "yarn $Command"
}
-#endregion Functions
\ No newline at end of file
+#endregion Functions
diff --git a/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1 b/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1
index 1b9efd82..620dea67 100644
--- a/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1
+++ b/tests/Microsoft.DotNet.Dsc/Microsoft.DotNet.Dsc.Tests.ps1
@@ -2,7 +2,7 @@
# Licensed under the MIT License.
using module Microsoft.DotNet.Dsc
-$ErrorActionPreference = "Stop"
+$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
<#
@@ -16,15 +16,14 @@ BeforeAll {
$script:toolsDir = Join-Path $env:USERPROFILE 'tools'
- if (-not (Test-Path $toolsDir))
- {
+ if (-not (Test-Path $toolsDir)) {
$null = New-Item -ItemType Directory -Path $toolsDir -Force -ErrorAction SilentlyContinue
}
}
Describe 'List available DSC resources' {
It 'Shows DSC Resources' {
- $expectedDSCResources = "DotNetToolPackage"
+ $expectedDSCResources = 'DotNetToolPackage'
$availableDSCResources = (Get-DscResource -Module Microsoft.DotNet.Dsc).Name
$availableDSCResources.count | Should -Be 1
$availableDSCResources | Where-Object { $expectedDSCResources -notcontains $_ } | Should -BeNullOrEmpty -ErrorAction Stop
@@ -36,9 +35,9 @@ Describe 'DSC operation capabilities' {
$parameters = @{
PackageId = 'gitversion.tool'
}
-
+
Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Set -Property $parameters
-
+
$finalState = Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Get -Property $parameters
$finalState.Exist | Should -BeTrue
$finalState.Version | Should -Not -BeNullOrEmpty
@@ -49,9 +48,9 @@ Describe 'DSC operation capabilities' {
PackageId = 'dotnet-ef'
PreRelease = $true
}
-
+
Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Set -Property $parameters
-
+
$finalState = Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Get -Property $parameters
$finalState.PackageId | Should -Be $parameters.PackageId
$finalState.PreRelease | Should -BeTrue
@@ -62,9 +61,9 @@ Describe 'DSC operation capabilities' {
PackageId = 'dotnet-reportgenerator-globaltool'
Version = '5.3.9'
}
-
+
Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Set -Property $parameters
-
+
$finalState = Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Get -Property $parameters
$finalState.PackageId | Should -Be $parameters.PackageId
$finalState.Version | Should -Be $parameters.Version
@@ -75,9 +74,9 @@ Describe 'DSC operation capabilities' {
PackageId = 'dotnet-reportgenerator-globaltool'
Version = '5.3.10'
}
-
+
Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Set -Property $parameters
-
+
$finalState = Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Get -Property $parameters
$finalState.PackageId | Should -Be $parameters.PackageId
$finalState.Version | Should -Be $parameters.Version
@@ -88,9 +87,9 @@ Describe 'DSC operation capabilities' {
PackageId = 'PowerShell'
Version = '7.2.0-preview.5'
}
-
+
Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Set -Property $parameters
-
+
$finalState = Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Get -Property $parameters
$finalState.PackageId | Should -Be $parameters.PackageId
$finalState.Version | Should -Be $parameters.Version
@@ -99,7 +98,7 @@ Describe 'DSC operation capabilities' {
It 'Exports resources' -Skip:(!$IsWindows) {
$obj = [DotNetToolPackage]::Export()
-
+
$obj.PackageId.Contains('dotnet-ef') | Should -Be $true
$obj.PackageId.Contains('dotnet-reportgenerator-globaltool') | Should -Be $true
}
@@ -108,8 +107,8 @@ Describe 'DSC operation capabilities' {
$parameters = @{
PackageId = 'Azure-Core' # not a tool
}
-
- { Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Set -Property $parameters } | Should -Throw -ExpectedMessage "Executing dotnet.exe with {tool install Azure-Core --global --ignore-failed-sources} failed."
+
+ { Invoke-DscResource -Name DotNetToolPackage -ModuleName Microsoft.DotNet.Dsc -Method Set -Property $parameters } | Should -Throw -ExpectedMessage 'Executing dotnet.exe with {tool install Azure-Core --global --ignore-failed-sources} failed.'
}
It 'Installs in tool path location with version' -Skip:(!$IsWindows) {
@@ -187,10 +186,10 @@ Describe 'DSC operation capabilities' {
}
Describe 'DSC helper functions' {
- Context "Semantic Versioning" {
+ Context 'Semantic Versioning' {
It 'Parses valid semantic version' {
$version = '1.2.3'
- $result = Get-Semver -version $version
+ $result = Get-SemVer -version $version
$result.Major | Should -Be 1
$result.Minor | Should -Be 2
$result.Build | Should -Be 3
@@ -198,7 +197,7 @@ Describe 'DSC helper functions' {
It 'Parses semantic version with alpha' {
$version = '1.2.3-alpha'
- $result = Get-Semver -version $version
+ $result = Get-SemVer -version $version
$result.Major | Should -Be 1
$result.Minor | Should -Be 2
$result.Build | Should -Be 3
@@ -207,7 +206,7 @@ Describe 'DSC helper functions' {
It 'Parses semantic version with alpha tag and version' {
$version = '1.2.3-alpha.123'
- $result = Get-Semver -version $version
+ $result = Get-SemVer -version $version
$result.Major | Should -Be 1
$result.Minor | Should -Be 2
$result.Build | Should -Be 3
@@ -216,7 +215,7 @@ Describe 'DSC helper functions' {
It 'Parses semantic version with beta tag and version' {
$version = '1.2.3-beta.11'
- $result = Get-Semver -version $version
+ $result = Get-SemVer -version $version
$result.Major | Should -Be 1
$result.Minor | Should -Be 2
$result.Build | Should -Be 3
@@ -225,7 +224,7 @@ Describe 'DSC helper functions' {
It 'Parses semantic version with rc and version' {
$version = '1.2.3-rc.1'
- $result = Get-Semver -version $version
+ $result = Get-SemVer -version $version
$result.Major | Should -Be 1
$result.Minor | Should -Be 2
$result.Build | Should -Be 3
@@ -236,4 +235,4 @@ Describe 'DSC helper functions' {
AfterAll {
Remove-Item -Path $toolsDir -Recurse -Force -ErrorAction SilentlyContinue
-}
\ No newline at end of file
+}
diff --git a/tests/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.Tests.ps1 b/tests/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.Tests.ps1
index 7291d432..118cbe5a 100644
--- a/tests/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.Tests.ps1
+++ b/tests/Microsoft.VSCode.Dsc/Microsoft.VSCode.Dsc.Tests.ps1
@@ -2,7 +2,7 @@
# Licensed under the MIT License.
using module Microsoft.VSCode.Dsc
-$ErrorActionPreference = "Stop"
+$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
<#
@@ -14,7 +14,7 @@ BeforeAll {
Install-Module -Name PSDesiredStateConfiguration -Force -SkipPublisherCheck
Import-Module Microsoft.VSCode.Dsc
- # Install VSCode
+ # Install VSCode
Invoke-WebRequest https://raw.githubusercontent.com/PowerShell/vscode-powershell/main/scripts/Install-VSCode.ps1 -UseBasicParsing -OutFile Install-VSCode.ps1
.\Install-VSCode.ps1 -BuildEdition Stable-User -Confirm:$false
@@ -24,7 +24,7 @@ BeforeAll {
Describe 'List available DSC resources' {
It 'Shows DSC Resources' {
- $expectedDSCResources = "VSCodeExtension"
+ $expectedDSCResources = 'VSCodeExtension'
$availableDSCResources = (Get-DscResource -Module Microsoft.VSCode.Dsc).Name
$availableDSCResources.count | Should -Be 1
$availableDSCResources | Where-Object { $expectedDSCResources -notcontains $_ } | Should -BeNullOrEmpty -ErrorAction Stop
@@ -37,10 +37,10 @@ Describe 'VSCodeExtension' {
Name = 'ms-vscode.powershell'
}
$initialState = Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Get -Property $parameters
-
+
$testResult = Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Test -Property $parameters
$testResult.InDesiredState | Should -Be $true
-
+
# Invoking set should not change these values.
Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Set -Property $parameters
$finalState = Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Get -Property $parameters
@@ -53,27 +53,27 @@ Describe 'VSCodeExtension' {
$desiredState = @{
Name = 'ms-azure-devops.azure-pipelines'
}
-
+
Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Set -Property $desiredState
-
+
$finalState = Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Get -Property $desiredState
$finalState.Name | Should -Be $desiredState.Name
$finalState.Exist | Should -BeTrue
- }
+ }
}
Describe 'VSCodeExtension-Insiders' {
It 'Keeps current extension in Insiders edition.' -Skip:(!$IsWindows) {
$parameters = @{
- Name = 'ms-vscode.powershell'
+ Name = 'ms-vscode.powershell'
Insiders = $true
}
$initialState = Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Get -Property $parameters
-
+
$testResult = Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Test -Property $parameters
$testResult.InDesiredState | Should -Be $true
-
+
# Invoking set should not change these values.
Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Set -Property $parameters
$finalState = Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Get -Property $parameters
@@ -84,18 +84,18 @@ Describe 'VSCodeExtension-Insiders' {
It 'Sets desired extension in Insiders edition' -Skip:(!$IsWindows) {
$desiredState = @{
- Name = 'ms-azure-devops.azure-pipelines'
+ Name = 'ms-azure-devops.azure-pipelines'
Insiders = $true
}
-
+
Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Set -Property $desiredState
-
+
$finalState = Invoke-DscResource -Name VSCodeExtension -ModuleName Microsoft.VSCode.Dsc -Method Get -Property $desiredState
$finalState.Name | Should -Be $desiredState.Name
$finalState.Exist | Should -BeTrue
- }
+ }
}
AfterAll {
# Uninstall VSCode?
-}
\ No newline at end of file
+}
diff --git a/tests/Microsoft.Windows.Developer/Microsoft.Windows.Developer.Tests.ps1 b/tests/Microsoft.Windows.Developer/Microsoft.Windows.Developer.Tests.ps1
index 0ca64a78..c72b4253 100644
--- a/tests/Microsoft.Windows.Developer/Microsoft.Windows.Developer.Tests.ps1
+++ b/tests/Microsoft.Windows.Developer/Microsoft.Windows.Developer.Tests.ps1
@@ -1,176 +1,176 @@
-# Copyright (c) Microsoft Corporation. All rights reserved.
-# Licensed under the MIT License.
-using module Microsoft.Windows.Developer
-
-$ErrorActionPreference = "Stop"
-Set-StrictMode -Version Latest
-
-<#
-.Synopsis
- Pester tests related to the Microsoft.WinGet.Developer PowerShell module.
-#>
-
-BeforeAll {
- Install-Module -Name PSDesiredStateConfiguration -Force -SkipPublisherCheck
- Import-Module Microsoft.Windows.Developer
-
- # Create test registry path.
- New-Item -Path TestRegistry:\ -Name TestKey
- # Set-ItemProperty requires the PSDrive to be in the format 'HKCU:'.
- $env:TestRegistryPath = ((Get-Item -Path TestRegistry:\).Name).replace("HKEY_CURRENT_USER", "HKCU:")
-}
-
-Describe 'List available DSC resources' {
- It 'Shows DSC Resources' {
- $expectedDSCResources = "DeveloperMode", "OsVersion", "ShowSecondsInClock", "EnableDarkMode", "Taskbar", "UserAccessControl", "WindowsExplorer", "EnableRemoteDesktop"
- $availableDSCResources = (Get-DscResource -Module Microsoft.Windows.Developer).Name
- $availableDSCResources.length | Should -Be 8
- $availableDSCResources | Where-Object { $expectedDSCResources -notcontains $_ } | Should -BeNullOrEmpty -ErrorAction Stop
- }
-}
-
-Describe 'Taskbar' {
- It 'Keeps current value.' {
- $initialState = Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
-
- $parameters = @{
- Alignment = 'KeepCurrentValue';
- HideLabelsMode = 'KeepCurrentValue';
- SearchboxMode = 'KeepCurrentValue';
- TaskViewButton = 'KeepCurrentValue';
- WidgetsButton = 'KeepCurrentValue'
- }
-
- $testResult = Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Test -Property $parameters
- $testResult.InDesiredState | Should -Be $true
-
- # Invoking set should not change these values.
- Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Set -Property $parameters
- $finalState = Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
- $finalState.Alignment | Should -Be $initialState.Alignment
- $finalState.HideLabelsMode | Should -Be $initialState.HideLabelsMode
- $finalState.SearchboxMode | Should -Be $initialState.SearchboxMode
- $finalState.TaskViewButton | Should -Be $initialState.WidgetsButton
- }
-
- It 'Sets desired value' {
- # Randomly generate desired state. Minimum is set to 1 to avoid KeepCurrentValue
- $desiredAlignment = [Alignment](Get-Random -Maximum 3 -Minimum 1)
- $desiredHideLabelsMode = [HideTaskBarLabelsBehavior](Get-Random -Maximum 4 -Minimum 1)
- $desiredSearchboxMode = [SearchBoxMode](Get-Random -Maximum 5 -Minimum 1)
- $desiredTaskViewButton = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
- $desiredWidgetsButton = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
-
- $desiredState = @{ Alignment = $desiredAlignment;
- HideLabelsMode = $desiredHideLabelsMode;
- SearchboxMode = $desiredSearchboxMode;
- TaskViewButton = $desiredTaskViewButton;
- WidgetsButton = $desiredWidgetsButton
- }
-
- Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
-
- $finalState = Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
- $finalState.Alignment | Should -Be $desiredAlignment
- $finalState.HideLabelsMode | Should -Be $desiredHideLabelsMode
- $finalState.SearchboxMode | Should -Be $desiredSearchboxMode
- $finalState.TaskViewButton | Should -Be $desiredTaskViewButton
- $finalState.WidgetsButton | Should -Be $desiredWidgetsButton
- }
-}
-
-Describe 'WindowsExplorer' {
- It 'Keeps current value.' {
- $initialState = Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
-
- $parameters = @{
- FileExtensions = 'KeepCurrentValue';
- HiddenFiles = 'KeepCurrentValue';
- ItemCheckBoxes = 'KeepCurrentValue'
- }
-
- $testResult = Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Test -Property $parameters
- $testResult.InDesiredState | Should -Be $true
-
- # Invoking set should not change these values.
- Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Set -Property $parameters
- $finalState = Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
- $finalState.FileExtensions | Should -Be $initialState.FileExtensions
- $finalState.HiddenFiles | Should -Be $initialState.HiddenFiles
- $finalState.ItemCheckBoxes | Should -Be $initialState.ItemCheckBoxes
- }
-
- It 'Sets desired value' {
- # Randomly generate desired state. Minimum is set to 1 to avoid using KeepCurrentValue
- $desiredFileExtensions = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
- $desiredHiddenFiles = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
- $desiredItemCheckBoxes = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
-
- $desiredState = @{
- FileExtensions = $desiredFileExtensions;
- HiddenFiles = $desiredHiddenFiles;
- ItemCheckBoxes = $desiredItemCheckBoxes
- }
-
- Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
-
- $finalState = Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
- $finalState.FileExtensions | Should -Be $desiredFileExtensions
- $finalState.HiddenFiles | Should -Be $desiredHiddenFiles
- $finalState.ItemCheckBoxes | Should -Be $desiredItemCheckBoxes
- }
-}
-
-Describe 'UserAccessControl' {
- It 'Keeps current value.' {
- $initialState = Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
-
- $parameters = @{ AdminConsentPromptBehavior = 'KeepCurrentValue' }
-
- $testResult = Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Test -Property $parameters
- $testResult.InDesiredState | Should -Be $true
-
- # Invoking set should not change these values.
- Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Set -Property $parameters
- $finalState = Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
- $finalState.AdminConsentPromptBehavior | Should -Be $initialState.AdminConsentPromptBehavior
- }
-
- It 'Sets desired value.' {
- # Randomly generate desired state. Minimum is set to 1 to avoid using KeepCurrentValue
- $desiredAdminConsentPromptBehavior = [AdminConsentPromptBehavior](Get-Random -Maximum 6 -Minimum 1)
-
- $desiredState = @{ AdminConsentPromptBehavior = $desiredAdminConsentPromptBehavior }
-
- Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
-
- $finalState = Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
- $finalState.AdminConsentPromptBehavior | Should -Be $desiredAdminConsentPromptBehavior
- }
-}
-
-Describe 'EnableRemoteDesktop' {
- It 'Sets Enabled' {
- $desiredRemoteDesktopBehavior = [Ensure]::Present
- $desiredState = @{ Ensure = $desiredRemoteDesktopBehavior }
-
- Invoke-DscResource -Name EnableRemoteDesktop -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
-
- $finalState = Invoke-DscResource -Name EnableRemoteDesktop -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
- $finalState.Ensure | Should -Be $desiredRemoteDesktopBehavior
- }
-
- It 'Sets Disabled' {
- $desiredRemoteDesktopBehavior = [Ensure]::Absent
- $desiredState = @{ Ensure = $desiredRemoteDesktopBehavior }
-
- Invoke-DscResource -Name EnableRemoteDesktop -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
-
- $finalState = Invoke-DscResource -Name EnableRemoteDesktop -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
- $finalState.Ensure | Should -Be $desiredRemoteDesktopBehavior
- }
-}
-
-AfterAll {
- $env:TestRegistryPath = ""
-}
\ No newline at end of file
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License.
+using module Microsoft.Windows.Developer
+
+$ErrorActionPreference = "Stop"
+Set-StrictMode -Version Latest
+
+<#
+.Synopsis
+ Pester tests related to the Microsoft.WinGet.Developer PowerShell module.
+#>
+
+BeforeAll {
+ Install-Module -Name PSDesiredStateConfiguration -Force -SkipPublisherCheck
+ Import-Module Microsoft.Windows.Developer
+
+ # Create test registry path.
+ New-Item -Path TestRegistry:\ -Name TestKey
+ # Set-ItemProperty requires the PSDrive to be in the format 'HKCU:'.
+ $env:TestRegistryPath = ((Get-Item -Path TestRegistry:\).Name).replace("HKEY_CURRENT_USER", "HKCU:")
+}
+
+Describe 'List available DSC resources' {
+ It 'Shows DSC Resources' {
+ $expectedDSCResources = "DeveloperMode", "OsVersion", "ShowSecondsInClock", "EnableDarkMode", "Taskbar", "UserAccessControl", "WindowsExplorer", "EnableRemoteDesktop"
+ $availableDSCResources = (Get-DscResource -Module Microsoft.Windows.Developer).Name
+ $availableDSCResources.length | Should -Be 8
+ $availableDSCResources | Where-Object { $expectedDSCResources -notcontains $_ } | Should -BeNullOrEmpty -ErrorAction Stop
+ }
+}
+
+Describe 'Taskbar' {
+ It 'Keeps current value.' {
+ $initialState = Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+
+ $parameters = @{
+ Alignment = 'KeepCurrentValue';
+ HideLabelsMode = 'KeepCurrentValue';
+ SearchboxMode = 'KeepCurrentValue';
+ TaskViewButton = 'KeepCurrentValue';
+ WidgetsButton = 'KeepCurrentValue'
+ }
+
+ $testResult = Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Test -Property $parameters
+ $testResult.InDesiredState | Should -Be $true
+
+ # Invoking set should not change these values.
+ Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Set -Property $parameters
+ $finalState = Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+ $finalState.Alignment | Should -Be $initialState.Alignment
+ $finalState.HideLabelsMode | Should -Be $initialState.HideLabelsMode
+ $finalState.SearchboxMode | Should -Be $initialState.SearchboxMode
+ $finalState.TaskViewButton | Should -Be $initialState.WidgetsButton
+ }
+
+ It 'Sets desired value' {
+ # Randomly generate desired state. Minimum is set to 1 to avoid KeepCurrentValue
+ $desiredAlignment = [Alignment](Get-Random -Maximum 3 -Minimum 1)
+ $desiredHideLabelsMode = [HideTaskBarLabelsBehavior](Get-Random -Maximum 4 -Minimum 1)
+ $desiredSearchboxMode = [SearchBoxMode](Get-Random -Maximum 5 -Minimum 1)
+ $desiredTaskViewButton = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
+ $desiredWidgetsButton = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
+
+ $desiredState = @{ Alignment = $desiredAlignment;
+ HideLabelsMode = $desiredHideLabelsMode;
+ SearchboxMode = $desiredSearchboxMode;
+ TaskViewButton = $desiredTaskViewButton;
+ WidgetsButton = $desiredWidgetsButton
+ }
+
+ Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
+
+ $finalState = Invoke-DscResource -Name Taskbar -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+ $finalState.Alignment | Should -Be $desiredAlignment
+ $finalState.HideLabelsMode | Should -Be $desiredHideLabelsMode
+ $finalState.SearchboxMode | Should -Be $desiredSearchboxMode
+ $finalState.TaskViewButton | Should -Be $desiredTaskViewButton
+ $finalState.WidgetsButton | Should -Be $desiredWidgetsButton
+ }
+}
+
+Describe 'WindowsExplorer' {
+ It 'Keeps current value.' {
+ $initialState = Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+
+ $parameters = @{
+ FileExtensions = 'KeepCurrentValue';
+ HiddenFiles = 'KeepCurrentValue';
+ ItemCheckBoxes = 'KeepCurrentValue'
+ }
+
+ $testResult = Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Test -Property $parameters
+ $testResult.InDesiredState | Should -Be $true
+
+ # Invoking set should not change these values.
+ Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Set -Property $parameters
+ $finalState = Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+ $finalState.FileExtensions | Should -Be $initialState.FileExtensions
+ $finalState.HiddenFiles | Should -Be $initialState.HiddenFiles
+ $finalState.ItemCheckBoxes | Should -Be $initialState.ItemCheckBoxes
+ }
+
+ It 'Sets desired value' {
+ # Randomly generate desired state. Minimum is set to 1 to avoid using KeepCurrentValue
+ $desiredFileExtensions = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
+ $desiredHiddenFiles = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
+ $desiredItemCheckBoxes = [ShowHideFeature](Get-Random -Maximum 3 -Minimum 1)
+
+ $desiredState = @{
+ FileExtensions = $desiredFileExtensions;
+ HiddenFiles = $desiredHiddenFiles;
+ ItemCheckBoxes = $desiredItemCheckBoxes
+ }
+
+ Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
+
+ $finalState = Invoke-DscResource -Name WindowsExplorer -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+ $finalState.FileExtensions | Should -Be $desiredFileExtensions
+ $finalState.HiddenFiles | Should -Be $desiredHiddenFiles
+ $finalState.ItemCheckBoxes | Should -Be $desiredItemCheckBoxes
+ }
+}
+
+Describe 'UserAccessControl' {
+ It 'Keeps current value.' {
+ $initialState = Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+
+ $parameters = @{ AdminConsentPromptBehavior = 'KeepCurrentValue' }
+
+ $testResult = Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Test -Property $parameters
+ $testResult.InDesiredState | Should -Be $true
+
+ # Invoking set should not change these values.
+ Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Set -Property $parameters
+ $finalState = Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+ $finalState.AdminConsentPromptBehavior | Should -Be $initialState.AdminConsentPromptBehavior
+ }
+
+ It 'Sets desired value.' {
+ # Randomly generate desired state. Minimum is set to 1 to avoid using KeepCurrentValue
+ $desiredAdminConsentPromptBehavior = [AdminConsentPromptBehavior](Get-Random -Maximum 6 -Minimum 1)
+
+ $desiredState = @{ AdminConsentPromptBehavior = $desiredAdminConsentPromptBehavior }
+
+ Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
+
+ $finalState = Invoke-DscResource -Name UserAccessControl -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+ $finalState.AdminConsentPromptBehavior | Should -Be $desiredAdminConsentPromptBehavior
+ }
+}
+
+Describe 'EnableRemoteDesktop' {
+ It 'Sets Enabled' {
+ $desiredRemoteDesktopBehavior = [Ensure]::Present
+ $desiredState = @{ Ensure = $desiredRemoteDesktopBehavior }
+
+ Invoke-DscResource -Name EnableRemoteDesktop -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
+
+ $finalState = Invoke-DscResource -Name EnableRemoteDesktop -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+ $finalState.Ensure | Should -Be $desiredRemoteDesktopBehavior
+ }
+
+ It 'Sets Disabled' {
+ $desiredRemoteDesktopBehavior = [Ensure]::Absent
+ $desiredState = @{ Ensure = $desiredRemoteDesktopBehavior }
+
+ Invoke-DscResource -Name EnableRemoteDesktop -ModuleName Microsoft.Windows.Developer -Method Set -Property $desiredState
+
+ $finalState = Invoke-DscResource -Name EnableRemoteDesktop -ModuleName Microsoft.Windows.Developer -Method Get -Property @{}
+ $finalState.Ensure | Should -Be $desiredRemoteDesktopBehavior
+ }
+}
+
+AfterAll {
+ $env:TestRegistryPath = ""
+}
diff --git a/tests/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.Tests.ps1 b/tests/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.Tests.ps1
index f30fb6b0..dd22de6d 100644
--- a/tests/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.Tests.ps1
+++ b/tests/Microsoft.Windows.Setting.Accessibility/Microsoft.Windows.Setting.Accessibility.Tests.ps1
@@ -3,7 +3,7 @@
# Licensed under the MIT License.
using module Microsoft.Windows.Setting.Accessibility
-$ErrorActionPreference = "Stop"
+$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
<#
@@ -12,22 +12,21 @@ Set-StrictMode -Version Latest
#>
BeforeAll {
- if ($null -eq (Get-Module -ListAvailable -Name PSDesiredStateConfiguration))
- {
+ if ($null -eq (Get-Module -ListAvailable -Name PSDesiredStateConfiguration)) {
Install-Module -Name PSDesiredStateConfiguration -Force -SkipPublisherCheck
}
-
+
Import-Module Microsoft.Windows.Setting.Accessibility
# Create test registry path.
New-Item -Path TestRegistry:\ -Name TestKey
# Set-ItemProperty requires the PSDrive to be in the format 'HKCU:'.
- $env:TestRegistryPath = ((Get-Item -Path TestRegistry:\).Name).replace("HKEY_CURRENT_USER", "HKCU:")
+ $env:TestRegistryPath = ((Get-Item -Path TestRegistry:\).Name).replace('HKEY_CURRENT_USER', 'HKCU:')
}
Describe 'List available DSC resources' {
It 'Shows DSC Resources' {
- $expectedDSCResources = "Text", "Magnifier", "MousePointer", "VisualEffect", "Audio", "TextCursor", "StickyKeys", "ToggleKeys", "FilterKeys"
+ $expectedDSCResources = 'Text', 'Magnifier', 'MousePointer', 'VisualEffect', 'Audio', 'TextCursor', 'StickyKeys', 'ToggleKeys', 'FilterKeys'
$availableDSCResources = (Get-DscResource -Module Microsoft.Windows.Setting.Accessibility).Name
$availableDSCResources.length | Should -Be 9
$availableDSCResources | Where-Object { $expectedDSCResources -notcontains $_ } | Should -BeNullOrEmpty -ErrorAction Stop
@@ -54,9 +53,9 @@ Describe 'Text' {
$desiredTextSize = [TextSize](Get-Random -Maximum 4 -Minimum 1)
$desiredState = @{ Size = $desiredTextSize }
-
+
Invoke-DscResource -Name Text -ModuleName Microsoft.Windows.Setting.Accessibility -Method Set -Property $desiredState
-
+
$finalState = Invoke-DscResource -Name Text -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
$finalState.Size | Should -Be $desiredTextSize
}
@@ -82,9 +81,9 @@ Describe 'Magnifier' {
$desiredMagnification = [MagnificationValue](Get-Random -Maximum 4 -Minimum 1)
$desiredState = @{ Magnification = $desiredMagnification }
-
+
Invoke-DscResource -Name Magnifier -ModuleName Microsoft.Windows.Setting.Accessibility -Method Set -Property $desiredState
-
+
$finalState = Invoke-DscResource -Name Magnifier -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
$finalState.Magnification | Should -Be $desiredMagnification
}
@@ -110,9 +109,9 @@ Describe 'MousePointer' {
$desiredPointerSize = [PointerSize](Get-Random -Maximum 4 -Minimum 1)
$desiredState = @{ PointerSize = $desiredPointerSize }
-
+
Invoke-DscResource -Name MousePointer -ModuleName Microsoft.Windows.Setting.Accessibility -Method Set -Property $desiredState
-
+
$finalState = Invoke-DscResource -Name MousePointer -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
$finalState.PointerSize | Should -Be $desiredPointerSize
}
@@ -158,9 +157,9 @@ Describe 'VisualEffect' {
$testResult2.InDesiredState | Should -Be $true
}
It 'MessageDuration' {
- $firstValue = 5 #Key is missing by default, and default value is 5 when not specified.
+ $firstValue = 5 #Key is missing by default, and default value is 5 when not specified.
$secondValue = 10
-
+
$initialState = Invoke-DscResource -Name VisualEffect -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
$initialState.MessageDurationInSeconds | Should -Be $firstValue
@@ -219,7 +218,7 @@ Describe 'TextCursor' {
$testResult2 = Invoke-DscResource -Name TextCursor -ModuleName Microsoft.Windows.Setting.Accessibility -Method Test -Property $parameters
$testResult2.InDesiredState | Should -Be $true
}
- It 'IndicatorSize.' {
+ It 'IndicatorSize.' {
Invoke-DscResource -Name TextCursor -ModuleName Microsoft.Windows.Setting.Accessibility -Method Set -Property @{ IndicatorSize = 1 }
$initialState = Invoke-DscResource -Name TextCursor -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
@@ -238,7 +237,7 @@ Describe 'TextCursor' {
$testResult2 = Invoke-DscResource -Name TextCursor -ModuleName Microsoft.Windows.Setting.Accessibility -Method Test -Property $parameters
$testResult2.InDesiredState | Should -Be $true
}
- It 'IndicatorColor.' {
+ It 'IndicatorColor.' {
Invoke-DscResource -Name TextCursor -ModuleName Microsoft.Windows.Setting.Accessibility -Method Set -Property @{ IndicatorColor = 16711871 }
$initialState = Invoke-DscResource -Name TextCursor -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
@@ -258,9 +257,9 @@ Describe 'TextCursor' {
$testResult2.InDesiredState | Should -Be $true
}
It 'Thickness' { #int
- $firstValue = 1 #Key is missing by default, and default value is 5 when not specified.
+ $firstValue = 1 #Key is missing by default, and default value is 5 when not specified.
$secondValue = 2
-
+
$initialState = Invoke-DscResource -Name TextCursor -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
$initialState.Thickness | Should -Be $firstValue
@@ -280,7 +279,7 @@ Describe 'TextCursor' {
}
Describe 'StickyKeys' {
- It 'Each property can be set' {
+ It 'Each property can be set' {
# Get a snapshot of the current state
$baselineState = Invoke-DscResource -Name StickyKeys -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
# Get a list of all the properties that can be changed
@@ -310,7 +309,7 @@ Describe 'StickyKeys' {
# Set all properties back to the initial state at once
$parameterList = $baselineState | Select-Object -Property $propertyList
- $parameters = @{} # Needs to be a hashtable for seeting them all at once
+ $parameters = @{} # Needs to be a hashtable for setting them all at once
$parameterList.PSObject.Properties | ForEach-Object { $parameters[$_.Name] = $_.Value }
$testResult = Invoke-DscResource -Name StickyKeys -ModuleName Microsoft.Windows.Setting.Accessibility -Method Test -Property $parameters
$testResult.InDesiredState | Should -Be $false # Everything should still be opposite from when each property was changed individually
@@ -321,7 +320,7 @@ Describe 'StickyKeys' {
}
Describe 'ToggleKeys' {
- It 'Each property can be set' {
+ It 'Each property can be set' {
# Get a snapshot of the current state
$baselineState = Invoke-DscResource -Name ToggleKeys -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
# Get a list of all the properties that can be changed
@@ -351,7 +350,7 @@ Describe 'ToggleKeys' {
# Set all properties back to the initial state at once
$parameterList = $baselineState | Select-Object -Property $propertyList
- $parameters = @{} # Needs to be a hashtable for seeting them all at once
+ $parameters = @{} # Needs to be a hashtable for setting them all at once
$parameterList.PSObject.Properties | ForEach-Object { $parameters[$_.Name] = $_.Value }
$testResult = Invoke-DscResource -Name ToggleKeys -ModuleName Microsoft.Windows.Setting.Accessibility -Method Test -Property $parameters
$testResult.InDesiredState | Should -Be $false # Everything should still be opposite from when each property was changed individually
@@ -362,7 +361,7 @@ Describe 'ToggleKeys' {
}
Describe 'FilterKeys' {
- It 'Each property can be set' {
+ It 'Each property can be set' {
# Get a snapshot of the current state
$baselineState = Invoke-DscResource -Name FilterKeys -ModuleName Microsoft.Windows.Setting.Accessibility -Method Get -Property @{}
# Get a list of all the properties that can be changed
@@ -392,7 +391,7 @@ Describe 'FilterKeys' {
# Set all properties back to the initial state at once
$parameterList = $baselineState | Select-Object -Property $propertyList
- $parameters = @{} # Needs to be a hashtable for seeting them all at once
+ $parameters = @{} # Needs to be a hashtable for setting them all at once
$parameterList.PSObject.Properties | ForEach-Object { $parameters[$_.Name] = $_.Value }
$testResult = Invoke-DscResource -Name FilterKeys -ModuleName Microsoft.Windows.Setting.Accessibility -Method Test -Property $parameters
$testResult.InDesiredState | Should -Be $false # Everything should still be opposite from when each property was changed individually
@@ -403,5 +402,5 @@ Describe 'FilterKeys' {
}
AfterAll {
- $env:TestRegistryPath = ""
-}
\ No newline at end of file
+ $env:TestRegistryPath = ''
+}
diff --git a/tests/PythonPip3Dsc/PythonPip3Dsc.Tests.ps1 b/tests/PythonPip3Dsc/PythonPip3Dsc.Tests.ps1
index 339e6221..9d1d33ee 100644
--- a/tests/PythonPip3Dsc/PythonPip3Dsc.Tests.ps1
+++ b/tests/PythonPip3Dsc/PythonPip3Dsc.Tests.ps1
@@ -1,6 +1,6 @@
using module PythonPip3Dsc
-$ErrorActionPreference = "Stop"
+$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
<#
@@ -10,10 +10,9 @@ Set-StrictMode -Version Latest
BeforeAll {
# Before import module make sure Python is installed
- if ($env:TF_BUILD)
- {
+ if ($env:TF_BUILD) {
$outFile = Join-Path $env:TEMP 'python.exe'
- Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.14.0/python-3.14.0a1-amd64.exe" -UseBasicParsing -OutFile $outFile
+ Invoke-WebRequest -Uri 'https://www.python.org/ftp/python/3.14.0/python-3.14.0a1-amd64.exe' -UseBasicParsing -OutFile $outFile
& $outFile /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
}
@@ -22,7 +21,7 @@ BeforeAll {
Describe 'List available DSC resources' {
It 'Shows DSC Resources' {
- $expectedDSCResources = "Pip3Package"
+ $expectedDSCResources = 'Pip3Package'
$availableDSCResources = (Get-DscResource -Module PythonPip3Dsc).Name
$availableDSCResources.count | Should -Be 1
$availableDSCResources | Where-Object { $expectedDSCResources -notcontains $_ } | Should -BeNullOrEmpty -ErrorAction Stop
@@ -34,9 +33,9 @@ Describe 'Pip3Package' {
$desiredState = @{
PackageName = 'django'
}
-
+
Invoke-DscResource -Name Pip3Package -ModuleName PythonPip3Dsc -Method Set -Property $desiredState
-
+
$finalState = Invoke-DscResource -Name Pip3Package -ModuleName PythonPip3Dsc -Method Get -Property $desiredState
$finalState.PackageName | Should -Be $desiredState.PackageName
$finalState.Exist | Should -BeTrue
@@ -47,13 +46,13 @@ Describe 'Pip3Package' {
PackageName = 'flask'
Version = '3.0.3'
}
-
+
Invoke-DscResource -Name Pip3Package -ModuleName PythonPip3Dsc -Method Set -Property $desiredState
-
+
$finalState = Invoke-DscResource -Name Pip3Package -ModuleName PythonPip3Dsc -Method Get -Property $desiredState
$finalState.PackageName | Should -Be $desiredState.PackageName
$finalState.Exist | Should -BeTrue
- $finalState.Version | Should -Be $desiredState.Version
+ $finalState.Version | Should -Be $desiredState.Version
}
It 'Updates with specific version' -Skip:(!$IsWindows) {
@@ -61,7 +60,7 @@ Describe 'Pip3Package' {
PackageName = 'requests'
Version = '2.32.2'
}
-
+
Invoke-DscResource -Name Pip3Package -ModuleName PythonPip3Dsc -Method Set -Property $desiredState
# Now update the package to a newer version
@@ -71,7 +70,7 @@ Describe 'Pip3Package' {
$finalState = Invoke-DscResource -Name Pip3Package -ModuleName PythonPip3Dsc -Method Get -Property $desiredState
$finalState.PackageName | Should -Be $desiredState.PackageName
$finalState.Exist | Should -BeTrue
- $finalState.Version | Should -Be $desiredState.Version
+ $finalState.Version | Should -Be $desiredState.Version
}
It 'Handles non-existent package gracefully' -Skip:(!$IsWindows) {