Skip to content

Commit 2715745

Browse files
authored
Merge pull request #124 from PowerShell/dev
Release of version 3.2.0.0 of xComputerManagement
2 parents 662d5cf + 01b9587 commit 2715745

31 files changed

+2183
-1033
lines changed

DSCResources/CommonResourceHelper.psm1

Lines changed: 0 additions & 425 deletions
This file was deleted.

DSCResources/MSFT_xComputer/MSFT_xComputer.psm1

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,22 @@ param
33
(
44
)
55

6-
Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) `
7-
-ChildPath 'CommonResourceHelper.psm1')
8-
$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xComputer'
6+
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
7+
8+
# Import the ComputerManagementDsc Common Modules
9+
Import-Module -Name (Join-Path -Path $modulePath `
10+
-ChildPath (Join-Path -Path 'ComputerManagementDsc.Common' `
11+
-ChildPath 'ComputerManagementDsc.Common.psm1'))
12+
13+
# Import the ComputerManagementDsc Resource Helper Module
14+
Import-Module -Name (Join-Path -Path $modulePath `
15+
-ChildPath (Join-Path -Path 'ComputerManagementDsc.ResourceHelper' `
16+
-ChildPath 'ComputerManagementDsc.ResourceHelper.psm1'))
17+
18+
# Import Localization Strings
19+
$script:localizedData = Get-LocalizedData `
20+
-ResourceName 'MSFT_xComputer' `
21+
-ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)
922

1023
<#
1124
.SYNOPSIS

DSCResources/MSFT_xOfflineDomainJoin/MSFT_xOfflineDomainJoin.psm1

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,22 @@ param
33
(
44
)
55

6-
Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) `
7-
-ChildPath 'CommonResourceHelper.psm1')
8-
$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xOfflineDomainJoin'
6+
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
7+
8+
# Import the ComputerManagementDsc Common Modules
9+
Import-Module -Name (Join-Path -Path $modulePath `
10+
-ChildPath (Join-Path -Path 'ComputerManagementDsc.Common' `
11+
-ChildPath 'ComputerManagementDsc.Common.psm1'))
12+
13+
# Import the ComputerManagementDsc Resource Helper Module
14+
Import-Module -Name (Join-Path -Path $modulePath `
15+
-ChildPath (Join-Path -Path 'ComputerManagementDsc.ResourceHelper' `
16+
-ChildPath 'ComputerManagementDsc.ResourceHelper.psm1'))
17+
18+
# Import Localization Strings
19+
$script:localizedData = Get-LocalizedData `
20+
-ResourceName 'MSFT_xOfflineDomainJoin' `
21+
-ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)
922

1023
<#
1124
.SYNOPSIS

DSCResources/MSFT_xPowerPlan/MSFT_xPowerPlan.psm1

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) `
2-
-ChildPath 'CommonResourceHelper.psm1')
3-
$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xPowerPlan'
1+
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
2+
3+
# Import the ComputerManagementDsc Common Modules
4+
Import-Module -Name (Join-Path -Path $modulePath `
5+
-ChildPath (Join-Path -Path 'ComputerManagementDsc.Common' `
6+
-ChildPath 'ComputerManagementDsc.Common.psm1'))
7+
8+
# Import the ComputerManagementDsc Resource Helper Module
9+
Import-Module -Name (Join-Path -Path $modulePath `
10+
-ChildPath (Join-Path -Path 'ComputerManagementDsc.ResourceHelper' `
11+
-ChildPath 'ComputerManagementDsc.ResourceHelper.psm1'))
12+
13+
# Import Localization Strings
14+
$script:localizedData = Get-LocalizedData `
15+
-ResourceName 'MSFT_xPowerPlan' `
16+
-ResourcePath (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)
417

518
<#
619
.SYNOPSIS
@@ -33,19 +46,20 @@ function Get-TargetResource
3346
$Name
3447
)
3548

36-
$arguments = @{
37-
Name = 'root\cimv2\power'
38-
Class = 'Win32_PowerPlan'
49+
$getCimInstanceArguments = @{
50+
Name = 'root\cimv2\power'
51+
Class = 'Win32_PowerPlan'
3952
Filter = "ElementName = '$Name'"
4053
}
4154

4255
try
4356
{
44-
$plan = Get-CimInstance @arguments
57+
$plan = Get-CimInstance @getCimInstanceArguments
4558
}
4659
catch
4760
{
48-
throw ($script:localizedData.PowerPlanCIMError -f $($arguments.Class) )
61+
New-InvalidOperationException `
62+
-Message ($script:localizedData.PowerPlanCimError -f $getCimInstanceArguments.Class)
4963
}
5064

5165
if ($plan)
@@ -63,12 +77,13 @@ function Get-TargetResource
6377
}
6478
else
6579
{
66-
throw ($script:localizedData.PowerPlanNotFound -f $Name)
80+
New-InvalidOperationException `
81+
-Message ($script:localizedData.PowerPlanNotFound -f $Name)
6782
}
6883

6984
return @{
7085
IsSingleInstance = $IsSingleInstance
71-
Name = $activePlanName
86+
Name = $activePlanName
7287
}
7388
}
7489

@@ -104,19 +119,20 @@ function Set-TargetResource
104119

105120
Write-Verbose -Message ($script:localizedData.PowerPlanIsBeingActivated -f $Name)
106121

107-
$arguments = @{
108-
Name = 'root\cimv2\power'
109-
Class = 'Win32_PowerPlan'
122+
$getCimInstanceArguments = @{
123+
Name = 'root\cimv2\power'
124+
Class = 'Win32_PowerPlan'
110125
Filter = "ElementName = '$Name'"
111126
}
112127

113128
try
114129
{
115-
$plan = Get-CimInstance @arguments
130+
$plan = Get-CimInstance @getCimInstanceArguments
116131
}
117132
catch
118133
{
119-
throw ($script:localizedData.PowerPlanCIMError -f $($arguments.Class) )
134+
New-InvalidOperationException `
135+
-Message ($script:localizedData.PowerPlanCimError -f $getCimInstanceArguments.Class)
120136
}
121137

122138
try
@@ -125,7 +141,8 @@ function Set-TargetResource
125141
}
126142
catch
127143
{
128-
throw ($script:localizedData.PowerPlanWasUnableToBeSet -f $Name, $($_.Exception.Message))
144+
New-InvalidOperationException `
145+
-Message ($script:localizedData.PowerPlanWasUnableToBeSet -f $Name, $_.Exception.Message)
129146
}
130147
}
131148

@@ -165,6 +182,7 @@ function Test-TargetResource
165182
Write-Verbose -Message ($script:localizedData.PowerPlanIsBeingValidated -f $Name)
166183

167184
$getTargetResourceResult = Get-TargetResource -IsSingleInstance $IsSingleInstance -Name $Name
185+
168186
if ($getTargetResourceResult.Name -eq $Name)
169187
{
170188
$returnValue = $true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[ClassVersion("1.0.0.0"), FriendlyName("xPowerPlan")]
22
class MSFT_xPowerPlan : OMI_BaseResource
33
{
4-
[Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance;
4+
[Key, Description("Specifies the resource is a single instance, the value must be 'Yes'."), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance;
55
[Required, Description("The name of the power plan to activate.")] String Name;
66
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Description("This resource is used to activate a power plan.") : Amended,AMENDMENT, LOCALE("MS_409")]
22
class MSFT_xPowerPlan : OMI_BaseResource
33
{
4-
[Key, Description("Specifies the resource is a single instance, the value must be 'Yes'") : Amended] String IsSingleInstance;
4+
[Key, Description("Specifies the resource is a single instance, the value must be 'Yes'.") : Amended] String IsSingleInstance;
55
[Description("The name of the power plan to activate.") : Amended] String Name;
66
};

DSCResources/MSFT_xPowerPlan/en-US/MSFT_xPowerPlan.strings.psd1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ConvertFrom-StringData @'
44
PowerPlanIsActive = The power plan '{0}' is the active plan.
55
PowerPlanIsNotActive = The power plan '{0}' is not the active plan.
66
PowerPlanNotFound = Unable to find the power plan '{0}'.
7-
PowerPlanIsBeingActivated = Activating power plan '{0}'
8-
PowerPlanIsBeingValidated = Validating power plan '{0}'
7+
PowerPlanIsBeingActivated = Activating power plan '{0}'.
8+
PowerPlanIsBeingValidated = Validating power plan '{0}'.
99
PowerPlanWasUnableToBeSet = Unable to set the power plan '{0}' to the active plan. Error message: {1}
10-
PowerPlanCIMError = Could not get the Common Information Model (CIM) instances of class {0}
10+
PowerPlanCimError = Could not get the Common Information Model (CIM) instances of class '{0}'.
1111
'@

0 commit comments

Comments
 (0)