From 869fff3453ea162c919f857e4a9378ccab2bd336 Mon Sep 17 00:00:00 2001 From: Jonas Cassier <61315302+JonasCassier@users.noreply.github.com> Date: Sun, 19 Nov 2023 17:03:36 +0100 Subject: [PATCH] OfficeOnlineServerDSC: Import DscResource.Common module (#68) - OfficeOnlineServerDsc - Imports DscResource.Common module - OfficeOnlineServerDsc - All resources - Get-LocalizedData from DscResource.Common is now used --- CHANGELOG.md | 7 + RequiredModules.psd1 | 3 + build.yaml | 13 + .../MSFT_OfficeOnlineServerFarm.psm1 | 246 +++++++++--------- .../MSFT_OfficeOnlineServerInstall.psm1 | 11 +- ...OfficeOnlineServerInstallLanguagePack.psm1 | 11 +- .../MSFT_OfficeOnlineServerMachine.psm1 | 11 +- .../MSFT_OfficeOnlineServerProductUpdate.psm1 | 11 +- .../OfficeOnlineServerDsc.Util.psm1 | 75 +----- 9 files changed, 179 insertions(+), 209 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcfa803..63781b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- OfficeOnlineServerDsc +- Imports DscResource.Common module + ### Changed - OfficeOnlineServerDsc - Updated to latest pipeline files. +- All resources + - Get-LocalizedData from DscResource.Common is now used ## [1.5.0] - 2020-04-03 diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 index 2df3b6c..975f436 100644 --- a/RequiredModules.psd1 +++ b/RequiredModules.psd1 @@ -21,4 +21,7 @@ xDscResourceDesigner = 'latest' 'DscResource.DocGenerator' = 'latest' PSDscResources = 'latest' + + # Build dependencies needed for using the module + 'DscResource.Common' = 'latest' } diff --git a/build.yaml b/build.yaml index effd013..01f4ba8 100644 --- a/build.yaml +++ b/build.yaml @@ -43,6 +43,17 @@ BuildWorkflow: - Publish_Release_To_GitHub - Publish_GitHub_Wiki_Content +#################################################### +# ModuleBuilder Dependent Modules Configuration # +#################################################### + +NestedModule: + DscResource.Common: + CopyOnly: true + Path: ./output/RequiredModules/DscResource.Common + AddToManifest: false + Exclude: PSGetModuleInfo.xml + #################################################### # PESTER Configuration # #################################################### @@ -50,6 +61,7 @@ BuildWorkflow: Pester: OutputFormat: NUnitXML ExcludeFromCodeCoverage: + - Modules/DscResource.Common Script: - tests/Unit ExcludeTag: @@ -76,6 +88,7 @@ DscTest: ExcludeSourceFile: - output ExcludeModuleFile: + - Modules/DscResource.Common MainGitBranch: master ModuleBuildTasks: diff --git a/src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1 b/src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1 index 474a7e7..1f1decc 100644 --- a/src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1 +++ b/src/DSCResources/MSFT_OfficeOnlineServerFarm/MSFT_OfficeOnlineServerFarm.psm1 @@ -1,21 +1,22 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'OfficeOnlineServerDsc.Util' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'OfficeOnlineServerDsc.Util.psm1') +$script:resourceHelperModulePath = @( + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\OfficeOnlineServerDsc.Util'), + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common') +) +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_OfficeOnlineServerFarm' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' $script:OOSDscRegKey = "HKLM:\SOFTWARE\OOSDsc" $script:v16onlyParams = @("AllowOutboundHttp", "S2SCertificateName", "OnlinePictureEnabled", ` - "OnlineVideoEnabled", "OfficeAddinEnabled", ` - "ExcelUseEffectiveUserName", "ExcelUdfsAllowed", ` - "ExcelMemoryCacheThreshold", "ExcelUnusedObjectAgeMax", ` - "ExcelCachingUnusedFiles", "ExcelAbortOnRefreshOnOpenFail", ` - "ExcelAutomaticVolatileFunctionCacheLifeTime", ` - "ExcelConcurrentDataRequestsPerSessionMax", ` - "ExcelDefaultWorkbookCalcMode", "ExcelRestExternalDataEnabled", ` - "ExcelChartAndImageSizeMax") + "OnlineVideoEnabled", "OfficeAddinEnabled", ` + "ExcelUseEffectiveUserName", "ExcelUdfsAllowed", ` + "ExcelMemoryCacheThreshold", "ExcelUnusedObjectAgeMax", ` + "ExcelCachingUnusedFiles", "ExcelAbortOnRefreshOnOpenFail", ` + "ExcelAutomaticVolatileFunctionCacheLifeTime", ` + "ExcelConcurrentDataRequestsPerSessionMax", ` + "ExcelDefaultWorkbookCalcMode", "ExcelRestExternalDataEnabled", ` + "ExcelChartAndImageSizeMax") function Get-TargetResource { @@ -240,56 +241,56 @@ function Get-TargetResource } $returnValue = @{ - AllowCEIP = $officeWebAppsFarm.AllowCEIP - AllowHttp = $officeWebAppsFarm.AllowHTTP - AllowHttpSecureStoreConnections = $officeWebAppsFarm.AllowHttpSecureStoreConnections - CacheLocation = $officeWebAppsFarm.CacheLocation - CacheSizeInGB = $officeWebAppsFarm.CacheSizeInGB - CertificateName = $officeWebAppsFarm.CertificateName - ClipartEnabled = $officeWebAppsFarm.ClipartEnabled - DocumentInfoCacheSize = $officeWebAppsFarm.DocumentInfoCacheSize - EditingEnabled = $officeWebAppsFarm.EditingEnabled - ExcelAllowExternalData = $officeWebAppsFarm.ExcelAllowExternalData - ExcelConnectionLifetime = $officeWebAppsFarm.ExcelConnectionLifetime - ExcelExternalDataCacheLifetime = $officeWebAppsFarm.ExcelExternalDataCacheLifetime - ExcelPrivateBytesMax = $officeWebAppsFarm.ExcelPrivateBytesMax - ExcelRequestDurationMax = $officeWebAppsFarm.ExcelRequestDurationMax - ExcelSessionTimeout = $officeWebAppsFarm.ExcelSessionTimeout - ExcelUdfsAllowed = $officeWebAppsFarm.ExcelUdfsAllowed - ExcelWarnOnDataRefresh = $officeWebAppsFarm.ExcelWarnOnDataRefresh - ExcelWorkbookSizeMax = $officeWebAppsFarm.ExcelWorkbookSizeMax - ExcelMemoryCacheThreshold = $officeWebAppsFarm.ExcelMemoryCacheThreshold - ExcelUnusedObjectAgeMax = $officeWebAppsFarm.ExcelUnusedObjectAgeMax - ExcelCachingUnusedFiles = $officeWebAppsFarm.ExcelCachingUnusedFiles - ExcelAbortOnRefreshOnOpenFail = $officeWebAppsFarm.ExcelAbortOnRefreshOnOpenFail + AllowCEIP = $officeWebAppsFarm.AllowCEIP + AllowHttp = $officeWebAppsFarm.AllowHTTP + AllowHttpSecureStoreConnections = $officeWebAppsFarm.AllowHttpSecureStoreConnections + CacheLocation = $officeWebAppsFarm.CacheLocation + CacheSizeInGB = $officeWebAppsFarm.CacheSizeInGB + CertificateName = $officeWebAppsFarm.CertificateName + ClipartEnabled = $officeWebAppsFarm.ClipartEnabled + DocumentInfoCacheSize = $officeWebAppsFarm.DocumentInfoCacheSize + EditingEnabled = $officeWebAppsFarm.EditingEnabled + ExcelAllowExternalData = $officeWebAppsFarm.ExcelAllowExternalData + ExcelConnectionLifetime = $officeWebAppsFarm.ExcelConnectionLifetime + ExcelExternalDataCacheLifetime = $officeWebAppsFarm.ExcelExternalDataCacheLifetime + ExcelPrivateBytesMax = $officeWebAppsFarm.ExcelPrivateBytesMax + ExcelRequestDurationMax = $officeWebAppsFarm.ExcelRequestDurationMax + ExcelSessionTimeout = $officeWebAppsFarm.ExcelSessionTimeout + ExcelUdfsAllowed = $officeWebAppsFarm.ExcelUdfsAllowed + ExcelWarnOnDataRefresh = $officeWebAppsFarm.ExcelWarnOnDataRefresh + ExcelWorkbookSizeMax = $officeWebAppsFarm.ExcelWorkbookSizeMax + ExcelMemoryCacheThreshold = $officeWebAppsFarm.ExcelMemoryCacheThreshold + ExcelUnusedObjectAgeMax = $officeWebAppsFarm.ExcelUnusedObjectAgeMax + ExcelCachingUnusedFiles = $officeWebAppsFarm.ExcelCachingUnusedFiles + ExcelAbortOnRefreshOnOpenFail = $officeWebAppsFarm.ExcelAbortOnRefreshOnOpenFail ExcelAutomaticVolatileFunctionCacheLifetime = $officeWebAppsFarm.ExcelAutomaticVolatileFunctionCacheLifeTime - ExcelConcurrentDataRequestsPerSessionMax = $officeWebAppsFarm.ExcelConcurrentDataRequestsPerSessionMax - ExcelDefaultWorkbookCalcMode = $officeWebAppsFarm.ExcelDefaultWorkbookCalcMode - ExcelRestExternalDataEnabled = $officeWebAppsFarm.ExcelRestExternalDataEnabled - ExcelChartAndImageSizeMax = $officeWebAppsFarm.ExcelChartAndImageSizeMax - ExternalURL = $officeWebAppsFarm.ExternalURL - FarmOU = $officeWebAppsFarm.FarmOU - InternalURL = $officeWebAppsFarm.InternalURL - LogLocation = $officeWebAppsFarm.LogLocation - LogRetentionInDays = $officeWebAppsFarm.LogRetentionInDays - LogVerbosity = $officeWebAppsFarm.LogVerbosity - MaxMemoryCacheSizeInMB = $officeWebAppsFarm.MaxMemoryCacheSizeInMB - MaxTranslationCharacterCount = $officeWebAppsFarm.MaxTranslationCharacterCount - OpenFromUncEnabled = $officeWebAppsFarm.OpenFromUncEnabled - OpenFromUrlEnabled = $officeWebAppsFarm.OpenFromUrlEnabled - OpenFromUrlThrottlingEnabled = $officeWebAppsFarm.OpenFromUrlThrottlingEnabled - PicturePasteDisabled = $officeWebAppsFarm.PicturePasteDisabled - Proxy = $officeWebAppsFarm.Proxy - RecycleActiveProcessCount = $officeWebAppsFarm.RecycleActiveProcessCount - RenderingLocalCacheLocation = $officeWebAppsFarm.RenderingLocalCacheLocation - SSLOffloaded = $officeWebAppsFarm.SSLOffloaded - TranslationEnabled = $officeWebAppsFarm.TranslationEnabled - TranslationServiceAddress = $officeWebAppsFarm.TranslationServiceAddress - TranslationServiceAppId = $officeWebAppsFarm.TranslationServiceAppId - RemovePersonalInformationFromLogs = $officeWebAppsFarm.RemovePersonalInformationFromLogs - ExcelUseEffectiveUserName = $officeWebAppsFarm.ExcelUseEffectiveUserName - AllowOutboundHttp = $officeWebAppsFarm.AllowOutboundHttp - S2SCertificateName = $officeWebAppsFarm.S2SCertificateName + ExcelConcurrentDataRequestsPerSessionMax = $officeWebAppsFarm.ExcelConcurrentDataRequestsPerSessionMax + ExcelDefaultWorkbookCalcMode = $officeWebAppsFarm.ExcelDefaultWorkbookCalcMode + ExcelRestExternalDataEnabled = $officeWebAppsFarm.ExcelRestExternalDataEnabled + ExcelChartAndImageSizeMax = $officeWebAppsFarm.ExcelChartAndImageSizeMax + ExternalURL = $officeWebAppsFarm.ExternalURL + FarmOU = $officeWebAppsFarm.FarmOU + InternalURL = $officeWebAppsFarm.InternalURL + LogLocation = $officeWebAppsFarm.LogLocation + LogRetentionInDays = $officeWebAppsFarm.LogRetentionInDays + LogVerbosity = $officeWebAppsFarm.LogVerbosity + MaxMemoryCacheSizeInMB = $officeWebAppsFarm.MaxMemoryCacheSizeInMB + MaxTranslationCharacterCount = $officeWebAppsFarm.MaxTranslationCharacterCount + OpenFromUncEnabled = $officeWebAppsFarm.OpenFromUncEnabled + OpenFromUrlEnabled = $officeWebAppsFarm.OpenFromUrlEnabled + OpenFromUrlThrottlingEnabled = $officeWebAppsFarm.OpenFromUrlThrottlingEnabled + PicturePasteDisabled = $officeWebAppsFarm.PicturePasteDisabled + Proxy = $officeWebAppsFarm.Proxy + RecycleActiveProcessCount = $officeWebAppsFarm.RecycleActiveProcessCount + RenderingLocalCacheLocation = $officeWebAppsFarm.RenderingLocalCacheLocation + SSLOffloaded = $officeWebAppsFarm.SSLOffloaded + TranslationEnabled = $officeWebAppsFarm.TranslationEnabled + TranslationServiceAddress = $officeWebAppsFarm.TranslationServiceAddress + TranslationServiceAppId = $officeWebAppsFarm.TranslationServiceAppId + RemovePersonalInformationFromLogs = $officeWebAppsFarm.RemovePersonalInformationFromLogs + ExcelUseEffectiveUserName = $officeWebAppsFarm.ExcelUseEffectiveUserName + AllowOutboundHttp = $officeWebAppsFarm.AllowOutboundHttp + S2SCertificateName = $officeWebAppsFarm.S2SCertificateName } return $returnValue @@ -771,8 +772,8 @@ function Test-TargetResource if ((Test-OosDscFarmOu -ExistingOU $officeWebAppsFarm.FarmOU -DesiredOU $FarmOU) -ne $true) { Write-Verbose -Message ("FarmOU not in a desired state. " + ` - "Expected: '$($PSBoundParameters['FarmOU'])'. " + ` - "Actual: '$($officeWebAppsFarm.FarmOU)'.") + "Expected: '$($PSBoundParameters['FarmOU'])'. " + ` + "Actual: '$($officeWebAppsFarm.FarmOU)'.") return $false } } @@ -795,58 +796,58 @@ function Test-TargetResource $Proxy += "/" } return Test-OosDscParameterState -CurrentValues $CurrentValues ` - -DesiredValues $PSBoundParameters ` - -ValuesToCheck @( - "InternalURL", - "ExternalURL", - "Proxy", - "AllowHTTP", - "AllowOutboundHttp", - "SSLOffloaded", - "CertificateName", - "S2SCertificateName", - "EditingEnabled", - "LogLocation", - "LogRetentionInDays", - "LogVerbosity", - "CacheLocation", - "MaxMemoryCacheSizeInMB", - "DocumentInfoCacheSize", - "CacheSizeInGB", - "ClipartEnabled", - "TranslationEnabled", - "MaxTranslationCharacterCount", - "TranslationServiceAppId", - "TranslationServiceAddress", - "RenderingLocalCacheLocation", - "RecycleActiveProcessCount", - "AllowCEIP", - "ExcelRequestDurationMax", - "ExcelSessionTimeout", - "ExcelWorkbookSizeMax", - "ExcelPrivateBytesMax", - "ExcelConnectionLifetime", - "ExcelExternalDataCacheLifetime", - "ExcelAllowExternalData", - "ExcelUseEffectiveUserName", - "ExcelWarnOnDataRefresh", - "ExcelUdfsAllowed", - "ExcelMemoryCacheThreshold", - "ExcelUnusedObjectAgeMax", - "ExcelCachingUnusedFiles", - "ExcelAbortOnRefreshOnOpenFail", - "ExcelAutomaticVolatileFunctionCacheLifeTime", - "ExcelConcurrentDataRequestsPerSessionMax", - "ExcelDefaultWorkbookCalcMode", - "ExcelRestExternalDataEnabled", - "ExcelChartAndImageSizeMax", - "OpenFromUrlEnabled", - "OpenFromUncEnabled", - "OpenFromUrlThrottlingEnabled", - "PicturePasteDisabled", - "RemovePersonalInformationFromLogs", - "AllowHttpSecureStoreConnections" - ) + -DesiredValues $PSBoundParameters ` + -ValuesToCheck @( + "InternalURL", + "ExternalURL", + "Proxy", + "AllowHTTP", + "AllowOutboundHttp", + "SSLOffloaded", + "CertificateName", + "S2SCertificateName", + "EditingEnabled", + "LogLocation", + "LogRetentionInDays", + "LogVerbosity", + "CacheLocation", + "MaxMemoryCacheSizeInMB", + "DocumentInfoCacheSize", + "CacheSizeInGB", + "ClipartEnabled", + "TranslationEnabled", + "MaxTranslationCharacterCount", + "TranslationServiceAppId", + "TranslationServiceAddress", + "RenderingLocalCacheLocation", + "RecycleActiveProcessCount", + "AllowCEIP", + "ExcelRequestDurationMax", + "ExcelSessionTimeout", + "ExcelWorkbookSizeMax", + "ExcelPrivateBytesMax", + "ExcelConnectionLifetime", + "ExcelExternalDataCacheLifetime", + "ExcelAllowExternalData", + "ExcelUseEffectiveUserName", + "ExcelWarnOnDataRefresh", + "ExcelUdfsAllowed", + "ExcelMemoryCacheThreshold", + "ExcelUnusedObjectAgeMax", + "ExcelCachingUnusedFiles", + "ExcelAbortOnRefreshOnOpenFail", + "ExcelAutomaticVolatileFunctionCacheLifeTime", + "ExcelConcurrentDataRequestsPerSessionMax", + "ExcelDefaultWorkbookCalcMode", + "ExcelRestExternalDataEnabled", + "ExcelChartAndImageSizeMax", + "OpenFromUrlEnabled", + "OpenFromUncEnabled", + "OpenFromUrlThrottlingEnabled", + "PicturePasteDisabled", + "RemovePersonalInformationFromLogs", + "AllowHttpSecureStoreConnections" + ) } function Test-OosDscV16Support @@ -855,7 +856,7 @@ function Test-OosDscV16Support [OutputType([System.Boolean])] param ( - [Parameter(Mandatory=$true)] + [Parameter(Mandatory = $true)] [Object] $Parameters ) @@ -863,7 +864,8 @@ function Test-OosDscV16Support $version = Get-OosDscInstalledProductVersion switch ($version.Major) { - 15 { + 15 + { Write-Verbose -Message $script:localizedData.OWA2013Detected foreach ($param in $script:v16onlyParams) { @@ -873,12 +875,14 @@ function Test-OosDscV16Support } } } - 16 { + 16 + { Write-Verbose -Message $script:localizedData.OOS2016Detected } - Default { + Default + { throw ("This module only supports Office Web Apps 2013 (v15) and Office " + ` - "Online Server 2016 (v16). Detected version was $($version.Major)") + "Online Server 2016 (v16). Detected version was $($version.Major)") } } } diff --git a/src/DSCResources/MSFT_OfficeOnlineServerInstall/MSFT_OfficeOnlineServerInstall.psm1 b/src/DSCResources/MSFT_OfficeOnlineServerInstall/MSFT_OfficeOnlineServerInstall.psm1 index 7fbeb36..9193c2d 100644 --- a/src/DSCResources/MSFT_OfficeOnlineServerInstall/MSFT_OfficeOnlineServerInstall.psm1 +++ b/src/DSCResources/MSFT_OfficeOnlineServerInstall/MSFT_OfficeOnlineServerInstall.psm1 @@ -1,9 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'OfficeOnlineServerDsc.Util' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'OfficeOnlineServerDsc.Util.psm1') +$script:resourceHelperModulePath = @( + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\OfficeOnlineServerDsc.Util'), + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common') +) +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_OfficeOnlineServerInstall' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' $Script:UninstallPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $script:InstallKeyPattern = "Office1(5)|(6).WacServer" diff --git a/src/DSCResources/MSFT_OfficeOnlineServerInstallLanguagePack/MSFT_OfficeOnlineServerInstallLanguagePack.psm1 b/src/DSCResources/MSFT_OfficeOnlineServerInstallLanguagePack/MSFT_OfficeOnlineServerInstallLanguagePack.psm1 index 93f089a..191fe62 100644 --- a/src/DSCResources/MSFT_OfficeOnlineServerInstallLanguagePack/MSFT_OfficeOnlineServerInstallLanguagePack.psm1 +++ b/src/DSCResources/MSFT_OfficeOnlineServerInstallLanguagePack/MSFT_OfficeOnlineServerInstallLanguagePack.psm1 @@ -1,9 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'OfficeOnlineServerDsc.Util' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'OfficeOnlineServerDsc.Util.psm1') +$script:resourceHelperModulePath = @( + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\OfficeOnlineServerDsc.Util'), + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common') +) +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_OfficeOnlineServerInstallLanguagePack' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' $Script:UninstallPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $script:InstallKeyPattern = "Office1(5)|(6).WacServerLpk." diff --git a/src/DSCResources/MSFT_OfficeOnlineServerMachine/MSFT_OfficeOnlineServerMachine.psm1 b/src/DSCResources/MSFT_OfficeOnlineServerMachine/MSFT_OfficeOnlineServerMachine.psm1 index 5ab2b3c..ca43a55 100644 --- a/src/DSCResources/MSFT_OfficeOnlineServerMachine/MSFT_OfficeOnlineServerMachine.psm1 +++ b/src/DSCResources/MSFT_OfficeOnlineServerMachine/MSFT_OfficeOnlineServerMachine.psm1 @@ -1,9 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'OfficeOnlineServerDsc.Util' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'OfficeOnlineServerDsc.Util.psm1') +$script:resourceHelperModulePath = @( + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\OfficeOnlineServerDsc.Util'), + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common') +) +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_OfficeOnlineServerMachine' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' $script:OOSDscRegKey = "HKLM:\SOFTWARE\OOSDsc" diff --git a/src/DSCResources/MSFT_OfficeOnlineServerProductUpdate/MSFT_OfficeOnlineServerProductUpdate.psm1 b/src/DSCResources/MSFT_OfficeOnlineServerProductUpdate/MSFT_OfficeOnlineServerProductUpdate.psm1 index 832374b..c94cb2c 100644 --- a/src/DSCResources/MSFT_OfficeOnlineServerProductUpdate/MSFT_OfficeOnlineServerProductUpdate.psm1 +++ b/src/DSCResources/MSFT_OfficeOnlineServerProductUpdate/MSFT_OfficeOnlineServerProductUpdate.psm1 @@ -1,9 +1,10 @@ -$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent -$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules' -$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'OfficeOnlineServerDsc.Util' -Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'OfficeOnlineServerDsc.Util.psm1') +$script:resourceHelperModulePath = @( + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\OfficeOnlineServerDsc.Util'), + (Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common') +) +Import-Module -Name $script:resourceHelperModulePath -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_OfficeOnlineServerProductUpdate' +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' $script:OOSDscRegKey = "HKLM:\SOFTWARE\OOSDsc" diff --git a/src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1 b/src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1 index e517221..37b83e5 100644 --- a/src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1 +++ b/src/Modules/OfficeOnlineServerDsc.Util/OfficeOnlineServerDsc.Util.psm1 @@ -135,67 +135,6 @@ function Convert-OOSDscCIMInstanceToString return $str } -<# - .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: - For WindowsOptionalFeature: MSFT_WindowsOptionalFeature - For Service: MSFT_ServiceResource - For Registry: MSFT_RegistryResource - For Helper: SqlServerDscHelper - .PARAMETER ScriptRoot - Optional. The root path where to expect to find the culture folder. This is only needed - for localization in helper modules. This should not normally be used for resources. - .NOTES - To be able to use localization in the helper function, this function must - be first in the file, before Get-LocalizedData is used by itself to load - localized data for this helper module (see directly after this function). -#> -function Get-LocalizedData -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [System.String] - $ResourceName, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [System.String] - $ScriptRoot - ) - - if (-not $ScriptRoot) - { - $dscResourcesFolder = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'DSCResources' - $resourceDirectory = Join-Path -Path $dscResourcesFolder -ChildPath $ResourceName - } - else - { - $resourceDirectory = $ScriptRoot - } - - $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 -} - <# .SYNOPSIS @@ -209,13 +148,13 @@ function Get-OosDscInstalledProductVersion param () return Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | ` - Select-Object DisplayName, DisplayVersion | ` - Where-Object { - $_.DisplayName -eq "Microsoft Office Web Apps Server 2013" -or ` - $_.DisplayName -eq "Microsoft Office Online Server" - } | ForEach-Object -Process { - return [Version]::Parse($_.DisplayVersion) - } | Select-Object -First 1 + Select-Object DisplayName, DisplayVersion | ` + Where-Object { + $_.DisplayName -eq "Microsoft Office Web Apps Server 2013" -or ` + $_.DisplayName -eq "Microsoft Office Online Server" + } | ForEach-Object -Process { + return [Version]::Parse($_.DisplayVersion) + } | Select-Object -First 1 }