forked from dsccommunity/ComputerManagementDsc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to xComputerManagement and xPowerPlan
Added helper module to handle localizaton with Get-LocalizedData in xComputerManagement Added localication to xPowerPlan Improved error handling in xPowerPlan Added comment-based help to example
- Loading branch information
Showing
6 changed files
with
141 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<# | ||
.SYNOPSIS | ||
Retrieves the localized string data based on the machine's culture. | ||
Falls back to en-US strings if the machine's culture is not supported. | ||
.PARAMETER ResourceName | ||
The name of the resource as it appears before '.strings.psd1' of the localized string file. | ||
For example: | ||
WindowsOptionalFeature: MSFT_WindowsOptionalFeature | ||
Service: MSFT_ServiceResource | ||
Registry: MSFT_RegistryResource | ||
#> | ||
function Get-LocalizedData | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[String] | ||
$ResourceName | ||
) | ||
|
||
$resourceDirectory = Join-Path -Path $PSScriptRoot -ChildPath $ResourceName | ||
$localizedStringFileLocation = Join-Path -Path $resourceDirectory -ChildPath $PSUICulture | ||
|
||
if (-not (Test-Path -Path $localizedStringFileLocation)) | ||
{ | ||
# Fallback to en-US | ||
$localizedStringFileLocation = Join-Path -Path $resourceDirectory -ChildPath 'en-US' | ||
} | ||
|
||
Import-LocalizedData ` | ||
-BindingVariable 'localizedData' ` | ||
-FileName "$ResourceName.strings.psd1" ` | ||
-BaseDirectory $localizedStringFileLocation | ||
|
||
return $localizedData | ||
} | ||
|
||
Export-ModuleMember -Function @( | ||
'Test-IsNanoServer', | ||
'New-InvalidArgumentException', | ||
'New-InvalidOperationException', | ||
'Get-LocalizedData' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
DSCResources/MSFT_xPowerPlan/en-US/MSFT_xPowerPlan.schema.mfl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[Description("This resource is used to activate a power plan.") : Amended,AMENDMENT, LOCALE("MS_409")] | ||
class MSFT_xPowerPlan : OMI_BaseResource | ||
{ | ||
[Key, Description("Specifies the resource is a single instance, the value must be 'Yes'") : Amended] String IsSingleInstance; | ||
[Required, Description("The name of the power plan to activate.") : Amended] String Name; | ||
}; |
11 changes: 11 additions & 0 deletions
11
DSCResources/MSFT_xPowerPlan/en-US/MSFT_xPowerPlan.strings.psd1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Localized resources for WindowsOptionalFeature | ||
|
||
ConvertFrom-StringData @' | ||
PowerPlanIsActive = The power plan '{0}' is the active plan. | ||
PowerPlanIsNotActive = The power plan '{0}' is not the active plan. | ||
PowerPlanNotFound = Unable to find the power plan '{0}'. | ||
PowerPlanIsBeingActivated = Activating power plan '{0}' | ||
PowerPlanIsBeingValidate = Validating power plan '{0}' | ||
PowerPlanWasUnableToBeSet = Unable to set the power plan '{0}' to the active plan. Error message: {1} | ||
PowerPlanCIMError = Could not get the Common Information Model (CIM) instances of class {0} | ||
'@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters