From 41276a23220552ed069752cc007167b4c9035000 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 19:51:49 +1300 Subject: [PATCH 01/30] Update 1 to move to new CIprocess --- .MetaTestOptIn.json | 14 - .codecov.yml | 26 - .github/PULL_REQUEST_TEMPLATE.md | 2 +- .gitignore | 10 +- .vscode/settings.json | 1 + CHANGELOG.md | 404 +--------------- CODE_OF_CONDUCT.md | 7 +- ComputerManagementDsc.psd1 | 82 ---- GitVersion.yml | 26 + HISTORIC_CHANGELOG.md | 451 ++++++++++++++++++ LICENSE | 34 +- README.md | 56 +-- RequiredModules.psd1 | 21 + Resolve-Dependency.ps1 | 288 +++++++++++ Resolve-Dependency.psd1 | 5 + Tests/Unit/MSFT_ScheduledTask.Tests.ps1 | 2 +- appveyor.yml | 44 -- azure-pipelines.yml | 289 +++++++++++ build.ps1 | 354 ++++++++++++++ build.yaml | 88 ++++ source/Build.psd1 | 5 + source/ComputerManagementDsc.psd1 | 90 ++++ .../MSFT_Computer/MSFT_Computer.psm1 | 0 .../MSFT_Computer/MSFT_Computer.schema.mof | 0 .../DSCResources}/MSFT_Computer/README.md | 0 .../en-US/MSFT_Computer.strings.psd1 | 0 .../MSFT_OfflineDomainJoin.psm1 | 0 .../MSFT_OfflineDomainJoin.schema.mof | 0 .../MSFT_OfflineDomainJoin/README.md | 0 .../en-US/MSFT_OfflineDomainJoin.strings.psd1 | 0 .../MSFT_PendingReboot.psm1 | 0 .../MSFT_PendingReboot.schema.mof | 0 .../MSFT_PendingReboot/README.md | 0 .../en-US/MSFT_PendingReboot.data.psd1 | 0 .../en-US/MSFT_PendingReboot.strings.psd1 | 0 .../MSFT_PowerPlan/MSFT_PowerPlan.psm1 | 0 .../MSFT_PowerPlan/MSFT_PowerPlan.schema.mof | 0 .../DSCResources}/MSFT_PowerPlan/README.md | 0 .../en-US/MSFT_PowerPlan.schema.mfl | 0 .../en-US/MSFT_PowerPlan.strings.psd1 | 0 .../MSFT_PowerShellExecutionPolicy.psm1 | 0 .../MSFT_PowerShellExecutionPolicy.schema.mof | 0 .../MSFT_PowerShellExecutionPolicy/README.md | 0 ...SFT_PowerShellExecutionPolicy.strings.psd1 | 0 .../MSFT_RemoteDesktopAdmin.psm1 | 0 .../MSFT_RemoteDesktopAdmin.schema.mof | 0 .../MSFT_RemoteDesktopAdmin/README.md | 0 .../MSFT_RemoteDesktopAdmin.strings.psd1 | 0 .../MSFT_ScheduledTask.psm1 | 2 +- .../MSFT_ScheduledTask.schema.mof | 0 .../MSFT_ScheduledTask/README.md | 0 .../en-US/MSFT_ScheduledTask.strings.psd1 | 0 .../MSFT_SmbServerConfiguration.data.psd1 | 0 .../MSFT_SmbServerConfiguration.psm1 | 0 .../MSFT_SmbServerConfiguration.schema.mof | 0 .../MSFT_SmbServerConfiguration/README.md | 0 .../MSFT_SmbServerConfiguration.schema.mfl | 0 .../MSFT_SmbServerConfiguration.strings.psd1 | 0 .../MSFT_SmbShare/MSFT_SmbShare.psm1 | 0 .../MSFT_SmbShare/MSFT_SmbShare.schema.mof | 0 .../DSCResources}/MSFT_SmbShare/README.md | 0 .../en-US/MSFT_SmbShare.schema.mfl | 0 .../en-US/MSFT_SmbShare.strings.psd1 | 0 .../MSFT_SystemLocale/MSFT_SystemLocale.psm1 | 0 .../MSFT_SystemLocale.schema.mof | 0 .../DSCResources}/MSFT_SystemLocale/README.md | 0 .../en-US/MSFT_SystemLocale.strings.psd1 | 0 .../MSFT_TimeZone/MSFT_TimeZone.psm1 | 0 .../MSFT_TimeZone/MSFT_TimeZone.schema.mof | 0 .../DSCResources}/MSFT_TimeZone/README.md | 0 .../en-US/MSFT_TimeZone.strings.psd1 | 0 .../MSFT_VirtualMemory.psm1 | 0 .../MSFT_VirtualMemory.schema.mof | 0 .../MSFT_VirtualMemory/README.md | 0 .../en-US/MSFT_VirtualMemory.strings.psd1 | 0 .../MSFT_WindowsCapability.psm1 | 0 .../MSFT_WindowsCapability.schema.mof | 0 .../MSFT_WindowsCapability/README.md | 0 .../en-US/MSFT_WindowsCapability.strings.psd1 | 0 .../MSFT_WindowsEventLog.psm1 | 0 .../MSFT_WindowsEventLog.schema.mof | 0 .../MSFT_WindowsEventLog/README.md | 0 .../en-US/MSFT_WindowsEventLog.strings.psd1 | 0 ...r_RenameComputerAndSetWorkgroup_Config.ps1 | 10 +- .../Computer/2-Computer_JoinDomain_Config.ps1 | 10 +- ...Computer_RenameComputerInDomain_Config.ps1 | 10 +- ...puter_RenameComputerInWorkgroup_Config.ps1 | 10 +- ...er_UnjoinDomainAndJoinWorkgroup_Config.ps1 | 10 +- ...tComputerDescriptionInWorkgroup_Config.ps1 | 10 +- ...Computer_JoinDomainSpecifyingDC_Config.ps1 | 10 +- ...mainJoin_JoinDomainUsingODJBlob_Config.ps1 | 10 +- ...ingReboot_RebootAfterDomainJoin_Config.ps1 | 10 +- ...2-PendingReboot_ConfigMgrReboot_Config.ps1 | 10 +- .../1-PowerPlan_SetPowerPlan_Config.ps1 | 10 +- ...rShellExecutionPolicy_SetPolicy_Config.ps1 | 10 +- ...licy_SetPolicyForMultipleScopes_Config.ps1 | 10 +- ...min_SetSecureRemoteDesktopAdmin_Config.ps1 | 10 +- ...ledTask_CreateScheduledTaskOnce_Config.ps1 | 10 +- ...llTaskOnceAsUserInteractiveOnly_Config.ps1 | 10 +- ...heduledTask_DisableABuiltInTask_Config.ps1 | 10 +- ...cheduledTask_DeleteABuiltInTask_Config.ps1 | 10 +- ...ask_CreateScheduledTasksOnEvent_Config.ps1 | 10 +- ...nceAsGroupManagedServiceAccount_Config.ps1 | 10 +- ...ynchronizeAcrossTimeZoneEnabled_Config.ps1 | 10 +- ...ledTasksAsBuiltInServiceAccount_Config.ps1 | 10 +- ...edTask_CreateScheduledTaskDaily_Config.ps1 | 10 +- ...ScheduledTasksDailyIndefinitely_Config.ps1 | 10 +- ...Task_CreateScheduledTasksWeekly_Config.ps1 | 10 +- ...ask_CreateScheduledTasksAtLogon_Config.ps1 | 10 +- ...k_CreateScheduledTasksAtStartup_Config.ps1 | 10 +- ...RunPowerShellTaskEvery15Minutes_Config.ps1 | 10 +- ...lTaskEvery15MinutesIndefinitely_Config.ps1 | 10 +- ...OnceAsUserWithHighestPriveleges_Config.ps1 | 10 +- ...rverConfiguration_AllProperties_Config.ps1 | 10 +- ...ServerConfiguration_DisableSmb1_Config.ps1 | 10 +- .../1-SmbShare_CreateShare_Config.ps1 | 10 +- ...bShare_CreateShareAllProperties_Config.ps1 | 10 +- .../3-SmbShare_RemoveShare_Config.ps1 | 10 +- .../4-SmbShare_RecreateShare_Config.ps1 | 10 +- .../1-SystemLocale_SetSystemLocale_Config.ps1 | 10 +- .../1-TimeZone_SetTimeZone_Config.ps1 | 10 +- ...-VirtualMemory_SetVirtualMemory_Config.ps1 | 10 +- ...Capability_AddWindowsCapability_Config.ps1 | 10 +- ...ability_RemoveWindowsCapability_Config.ps1 | 10 +- ...apabilitywithLogLevelandLogPath_Config.ps1 | 10 +- ...Eventlog_SetWindowsEventlogSize_Config.ps1 | 10 +- ...ntlog_SetWindowsEventlogLogMode_Config.ps1 | 10 +- ...sEventlog_EnableWindowsEventLog_Config.ps1 | 10 +- ...ntlog_SetWindowsEventlogLogMode_Config.ps1 | 10 +- ...ndowsEventlogSecurityDescriptor_Config.ps1 | 10 +- ...Eventlog_DisableWindowsEventlog_Config.ps1 | 10 +- .../ComputerManagementDsc.Common.psm1 | 0 .../SetTimeZone.cs | 0 .../ComputerManagementDsc.Common.strings.psd1 | 0 .../about_ComputerManagementDsc.help.txt | 34 ++ 135 files changed, 1972 insertions(+), 843 deletions(-) delete mode 100644 .MetaTestOptIn.json delete mode 100644 .codecov.yml delete mode 100644 ComputerManagementDsc.psd1 create mode 100644 GitVersion.yml create mode 100644 HISTORIC_CHANGELOG.md create mode 100644 RequiredModules.psd1 create mode 100644 Resolve-Dependency.ps1 create mode 100644 Resolve-Dependency.psd1 delete mode 100644 appveyor.yml create mode 100644 azure-pipelines.yml create mode 100644 build.ps1 create mode 100644 build.yaml create mode 100644 source/Build.psd1 create mode 100644 source/ComputerManagementDsc.psd1 rename {DSCResources => source/DSCResources}/MSFT_Computer/MSFT_Computer.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_Computer/MSFT_Computer.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_Computer/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_OfflineDomainJoin/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_PendingReboot/MSFT_PendingReboot.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_PendingReboot/MSFT_PendingReboot.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_PendingReboot/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_PendingReboot/en-US/MSFT_PendingReboot.data.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_PendingReboot/en-US/MSFT_PendingReboot.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_PowerPlan/MSFT_PowerPlan.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_PowerPlan/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl (100%) rename {DSCResources => source/DSCResources}/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_PowerShellExecutionPolicy/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_RemoteDesktopAdmin/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_RemoteDesktopAdmin/en-US/MSFT_RemoteDesktopAdmin.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 (99%) rename {DSCResources => source/DSCResources}/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_ScheduledTask/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.data.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbServerConfiguration/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.schema.mfl (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbShare/MSFT_SmbShare.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbShare/MSFT_SmbShare.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbShare/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbShare/en-US/MSFT_SmbShare.schema.mfl (100%) rename {DSCResources => source/DSCResources}/MSFT_SmbShare/en-US/MSFT_SmbShare.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SystemLocale/MSFT_SystemLocale.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_SystemLocale/MSFT_SystemLocale.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_SystemLocale/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_SystemLocale/en-US/MSFT_SystemLocale.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_TimeZone/MSFT_TimeZone.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_TimeZone/MSFT_TimeZone.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_TimeZone/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_TimeZone/en-US/MSFT_TimeZone.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_VirtualMemory/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_WindowsCapability/MSFT_WindowsCapability.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_WindowsCapability/MSFT_WindowsCapability.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_WindowsCapability/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_WindowsCapability/en-US/MSFT_WindowsCapability.strings.psd1 (100%) rename {DSCResources => source/DSCResources}/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 (100%) rename {DSCResources => source/DSCResources}/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof (100%) rename {DSCResources => source/DSCResources}/MSFT_WindowsEventLog/README.md (100%) rename {DSCResources => source/DSCResources}/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 (100%) rename {Examples => source/Examples}/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 (73%) rename {Examples => source/Examples}/Resources/Computer/2-Computer_JoinDomain_Config.ps1 (78%) rename {Examples => source/Examples}/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 (78%) rename {Examples => source/Examples}/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 (70%) rename {Examples => source/Examples}/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 (78%) rename {Examples => source/Examples}/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 (71%) rename {Examples => source/Examples}/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 (79%) rename {Examples => source/Examples}/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 (72%) rename {Examples => source/Examples}/Resources/PendingReboot/1-PendingReboot_RebootAfterDomainJoin_Config.ps1 (80%) rename {Examples => source/Examples}/Resources/PendingReboot/2-PendingReboot_ConfigMgrReboot_Config.ps1 (81%) rename {Examples => source/Examples}/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 (71%) rename {Examples => source/Examples}/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 (75%) rename {Examples => source/Examples}/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 (80%) rename {Examples => source/Examples}/Resources/RemoteDesktopAdmin/1-RemoteDesktopAdmin_SetSecureRemoteDesktopAdmin_Config.ps1 (75%) rename {Examples => source/Examples}/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 (85%) rename {Examples => source/Examples}/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 (84%) rename {Examples => source/Examples}/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 (74%) rename {Examples => source/Examples}/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 (74%) rename {Examples => source/Examples}/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 (85%) rename {Examples => source/Examples}/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 (84%) rename {Examples => source/Examples}/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 (83%) rename {Examples => source/Examples}/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 (84%) rename {Examples => source/Examples}/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 (85%) rename {Examples => source/Examples}/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 (81%) rename {Examples => source/Examples}/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 (84%) rename {Examples => source/Examples}/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 (80%) rename {Examples => source/Examples}/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 (80%) rename {Examples => source/Examples}/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 (80%) rename {Examples => source/Examples}/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 (80%) rename {Examples => source/Examples}/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 (84%) rename {Examples => source/Examples}/Resources/SmbServerConfiguration/1-SmbServerConfiguration_AllProperties_Config.ps1 (91%) rename {Examples => source/Examples}/Resources/SmbServerConfiguration/1-SmbServerConfiguration_DisableSmb1_Config.ps1 (73%) rename {Examples => source/Examples}/Resources/SmbShare/1-SmbShare_CreateShare_Config.ps1 (74%) rename {Examples => source/Examples}/Resources/SmbShare/2-SmbShare_CreateShareAllProperties_Config.ps1 (82%) rename {Examples => source/Examples}/Resources/SmbShare/3-SmbShare_RemoveShare_Config.ps1 (73%) rename {Examples => source/Examples}/Resources/SmbShare/4-SmbShare_RecreateShare_Config.ps1 (78%) rename {Examples => source/Examples}/Resources/SystemLocale/1-SystemLocale_SetSystemLocale_Config.ps1 (75%) rename {Examples => source/Examples}/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 (71%) rename {Examples => source/Examples}/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 (73%) rename {Examples => source/Examples}/Resources/WindowsCapability/1-WindowsCapability_AddWindowsCapability_Config.ps1 (71%) rename {Examples => source/Examples}/Resources/WindowsCapability/2-WindowsCapability_RemoveWindowsCapability_Config.ps1 (71%) rename {Examples => source/Examples}/Resources/WindowsCapability/3-WindowsCapability_AddWindowsCapabilitywithLogLevelandLogPath_Config.ps1 (76%) rename {Examples => source/Examples}/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 (77%) rename {Examples => source/Examples}/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 (79%) rename {Examples => source/Examples}/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 (79%) rename {Examples => source/Examples}/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 (77%) rename {Examples => source/Examples}/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 (80%) rename {Examples => source/Examples}/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 (74%) rename {Modules => source/Modules}/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 (100%) rename {Modules => source/Modules}/ComputerManagementDsc.Common/SetTimeZone.cs (100%) rename {Modules => source/Modules}/ComputerManagementDsc.Common/en-US/ComputerManagementDsc.Common.strings.psd1 (100%) create mode 100644 source/en-US/about_ComputerManagementDsc.help.txt diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json deleted file mode 100644 index da83b370..00000000 --- a/.MetaTestOptIn.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "Common Tests - Validate Markdown Files", - "Common Tests - Validate Example Files", - "Common Tests - Validate Module Files", - "Common Tests - Validate Script Files", - "Common Tests - Required Script Analyzer Rules", - "Common Tests - Flagged Script Analyzer Rules", - "Common Tests - New Error-Level Script Analyzer Rules", - "Common Tests - Custom Script Analyzer Rules", - "Common Tests - Validate Example Files To Be Published", - "Common Tests - Validate Markdown Links", - "Common Tests - Relative Path Length", - "Common Tests - Validate Localization" -] diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 411198f0..00000000 --- a/.codecov.yml +++ /dev/null @@ -1,26 +0,0 @@ -codecov: - notify: - require_ci_to_pass: no - # dev should be the baseline for reporting - branch: dev - -comment: - layout: "reach, diff" - behavior: default - -coverage: - range: 50..80 - round: down - precision: 0 - - status: - project: - default: - # Set the overall project code coverage requirement to 70% - target: 70 - patch: - default: - # Set the pull request requirement to not regress overall coverage by more than 5% - # and let codecov.io set the goal for the code changed in the patch. - target: auto - threshold: 5 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 925594ed..8f9fed13 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -36,7 +36,7 @@ --> - [ ] Added an entry under the Unreleased section of the change log in the CHANGELOG.md. Entry should say what was changed, and how that affects users (if applicable). -- [ ] Resource documentation added/updated in README.md in the resource folder. +- [ ] Resource documentation added/updated in README.md in resource folder. - [ ] Resource parameter descriptions added/updated in schema.mof and comment-based help. - [ ] Comment-based help added/updated. diff --git a/.gitignore b/.gitignore index 5066fd17..ecfe6a7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,9 @@ -DSCResource.Tests +*.suo +*.user +*.coverage +.vs +.psproj +.sln +markdownissues.txt +TestResults.xml +output/ diff --git a/.vscode/settings.json b/.vscode/settings.json index 43f01cf9..52e2e057 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,6 +8,7 @@ "powershell.codeFormatting.whitespaceAroundOperator": true, "powershell.codeFormatting.whitespaceAfterSeparator": true, "powershell.codeFormatting.ignoreOneLineBlock": false, + "powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationAfterEveryPipeline", "powershell.codeFormatting.preset": "Custom", "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ceafd2..5b8339b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,400 +1,38 @@ -# Versions +# Change log for NetworkingDSc -## Unreleased +The format is based on and uses the types of changes according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- None + +### Changed - SmbShare: - Add parameter ScopeName to support creating shares in a different - scope. Fixes [Issue #284](https://github.com/PowerShell/ComputerManagementDsc/issues/284) + scope. Fixes [Issue #284](https://github.com/dsccommunity/ComputerManagementDsc/issues/284) - Added `.gitattributes` to ensure CRLF is used when pulling repository - Fixes - [Issue #290](https://github.com/PowerShell/ComputerManagementDsc/issues/290). + [Issue #290](https://github.com/dsccommunity/ComputerManagementDsc/issues/290). - SystemLocale: - Migrated SystemLocale from [SystemLocaleDsc](https://github.com/PowerShell/SystemLocaleDsc). - RemoteDesktopAdmin: - Correct Context messages in integration tests by adding 'When'. -## 7.1.0.0 - -- ComputerManagementDsc: - - Update psd1 description - Fixes [Issue #269](https://github.com/PowerShell/ComputerManagementDsc/issues/269). -- Fix minor style issues with missing spaces between `param` statements and '('. -- SmbServerConfiguration: - - New resource for configuring the SMB Server settings. - - Added examples for SMB Server Configuration. -- Minor corrections to CHANGELOG.MD. -- ScheduledTask: - - Fixed bug when description has any form of whitespace at beginning or - end the resource would not go into state - Fixes [Issue #258](https://github.com/PowerShell/ComputerManagementDsc/issues/258). -- SmbShare: - - Fixed bug where the resource would not update the path of a share if the - share exists on a different path. Adds a parameter Force to the SmbShare - resource to allow updating of the path - Fixes [Issue #215](https://github.com/PowerShell/ComputerManagementDsc/issues/215) - - Removal of duplicate code in Add-SmbShareAccessPermission helper function - fixes [Issue #226](https://github.com/PowerShell/ComputerManagementDsc/issues/226). - -## 7.0.0.0 - -- ScheduledTask: - - Better compatibility with Group LogonType - when passing BuiltIn groups through ExecuteAsCredential - - Primary use case is 'BUILTIN\Users' - - Use the ExecuteAsCredential property to pass the username - The PSCredential needs a non-null that is ignored - - Delay property not handled properly on AtLogon and AtStartup trigger - Fixes - [Issue #230](https://github.com/PowerShell/ComputerManagementDsc/issues/230). - - Changed `Get-ScheduledTask` calls to `ScheduledTasks\Get-ScheduledTask` to - avoid name clash with `Carbon` module. Fixes [Issue #248](https://github.com/PowerShell/ComputerManagementDsc/issues/248). - - Cast `MultipleInstances` value returned by `Get-TargetResource` to `string` - - fixes [Issue #255](https://github.com/PowerShell/ComputerManagementDsc/issues/255). -- PendingReboot: - - Migrated xPendingReboot from [xPendingReboot](https://github.com/PowerShell/xPendingReboot) - and renamed to PendingReboot. - - Converted to meet HQRM guidelines - Fixes [Issue #12](https://github.com/PowerShell/xPendingReboot/issues/12). - - Changed `SkipCcmClientSDK` parameter to default to `$true` - Fixes [Issue #13](https://github.com/PowerShell/xPendingReboot/issues/13). - - Fixed `Test-TargetResource` so that if ConfigMgr requires a reboot then - the pending reboot will be set - Fixes [Issue #26](https://github.com/PowerShell/xPendingReboot/issues/26). - - Refactored `Test-TargetResource` to reduce code duplication and move to a - data driven design. - - Refactored `Get-TargetResource` by adding a new function `Get-PendingRebootState` - so that `Test-TargetResource` no longer needed to use `Get-TargetResource`. This - eliminated the need to include write parameters in `Get-TargetResource`. - - Converted the call to `Invoke-WmiMethod` to `Invoke-CimMethod`. - - Deleted the code that removes the `regRebootLocations` variable at the end of - the resource as it appears to serve no purpose. -- Correct all tests to meet Pester 4.0 standards. -- RemoteDesktopAdmin: - - New resource for configuring Remote Desktop for Administration - fixes - [Issue #224](https://github.com/PowerShell/ComputerManagementDsc/issues/224). -- Updated common function `Test-DscParameterState` to support ordered comparison - of arrays by copying function and tests from `NetworkingDsc` - fixes [Issue #250](https://github.com/PowerShell/ComputerManagementDsc/issues/250). -- BREAKING CHANGE: ScheduledTask: - - Correct output type of `DaysInterval`,`StartTime`,`WeeksDaysOfWeek`, - and `WeeksInterval` parameters from `Get-TargetResource` to match MOF. - - Refactored `Get-TargetResource` to remove parameters that - are not key or required - fixes [Issue #249](https://github.com/PowerShell/ComputerManagementDsc/issues/249). - - Added function `Test-DateStringContainsTimeZone` to determine if a string - containing a date time includes a time zone. - - Enable verbose preference to be passed through to `Test-DscParameterState`. - - Changed `Test-TargetResource` so that `StartTime` is only compared for - trigger types `Daily`,`Weekly` or `Once`. -- Fix minor style issues in statement case. - -## 6.5.0.0 - -- Computer: - - Fix for 'directory service is busy' error when joining a domain and renaming - a computer when JoinOU is specified - Fixes [Issue #221](https://github.com/PowerShell/ComputerManagementDsc/issues/221). -- Added new resource SmbShare - - Moved and improved from deprecated module xSmbShare. -- Changes to ComputerManagementDsc.Common - - Updated Test-DscParameterState so it now can compare zero item - collections (arrays). -- Changes to WindowsEventLog - - Minor style guideline cleanup. -- Opt-in to common test to validate localization. Fixed localization strings - in resources - Fixes [Issue #217](https://github.com/PowerShell/ComputerManagementDsc/issues/217). -- PowerShellExecutionPolicy: - - Removed `SupportsShouldProcess` as it cannot be used with DSC - Fixes - [Issue #219](https://github.com/PowerShell/ComputerManagementDsc/issues/219). -- Combined all ComputerManagementDsc.ResourceHelper module functions into - ComputerManagementDsc.Common module - Fixes [Issue #218](https://github.com/PowerShell/ComputerManagementDsc/issues/218). - - Minor code cleanup against style guideline. - - Remove code from `New-InvalidOperationException` because it was a - code path that could never could be used due to the parameter - validation preventing the helper function being called that way. - - Updated all `Get-LocalizationData` to latest version from - [DSCResource.Template](https://github.com/PowerShell/DSCResource.Template). - - Fixed an issue with the helper function `Test-IsNanoServer` that - prevented it to work. Though the helper function is not used, so this - issue was not caught until now when unit tests was added. - - Improved code coverage. - -## 6.4.0.0 - -- ScheduledTask: - - IdleWaitTimeout returned from Get-TargetResource always null - Fixes [Issue #186](https://github.com/PowerShell/ComputerManagementDsc/issues/186). - - Added BuiltInAccount Property to allow running task as one of the build in - service accounts - Fixes [Issue #130](https://github.com/PowerShell/ComputerManagementDsc/issues/130). -- Refactored module folder structure to move resource to root folder of - repository and remove test harness - fixes [Issue #188](https://github.com/PowerShell/ComputerManagementDsc/issues/188). -- Added a CODE\_OF\_CONDUCT.md with the same content as in the README.md and - linked to it from README.MD instead. -- Updated test header for all unit tests to version 1.2.4. -- Updated test header for all integration to version 1.3.3. -- Enabled example publish to PowerShell Gallery by adding `gallery_api` - environment variable to `AppVeyor.yml`. - -## 6.3.0.0 - -- Correct PSSA custom rule violations - fixes [Issue #209](https://github.com/PowerShell/ComputerManagementDsc/issues/209). -- Correct long example filenames for PowerShellExecutionPolicy examples. -- Opted into Common Tests 'Required Script Analyzer Rules', - 'Flagged Script Analyzer Rules', 'New Error-Level Script Analyzer Rules' - 'Custom Script Analyzer Rules' and 'Relative Path Length' - - fixes [Issue #152](https://github.com/PowerShell/ComputerManagementDsc/issues/152). -- PowerPlan: - - Added support to specify the desired power plan either as name or guid. - Fixes [Issue #59](https://github.com/PowerShell/ComputerManagementDsc/issues/59) - - Changed the resource so it uses Windows APIs instead of WMI/CIM - (Workaround for Server 2012R2 Core, Nano Server, Server 2019 and Windows 10). - Fixes [Issue #155](https://github.com/PowerShell/ComputerManagementDsc/issues/155) - and [Issue #65](https://github.com/PowerShell/ComputerManagementDsc/issues/65) - -## 6.2.0.0 - -- WindowsEventLog: - - Migrated the xWinEventLog from [xWinEventLog](https://github.com/PowerShell/xWinEventLog) - and renamed to WindowsEventLog. - - Moved strings in localization file. - - LogMode is now set with Limit-EventLog, - - Fixes [Issue #18](https://github.com/PowerShell/ComputerManagementDsc/issues/18). -- Updated examples to format required for publishing to PowerShell Gallery - fixes - [Issue #206](https://github.com/PowerShell/ComputerManagementDsc/issues/206). -- Opted into Common Tests 'Validate Example Files To Be Published' and - 'Validate Markdown Links'. - -## 6.1.0.0 - -- Updated LICENSE file to match the Microsoft Open Source Team standard. - Fixes [Issue #197](https://github.com/PowerShell/ComputerManagementDsc/issues/197). -- Explicitly removed extra hidden files from release package - -## 6.0.0.0 - -- ScheduledTask: - - Added support for Group Managed Service Accounts, implemented using the ExecuteAsGMSA - parameter. Fixes [Issue #111](https://github.com/PowerShell/ComputerManagementDsc/issues/111) - - Added support to set the Synchronize Across Time Zone option. Fixes [Issue #109](https://github.com/PowerShell/ComputerManagementDsc/issues/109) -- Added .VSCode settings for applying DSC PSSA rules - fixes [Issue #189](https://github.com/PowerShell/ComputerManagementDsc/issues/189). -- BREAKING CHANGE: PowerPlan: - - Added IsActive Read-Only Property - Fixes [Issue #171](https://github.com/PowerShell/ComputerManagementDsc/issues/171). - - InActive power plans are no longer returned with their Name set to null. - Now, the name is always returned and the Read-Only property of IsActive - is set accordingly. - -## 5.2.0.0 - -- PowershellExecutionPolicy: - - Updated to meet HQRM guidelines. - - Migrated the xPowershellExecutionPolicy from [xPowershellExecutionPolicy](https://github.com/PowerShell/xPowerShellExecutionPolicy) - and renamed to PowershellExecutionPolicy. - - Moved strings to localization file. -- Changed the scope from Global to Script in MSFT_ScheduledTask.Integration.Tests.ps1 -- Changed the scope from Global to Script ComputerManagementDsc.Common.Tests.ps1 -- ScheduledTask: - - Added support for event based triggers, implemented using the ScheduleType OnEvent - fixes [Issue #167](https://github.com/PowerShell/ComputerManagementDsc/issues/167) - -## 5.1.0.0 - -- TimeZone: - - Migrated xTimeZone resource from [xTimeZone](https://github.com/PowerShell/xTimeZone) - and renamed to TimeZone - fixes [Issue #157](https://github.com/PowerShell/ComputerManagementDsc/issues/157). -- Moved Test-Command from ComputerManagementDsc.ResourceHelper to - ComputerManagementDsc.Common module to match what TimeZone requires. - It was not exported in ComputerManagementDsc.ResourceHelper and not - used. -- Add `server` parameter to `Computer` resource - fixes [Issue #161](https://github.com/PowerShell/ComputerManagementDsc/issues/161) - -## 5.0.0.0 - -- BREAKING CHANGE: - - Renamed ComputerManagement to ComputerManagementDsc - fixes [Issue #119](https://github.com/PowerShell/ComputerManagementDsc/issues/119). - - Changed all MSFT\_xResourceName to MSFT\_ResourceName. - - Updated DSCResources, Examples, Modules and Tests with new naming. - - Updated Year to 2018 in License and Manifest. - - Updated README.md from xComputerManagement to ComputerManagementDsc. -- OfflineDomainJoin: - - Cleaned up spacing in strings file to make consistent with other - resources. -- VirtualMemory: - - Converted strings to single quotes in integration test. - -## 4.1.0.0 - -- xScheduledTask: - - Update existing Scheduled Task using SetScheduleTask - instead of UnRegister/Register - See [Issue #134](https://github.com/PowerShell/xComputerManagement/issues/134). -- Fix master branch AppVeyor badge link URL in README.MD - See [Issue #140](https://github.com/PowerShell/xComputerManagement/issues/140). -- Fix deletion of scheduled task with unknown or empty task trigger. - Get-TargetResource returns an empty ScheduleType string if the task - trigger is empty or unknown - See [Issue - #137](https://github.com/PowerShell/xComputerManagement/issues/137). -- Added dependency information for xScheduledTask to README.MD. - -## 4.0.0.0 - -- BREAKING CHANGE: xScheduledTask: - - Breaking change because `Get-TargetResource` no longer outputs - `ActionExecutable` and `ScheduleType` properties when the scheduled - task does not exist. It will also include `TaskPath` in output when - scheduled task does not exist. -- xScheduledTask: - - Add support to disable built-in scheduled tasks - See [Issue #74](https://github.com/PowerShell/xComputerManagement/issues/74). - - Fix unit test mocked schedule task object structure. - - Fix error message when trigger type is unknown - See [Issue #121](https://github.com/PowerShell/xComputerManagement/issues/121). - - Moved strings into separate strings file. - - Updated to meet HQRM guidelines. -- xComputer: - - Resolved bug in Get-ComputerDomain where LocalSystem doesn't have - rights to the domain. -- Updated tests to meet Pester V4 guidelines - See [Issue #106](https://github.com/PowerShell/xComputerManagement/issues/106). -- Converted module to use auto documentation format. - -## 3.2.0.0 - -- xScheduledTask: - - Enable Execution Time Limit of task to be set to indefinite - by setting `ExecutionTimeLimit` to '00:00:00' - See [Issue #115](https://github.com/PowerShell/xComputerManagement/issues/115). -- xPowerPlan: - - Updated to meet HQRM guidelines. - - Converted calls to `throw` to use `New-InvalidOperationException` - in CommonResourceHelper. -- Move Common Resource Helper functions into modules folder. -- Changed resources to use Common Resource Helper functions. -- Moved strings for Common Resource Helper functions into separate - strings file. -- Added unit tests for Common Helper functions. - -## 3.1.0.0 - -- xOfflineDomainJoin: - - Updated to meet HQRM guidelines. -- xScheduledTask: - - Applied autoformatting to examples to improve readability. - - Added LogonType and RunLevel parameters for controlling - task execution. - - Correct `Assert-VerifiableMocks` to `Assert-VerifiableMock` - -## 3.0.0.0 - -- xComputer: Added parameter to set the local computer description along with documentation - and unit tests for this change. -- BREAKING CHANGE: xScheduledTask: - - Converted all Interval/Duration type parameters over to be string format - to prevent the Timezone the MOF file was created in from being stored. - This is to fix problems where MOF files are created in one timezone but - deployed nodes to a different timezone - See [Issue #85](https://github.com/PowerShell/xComputerManagement/issues/85) - - Added ConvertTo-TimeSpanFromScheduledTaskString function and refactored - to reduce code duplication. - - Added support for setting repetition duration to `Indefinitely`. -- xComputer: - - Moved strings to localization file. - - Updated to meet HQRM guidelines. -- xVirtualMemory: - - Refactored shared common code into new utility functions to - reduce code duplication and improve testability. - - Moved strings into localizable strings file. - - Converted calls to `throw` to use `New-InvalidOperationException` - in CommonResourceHelper. - - Improved unit test coverage. - - Updated to meet HQRM guidelines. - -## 2.1.0.0 - -- xComputer: Changed comparison that validates if we are in the correct AD - Domain to work correctly if FQDN wasn't used. -- Updated AppVeyor.yml to use AppVeyor.psm1 module in DSCResource.Tests. -- Removed Markdown.md errors. -- Added CodeCov.io support. -- xScheduledTask - - Fixed incorrect TaskPath handling - [Issue #45](https://github.com/PowerShell/xComputerManagement/issues/45) -- Change examples to meet HQRM standards and optin to Example validation - tests. -- Replaced examples in README.MD to links to Example files. -- Added the VS Code PowerShell extension formatting settings that cause PowerShell - files to be formatted as per the DSC Resource kit style guidelines - [Issue #91](https://github.com/PowerShell/xComputerManagement/issues/91). -- Opted into Common Tests 'Validate Module Files' and 'Validate Script Files'. -- Converted files with UTF8 with BOM over to UTF8 - fixes [Issue #90](https://github.com/PowerShell/xComputerManagement/issues/90). -- Updated Year to 2017 in License and Manifest - fixes [Issue #87](https://github.com/PowerShell/xComputerManagement/issues/87). -- Added .github support files - fixes [Issue #88](https://github.com/PowerShell/xComputerManagement/issues/88): - - CONTRIBUTING.md - - ISSUE_TEMPLATE.md - - PULL_REQUEST_TEMPLATE.md -- Resolved all PSScriptAnalyzer warnings and style guide warnings. -- xOfflineDomainJoin: - - Changed to use CommonResourceHelper to load localization strings. - - Renamed en-US to be correct case so that localization strings can be loaded. - - Suppress PSScriptAnalyzer rule PSAvoidGlobalVars for - `$global:DSCMachineStatus = 1`. -- xComputer: - - Suppress PSScriptAnalyzer rule PSAvoidGlobalVars for - `$global:DSCMachineStatus = 1`. -- xVirtualMemory: - - Suppress PSScriptAnalyzer rule PSAvoidGlobalVars for - `$global:DSCMachineStatus = 1`. - -## 2.0.0.0 - -- Updated resources - - BREAKING CHANGE: xScheduledTask: Added nearly all available parameters for tasks -- xVirtualMemory: - - Fixed failing tests. - -## 1.10.0.0 - -- Added resources: - - xVirtualMemory - -## 1.9.0.0 - -- Added resources - - xPowerPlan - -## 1.8.0.0 - -- Converted AppVeyor.yml to pull Pester from PSGallery instead of - Chocolatey. -- Changed AppVeyor.yml to use default image -- xScheduledTask: Fixed bug with different OS versions returning repeat interval - differently - -## 1.7.0.0 - -- Added support for enabling or disabling scheduled tasks -- The Name parameter resolves to $env:COMPUTERNAME when the value is localhost - -## 1.6.0.0 - -- Added the following resources: - - MSFT_xOfflineDomainJoin resource to join computers to an AD Domain using an - Offline Domain Join request file. - - MSFT_xScheduledTask resource to control scheduled tasks on the local server -- MSFT_xOfflineDomainJoin: Corrected localizedData.DomainAlreadyJoinedhMessage name. -- xComputer: Changed credential generation code in tests to avoid triggering - PSSA rule PSAvoidUsingConvertToSecureStringWithPlainText. - Renamed unit test file to match the name of Resource file. - -## 1.5.0.0 - -- Update Unit tests to use the standard folder structure and test templates. -- Added .gitignore to prevent commit of DSCResource.Tests. - -## 1.4.0.0 - -- Added validation to the Name parameter -- Added the JoinOU parameter which allows you to specify the organizational unit - that the computer account will be created in -- Added the CurrentOU read-only property that shows the organizational unit that - the computer account is currently in - -## 1.3.0 +### Deprecated -- xComputer - - Fixed issue with Test-TargetResource when not specifying Domain or - Workgroup name - - Added tests +- None -## 1.2.2 +### Removed -- Added types to Get/Set/Test definitions to allow xResourceDesigner validation - to succeed +- None -## 1.2 +### Fixed -- Added functionality to enable moving computer from one domain to another -- Modified Test-DscConfiguration logics when testing domain join +- None -## 1.0.0.0 +### Security -- Initial release with the following resources: - - xComputer +- None diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 1d5c9eab..d7589ddb 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,6 +1,3 @@ -# Code of conduct +# Code of Conduct -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional -questions or comments. +This project has adopted the [DSC Community Code of Conduct](https://dsccommunity.org/code_of_conduct). diff --git a/ComputerManagementDsc.psd1 b/ComputerManagementDsc.psd1 deleted file mode 100644 index 842c8c27..00000000 --- a/ComputerManagementDsc.psd1 +++ /dev/null @@ -1,82 +0,0 @@ -@{ -# Version number of this module. -moduleVersion = '7.1.0.0' - -# ID used to uniquely identify this module -GUID = 'B5004952-489E-43EA-999C-F16A25355B89' - -# Author of this module -Author = 'Microsoft Corporation' - -# Company or vendor of this module -CompanyName = 'Microsoft Corporation' - -# Copyright statement for this module -Copyright = '(c) Microsoft Corporation. All rights reserved.' - -# Description of the functionality provided by this module -Description = 'The ComputerManagementDsc module contains DSC resources for configuration of a Windows computer. These DSC resources allow you to perform computer management tasks, such as renaming the computer, joining a domain and scheduling tasks as well as configuring items such as virtual memory, event logs, time zones and power settings. - -All of the resources in the DSC Resource Kit are provided AS IS, and are not supported through any Microsoft standard support program or service.' - -# Minimum version of the Windows PowerShell engine required by this module -PowerShellVersion = '4.0' - -# Minimum version of the common language runtime (CLR) required by this module -CLRVersion = '4.0' - -# Functions to export from this module -FunctionsToExport = '*' - -# Cmdlets to export from this module -CmdletsToExport = '*' - -# 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 = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource') - - # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/PowerShell/ComputerManagementDsc' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - ReleaseNotes = '- ComputerManagementDsc: - - Update psd1 description - Fixes [Issue 269](https://github.com/PowerShell/ComputerManagementDsc/issues/269). -- Fix minor style issues with missing spaces between `param` statements and "(". -- SmbServerConfiguration: - - New resource for configuring the SMB Server settings. - - Added examples for SMB Server Configuration. -- Minor corrections to CHANGELOG.MD. -- ScheduledTask: - - Fixed bug when description has any form of whitespace at beginning or - end the resource would not go into state - Fixes [Issue 258](https://github.com/PowerShell/ComputerManagementDsc/issues/258). -- SmbShare: - - Removal of duplicate code in Add-SmbShareAccessPermission helper function - fixes [Issue 226](https://github.com/PowerShell/ComputerManagementDsc/issues/226). - -' - - } # End of PSData hashtable - -} # End of PrivateData hashtable -} - - - - - - - - - - - diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 00000000..ae02882c --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,26 @@ +mode: ContinuousDelivery +next-version: 7.4.0 +major-version-bump-message: '\s?(breaking|major|breaking\schange)' +minor-version-bump-message: '\s?(add|feature|minor)' +patch-version-bump-message: '\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +assembly-informational-format: '{NuGetVersionV2}+Sha.{Sha}.Date.{CommitDate}' +branches: + master: + tag: preview + pull-request: + tag: PR + feature: + tag: useBranchName + increment: Minor + regex: f(eature(s)?)?[\/-] + source-branches: ['master'] + hotfix: + tag: fix + increment: Patch + regex: (hot)?fix(es)?[\/-] + source-branches: ['master'] + +ignore: + sha: [] +merge-message-formats: {} diff --git a/HISTORIC_CHANGELOG.md b/HISTORIC_CHANGELOG.md new file mode 100644 index 00000000..a32e349b --- /dev/null +++ b/HISTORIC_CHANGELOG.md @@ -0,0 +1,451 @@ +# Historic change log for ComputerManagementDsc + +The release notes in the PowerShell Module manifest cannot exceed 10000 +characters. Due to a bug in the CI deploy pipeline this is not handled. +This file is to temporary move the older change log history to keep the +change log short. + +## [7.1.0.0] + +### Changed + +- ComputerManagementDsc: + - Update psd1 description - Fixes [Issue #269](https://github.com/dsccommunity/ComputerManagementDsc/issues/269). +- Fix minor style issues with missing spaces between `param` statements and '('. +- SmbServerConfiguration: + - New resource for configuring the SMB Server settings. + - Added examples for SMB Server Configuration. +- Minor corrections to CHANGELOG.MD. +- ScheduledTask: + - Fixed bug when description has any form of whitespace at beginning or + end the resource would not go into state - Fixes [Issue #258](https://github.com/dsccommunity/ComputerManagementDsc/issues/258). +- SmbShare: + - Fixed bug where the resource would not update the path of a share if the + share exists on a different path. Adds a parameter Force to the SmbShare + resource to allow updating of the path - Fixes [Issue #215](https://github.com/dsccommunity/ComputerManagementDsc/issues/215) + - Removal of duplicate code in Add-SmbShareAccessPermission helper function + fixes [Issue #226](https://github.com/dsccommunity/ComputerManagementDsc/issues/226). + +## [7.0.0.0] + +### Changed + +- ScheduledTask: + - Better compatibility with Group LogonType + when passing BuiltIn groups through ExecuteAsCredential + - Primary use case is 'BUILTIN\Users' + - Use the ExecuteAsCredential property to pass the username + The PSCredential needs a non-null that is ignored + - Delay property not handled properly on AtLogon and AtStartup trigger - Fixes + [Issue #230](https://github.com/dsccommunity/ComputerManagementDsc/issues/230). + - Changed `Get-ScheduledTask` calls to `ScheduledTasks\Get-ScheduledTask` to + avoid name clash with `Carbon` module. Fixes [Issue #248](https://github.com/dsccommunity/ComputerManagementDsc/issues/248). + - Cast `MultipleInstances` value returned by `Get-TargetResource` to `string` - + fixes [Issue #255](https://github.com/dsccommunity/ComputerManagementDsc/issues/255). +- PendingReboot: + - Migrated xPendingReboot from [xPendingReboot](https://github.com/PowerShell/xPendingReboot) + and renamed to PendingReboot. + - Converted to meet HQRM guidelines - Fixes [Issue #12](https://github.com/PowerShell/xPendingReboot/issues/12). + - Changed `SkipCcmClientSDK` parameter to default to `$true` - Fixes [Issue #13](https://github.com/PowerShell/xPendingReboot/issues/13). + - Fixed `Test-TargetResource` so that if ConfigMgr requires a reboot then + the pending reboot will be set - Fixes [Issue #26](https://github.com/PowerShell/xPendingReboot/issues/26). + - Refactored `Test-TargetResource` to reduce code duplication and move to a + data driven design. + - Refactored `Get-TargetResource` by adding a new function `Get-PendingRebootState` + so that `Test-TargetResource` no longer needed to use `Get-TargetResource`. This + eliminated the need to include write parameters in `Get-TargetResource`. + - Converted the call to `Invoke-WmiMethod` to `Invoke-CimMethod`. + - Deleted the code that removes the `regRebootLocations` variable at the end of + the resource as it appears to serve no purpose. +- Correct all tests to meet Pester 4.0 standards. +- RemoteDesktopAdmin: + - New resource for configuring Remote Desktop for Administration - fixes + [Issue #224](https://github.com/dsccommunity/ComputerManagementDsc/issues/224). +- Updated common function `Test-DscParameterState` to support ordered comparison + of arrays by copying function and tests from `NetworkingDsc` - fixes [Issue #250](https://github.com/dsccommunity/ComputerManagementDsc/issues/250). +- BREAKING CHANGE: ScheduledTask: + - Correct output type of `DaysInterval`,`StartTime`,`WeeksDaysOfWeek`, + and `WeeksInterval` parameters from `Get-TargetResource` to match MOF. + - Refactored `Get-TargetResource` to remove parameters that + are not key or required - fixes [Issue #249](https://github.com/dsccommunity/ComputerManagementDsc/issues/249). + - Added function `Test-DateStringContainsTimeZone` to determine if a string + containing a date time includes a time zone. + - Enable verbose preference to be passed through to `Test-DscParameterState`. + - Changed `Test-TargetResource` so that `StartTime` is only compared for + trigger types `Daily`,`Weekly` or `Once`. +- Fix minor style issues in statement case. + +## [6.5.0.0] + +### Changed + +- Computer: + - Fix for 'directory service is busy' error when joining a domain and renaming + a computer when JoinOU is specified - Fixes [Issue #221](https://github.com/dsccommunity/ComputerManagementDsc/issues/221). +- Added new resource SmbShare + - Moved and improved from deprecated module xSmbShare. +- Changes to ComputerManagementDsc.Common + - Updated Test-DscParameterState so it now can compare zero item + collections (arrays). +- Changes to WindowsEventLog + - Minor style guideline cleanup. +- Opt-in to common test to validate localization. Fixed localization strings + in resources - Fixes [Issue #217](https://github.com/dsccommunity/ComputerManagementDsc/issues/217). +- PowerShellExecutionPolicy: + - Removed `SupportsShouldProcess` as it cannot be used with DSC - Fixes + [Issue #219](https://github.com/dsccommunity/ComputerManagementDsc/issues/219). +- Combined all ComputerManagementDsc.ResourceHelper module functions into + ComputerManagementDsc.Common module - Fixes [Issue #218](https://github.com/dsccommunity/ComputerManagementDsc/issues/218). + - Minor code cleanup against style guideline. + - Remove code from `New-InvalidOperationException` because it was a + code path that could never could be used due to the parameter + validation preventing the helper function being called that way. + - Updated all `Get-LocalizationData` to latest version from + [DSCResource.Template](https://github.com/PowerShell/DSCResource.Template). + - Fixed an issue with the helper function `Test-IsNanoServer` that + prevented it to work. Though the helper function is not used, so this + issue was not caught until now when unit tests was added. + - Improved code coverage. + +## [6.4.0.0] + +### Changed + +- ScheduledTask: + - IdleWaitTimeout returned from Get-TargetResource always null - Fixes [Issue #186](https://github.com/dsccommunity/ComputerManagementDsc/issues/186). + - Added BuiltInAccount Property to allow running task as one of the build in + service accounts - Fixes [Issue #130](https://github.com/dsccommunity/ComputerManagementDsc/issues/130). +- Refactored module folder structure to move resource to root folder of + repository and remove test harness - fixes [Issue #188](https://github.com/dsccommunity/ComputerManagementDsc/issues/188). +- Added a CODE\_OF\_CONDUCT.md with the same content as in the README.md and + linked to it from README.MD instead. +- Updated test header for all unit tests to version 1.2.4. +- Updated test header for all integration to version 1.3.3. +- Enabled example publish to PowerShell Gallery by adding `gallery_api` + environment variable to `AppVeyor.yml`. + +## [6.3.0.0] + +### Changed + +- Correct PSSA custom rule violations - fixes [Issue #209](https://github.com/dsccommunity/ComputerManagementDsc/issues/209). +- Correct long example filenames for PowerShellExecutionPolicy examples. +- Opted into Common Tests 'Required Script Analyzer Rules', + 'Flagged Script Analyzer Rules', 'New Error-Level Script Analyzer Rules' + 'Custom Script Analyzer Rules' and 'Relative Path Length' - + fixes [Issue #152](https://github.com/dsccommunity/ComputerManagementDsc/issues/152). +- PowerPlan: + - Added support to specify the desired power plan either as name or guid. + Fixes [Issue #59](https://github.com/dsccommunity/ComputerManagementDsc/issues/59) + - Changed the resource so it uses Windows APIs instead of WMI/CIM + (Workaround for Server 2012R2 Core, Nano Server, Server 2019 and Windows 10). + Fixes [Issue #155](https://github.com/dsccommunity/ComputerManagementDsc/issues/155) + and [Issue #65](https://github.com/dsccommunity/ComputerManagementDsc/issues/65) + +## [6.2.0.0] + +### Changed + +- WindowsEventLog: + - Migrated the xWinEventLog from [xWinEventLog](https://github.com/PowerShell/xWinEventLog) + and renamed to WindowsEventLog. + - Moved strings in localization file. + - LogMode is now set with Limit-EventLog, + - Fixes [Issue #18](https://github.com/dsccommunity/ComputerManagementDsc/issues/18). +- Updated examples to format required for publishing to PowerShell Gallery - fixes + [Issue #206](https://github.com/dsccommunity/ComputerManagementDsc/issues/206). +- Opted into Common Tests 'Validate Example Files To Be Published' and + 'Validate Markdown Links'. + +## [6.1.0.0] + +### Changed + +- Updated LICENSE file to match the Microsoft Open Source Team standard. + Fixes [Issue #197](https://github.com/dsccommunity/ComputerManagementDsc/issues/197). +- Explicitly removed extra hidden files from release package + +## [6.0.0.0] + +### Changed + +- ScheduledTask: + - Added support for Group Managed Service Accounts, implemented using the ExecuteAsGMSA + parameter. Fixes [Issue #111](https://github.com/dsccommunity/ComputerManagementDsc/issues/111) + - Added support to set the Synchronize Across Time Zone option. Fixes [Issue #109](https://github.com/dsccommunity/ComputerManagementDsc/issues/109) +- Added .VSCode settings for applying DSC PSSA rules - fixes [Issue #189](https://github.com/dsccommunity/ComputerManagementDsc/issues/189). +- BREAKING CHANGE: PowerPlan: + - Added IsActive Read-Only Property - Fixes [Issue #171](https://github.com/dsccommunity/ComputerManagementDsc/issues/171). + - InActive power plans are no longer returned with their Name set to null. + Now, the name is always returned and the Read-Only property of IsActive + is set accordingly. + +## [5.2.0.0] + +### Changed + +- PowershellExecutionPolicy: + - Updated to meet HQRM guidelines. + - Migrated the xPowershellExecutionPolicy from [xPowershellExecutionPolicy](https://github.com/PowerShell/xPowerShellExecutionPolicy) + and renamed to PowershellExecutionPolicy. + - Moved strings to localization file. +- Changed the scope from Global to Script in MSFT_ScheduledTask.Integration.Tests.ps1 +- Changed the scope from Global to Script ComputerManagementDsc.Common.Tests.ps1 +- ScheduledTask: + - Added support for event based triggers, implemented using the ScheduleType OnEvent + fixes [Issue #167](https://github.com/dsccommunity/ComputerManagementDsc/issues/167) + +## [5.1.0.0] + +### Changed + +- TimeZone: + - Migrated xTimeZone resource from [xTimeZone](https://github.com/PowerShell/xTimeZone) + and renamed to TimeZone - fixes [Issue #157](https://github.com/dsccommunity/ComputerManagementDsc/issues/157). +- Moved Test-Command from ComputerManagementDsc.ResourceHelper to + ComputerManagementDsc.Common module to match what TimeZone requires. + It was not exported in ComputerManagementDsc.ResourceHelper and not + used. +- Add `server` parameter to `Computer` resource - fixes [Issue #161](https://github.com/dsccommunity/ComputerManagementDsc/issues/161) + +## [5.0.0.0] + +### Changed + +- BREAKING CHANGE: + - Renamed ComputerManagement to ComputerManagementDsc - fixes [Issue #119](https://github.com/dsccommunity/ComputerManagementDsc/issues/119). + - Changed all MSFT\_xResourceName to MSFT\_ResourceName. + - Updated DSCResources, Examples, Modules and Tests with new naming. + - Updated Year to 2018 in License and Manifest. + - Updated README.md from xComputerManagement to ComputerManagementDsc. +- OfflineDomainJoin: + - Cleaned up spacing in strings file to make consistent with other + resources. +- VirtualMemory: + - Converted strings to single quotes in integration test. + +## [4.1.0.0] + +### Changed + +- xScheduledTask: + - Update existing Scheduled Task using SetScheduleTask + instead of UnRegister/Register - See [Issue #134](https://github.com/PowerShell/xComputerManagement/issues/134). +- Fix master branch AppVeyor badge link URL in README.MD - See [Issue #140](https://github.com/PowerShell/xComputerManagement/issues/140). +- Fix deletion of scheduled task with unknown or empty task trigger. + Get-TargetResource returns an empty ScheduleType string if the task + trigger is empty or unknown - See [Issue + #137](https://github.com/PowerShell/xComputerManagement/issues/137). +- Added dependency information for xScheduledTask to README.MD. + +## [4.0.0.0] + +### Changed + +- BREAKING CHANGE: xScheduledTask: + - Breaking change because `Get-TargetResource` no longer outputs + `ActionExecutable` and `ScheduleType` properties when the scheduled + task does not exist. It will also include `TaskPath` in output when + scheduled task does not exist. +- xScheduledTask: + - Add support to disable built-in scheduled tasks - See [Issue #74](https://github.com/PowerShell/xComputerManagement/issues/74). + - Fix unit test mocked schedule task object structure. + - Fix error message when trigger type is unknown - See [Issue #121](https://github.com/PowerShell/xComputerManagement/issues/121). + - Moved strings into separate strings file. + - Updated to meet HQRM guidelines. +- xComputer: + - Resolved bug in Get-ComputerDomain where LocalSystem doesn't have + rights to the domain. +- Updated tests to meet Pester V4 guidelines - See [Issue #106](https://github.com/PowerShell/xComputerManagement/issues/106). +- Converted module to use auto documentation format. + +## [3.2.0.0] + +### Changed + +- xScheduledTask: + - Enable Execution Time Limit of task to be set to indefinite + by setting `ExecutionTimeLimit` to '00:00:00' - See [Issue #115](https://github.com/PowerShell/xComputerManagement/issues/115). +- xPowerPlan: + - Updated to meet HQRM guidelines. + - Converted calls to `throw` to use `New-InvalidOperationException` + in CommonResourceHelper. +- Move Common Resource Helper functions into modules folder. +- Changed resources to use Common Resource Helper functions. +- Moved strings for Common Resource Helper functions into separate + strings file. +- Added unit tests for Common Helper functions. + +## [3.1.0.0] + +### Changed + +- xOfflineDomainJoin: + - Updated to meet HQRM guidelines. +- xScheduledTask: + - Applied autoformatting to examples to improve readability. + - Added LogonType and RunLevel parameters for controlling + task execution. + - Correct `Assert-VerifiableMocks` to `Assert-VerifiableMock` + +## [3.0.0.0] + +### Changed + +- xComputer: Added parameter to set the local computer description along with documentation + and unit tests for this change. +- BREAKING CHANGE: xScheduledTask: + - Converted all Interval/Duration type parameters over to be string format + to prevent the Timezone the MOF file was created in from being stored. + This is to fix problems where MOF files are created in one timezone but + deployed nodes to a different timezone - See [Issue #85](https://github.com/PowerShell/xComputerManagement/issues/85) + - Added ConvertTo-TimeSpanFromScheduledTaskString function and refactored + to reduce code duplication. + - Added support for setting repetition duration to `Indefinitely`. +- xComputer: + - Moved strings to localization file. + - Updated to meet HQRM guidelines. +- xVirtualMemory: + - Refactored shared common code into new utility functions to + reduce code duplication and improve testability. + - Moved strings into localizable strings file. + - Converted calls to `throw` to use `New-InvalidOperationException` + in CommonResourceHelper. + - Improved unit test coverage. + - Updated to meet HQRM guidelines. + +## [2.1.0.0] + +### Changed + +- xComputer: Changed comparison that validates if we are in the correct AD + Domain to work correctly if FQDN wasn't used. +- Updated AppVeyor.yml to use AppVeyor.psm1 module in DSCResource.Tests. +- Removed Markdown.md errors. +- Added CodeCov.io support. +- xScheduledTask + - Fixed incorrect TaskPath handling - [Issue #45](https://github.com/PowerShell/xComputerManagement/issues/45) +- Change examples to meet HQRM standards and optin to Example validation + tests. +- Replaced examples in README.MD to links to Example files. +- Added the VS Code PowerShell extension formatting settings that cause PowerShell + files to be formatted as per the DSC Resource kit style guidelines - [Issue #91](https://github.com/PowerShell/xComputerManagement/issues/91). +- Opted into Common Tests 'Validate Module Files' and 'Validate Script Files'. +- Converted files with UTF8 with BOM over to UTF8 - fixes [Issue #90](https://github.com/PowerShell/xComputerManagement/issues/90). +- Updated Year to 2017 in License and Manifest - fixes [Issue #87](https://github.com/PowerShell/xComputerManagement/issues/87). +- Added .github support files - fixes [Issue #88](https://github.com/PowerShell/xComputerManagement/issues/88): + - CONTRIBUTING.md + - ISSUE_TEMPLATE.md + - PULL_REQUEST_TEMPLATE.md +- Resolved all PSScriptAnalyzer warnings and style guide warnings. +- xOfflineDomainJoin: + - Changed to use CommonResourceHelper to load localization strings. + - Renamed en-US to be correct case so that localization strings can be loaded. + - Suppress PSScriptAnalyzer rule PSAvoidGlobalVars for + `$global:DSCMachineStatus = 1`. +- xComputer: + - Suppress PSScriptAnalyzer rule PSAvoidGlobalVars for + `$global:DSCMachineStatus = 1`. +- xVirtualMemory: + - Suppress PSScriptAnalyzer rule PSAvoidGlobalVars for + `$global:DSCMachineStatus = 1`. + +## [2.0.0.0] + +### Changed + +- Updated resources + - BREAKING CHANGE: xScheduledTask: Added nearly all available parameters for tasks +- xVirtualMemory: + - Fixed failing tests. + +## [1.10.0.0] + +### Changed + +- Added resources: + - xVirtualMemory + +## [1.9.0.0] + +### Changed + +- Added resources + - xPowerPlan + +## [1.8.0.0] + +### Changed + +- Converted AppVeyor.yml to pull Pester from PSGallery instead of + Chocolatey. +- Changed AppVeyor.yml to use default image +- xScheduledTask: Fixed bug with different OS versions returning repeat interval + differently + +## [1.7.0.0] + +### Changed + +- Added support for enabling or disabling scheduled tasks +- The Name parameter resolves to $env:COMPUTERNAME when the value is localhost + +## [1.6.0.0] + +### Changed + +- Added the following resources: + - MSFT_xOfflineDomainJoin resource to join computers to an AD Domain using an + Offline Domain Join request file. + - MSFT_xScheduledTask resource to control scheduled tasks on the local server +- MSFT_xOfflineDomainJoin: Corrected localizedData.DomainAlreadyJoinedhMessage name. +- xComputer: Changed credential generation code in tests to avoid triggering + PSSA rule PSAvoidUsingConvertToSecureStringWithPlainText. + Renamed unit test file to match the name of Resource file. + +## [1.5.0.0] + +### Changed + +- Update Unit tests to use the standard folder structure and test templates. +- Added .gitignore to prevent commit of DSCResource.Tests. + +## [1.4.0.0] + +### Changed + +- Added validation to the Name parameter +- Added the JoinOU parameter which allows you to specify the organizational unit + that the computer account will be created in +- Added the CurrentOU read-only property that shows the organizational unit that + the computer account is currently in + +## [1.3.0.0] + +### Changed + +- xComputer + - Fixed issue with Test-TargetResource when not specifying Domain or + Workgroup name + - Added tests + +## [1.2.2.0] + +### Changed + +- Added types to Get/Set/Test definitions to allow xResourceDesigner validation + to succeed + +## [1.2.0.0] + +### Changed + +- Added functionality to enable moving computer from one domain to another +- Modified Test-DscConfiguration logics when testing domain join + +## [1.0.0.0] + +### Changed + +- Initial release with the following resources: + - xComputer diff --git a/LICENSE b/LICENSE index 21071075..be601b58 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ - MIT License +MIT License - Copyright (c) Microsoft Corporation. All rights reserved. +Copyright the DSC Community contributors. All rights reserved. - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE diff --git a/README.md b/README.md index 80ad2f4c..ac19b646 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,32 @@ # ComputerManagementDsc +[![Build Status](https://dev.azure.com/dsccommunity/ComputerManagementDsc/_apis/build/status/dsccommunity.ComputerManagementDsc?branchName=master)](https://dev.azure.com/dsccommunity/ComputerManagementDsc/_build/latest?definitionId=16&branchName=master) +![Code Coverage](https://img.shields.io/azure-devops/coverage/dsccommunity/ComputerManagementDsc/16/master) +[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/ComputerManagementDsc/16/master)](https://dsccommunity.visualstudio.com/ComputerManagementDsc/_test/analytics?definitionId=16&contextType=build) +[![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/ComputerManagementDsc?label=ComputerManagementDsc%20Preview)](https://www.powershellgallery.com/packages/ComputerManagementDsc/) +[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/ComputerManagementDsc?label=ComputerManagementDsc)](https://www.powershellgallery.com/packages/ComputerManagementDsc/) + +## Code of Conduct + +This project has adopted [this code of conduct](CODE_OF_CONDUCT.md). + +## Releases + +For each merge to the branch `master` a preview release will be +deployed to [PowerShell Gallery](https://www.powershellgallery.com/). +Periodically a release version tag will be pushed which will deploy a +full release to [PowerShell Gallery](https://www.powershellgallery.com/). + +## Contributing + +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing). + +## Change log + +A full list of changes in each version can be found in the [change log](CHANGELOG.md). + +## Resources + The **ComputerManagementDsc** module contains the following resources: - **Computer**: allows you to configure a computer by changing its name and @@ -40,31 +67,4 @@ This project has adopted [this code of conduct](CODE_OF_CONDUCT.md). ## Documentation and Examples For a full list of resources in ComputerManagementDsc and examples on their use, -check out the [ComputerManagementDsc wiki](https://github.com/PowerShell/ComputerManagementDsc/wiki). - -## Branches - -### master - -[![Build status](https://ci.appveyor.com/api/projects/status/cg28qxeco39wgo9l/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/ComputerManagementDsc/branch/master) -[![codecov](https://codecov.io/gh/PowerShell/ComputerManagementDsc/branch/master/graph/badge.svg)](https://codecov.io/gh/PowerShell/ComputerManagementDsc/branch/master) - -This is the branch containing the latest release - no contributions should be made -directly to this branch. - -### dev - -[![Build status](https://ci.appveyor.com/api/projects/status/cg28qxeco39wgo9l/branch/dev?svg=true)](https://ci.appveyor.com/project/PowerShell/ComputerManagementDsc/branch/dev) -[![codecov](https://codecov.io/gh/PowerShell/ComputerManagementDsc/branch/dev/graph/badge.svg)](https://codecov.io/gh/PowerShell/ComputerManagementDsc/branch/dev) - -This is the development branch to which contributions should be proposed by contributors -as pull requests. This development branch will periodically be merged to the master -branch, and be released to [PowerShell Gallery](https://www.powershellgallery.com/). - -## Contributing - -Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md). - -## Change log - -A full list of changes in each version can be found in the [change log](CHANGELOG.md). +check out the [ComputerManagementDsc wiki](https://github.com/dsccommunity/ComputerManagementDsc/wiki). diff --git a/RequiredModules.psd1 b/RequiredModules.psd1 new file mode 100644 index 00000000..e37ab1af --- /dev/null +++ b/RequiredModules.psd1 @@ -0,0 +1,21 @@ +@{ + # Set up a mini virtual environment... + PSDependOptions = @{ + AddToPath = $true + Target = 'output\RequiredModules' + Parameters = @{ + } + } + + invokeBuild = 'latest' + PSScriptAnalyzer = 'latest' + pester = 'latest' + Plaster = 'latest' + ModuleBuilder = '1.0.0' + ChangelogManagement = 'latest' + Sampler = 'latest' + 'DscResource.Test' = 'latest' + 'DscResource.AnalyzerRules' = 'latest' + xDscResourceDesigner = 'latest' + LoopbackAdapter = 'latest' +} diff --git a/Resolve-Dependency.ps1 b/Resolve-Dependency.ps1 new file mode 100644 index 00000000..ec909b88 --- /dev/null +++ b/Resolve-Dependency.ps1 @@ -0,0 +1,288 @@ +[CmdletBinding()] +param +( + [Parameter()] + [String] + $DependencyFile = 'RequiredModules.psd1', + + [Parameter()] + [String] + # Path for PSDepend to be bootstrapped and save other dependencies. + # Can also be CurrentUser or AllUsers if you wish to install the modules in such scope + # Default to $PWD.Path/output/modules + $PSDependTarget = (Join-Path $PSScriptRoot './output/RequiredModules'), + + [Parameter()] + [uri] + # URI to use for Proxy when attempting to Bootstrap PackageProvider & PowerShellGet + $Proxy, + + [Parameter()] + # Credential to contact the Proxy when provided + [PSCredential]$ProxyCredential, + + [Parameter()] + [ValidateSet('CurrentUser', 'AllUsers')] + [String] + # Scope to bootstrap the PackageProvider and PSGet if not available + $Scope = 'CurrentUser', + + [Parameter()] + [String] + # Gallery to use when bootstrapping PackageProvider, PSGet and when calling PSDepend (can be overridden in Dependency files) + $Gallery = 'PSGallery', + + [Parameter()] + [PSCredential] + # Credentials to use with the Gallery specified above + $GalleryCredential, + + + [Parameter()] + [switch] + # Allow you to use a locally installed version of PowerShellGet older than 1.6.0 (not recommended, default to $false) + $AllowOldPowerShellGetModule, + + [Parameter()] + [String] + # Allow you to specify a minimum version fo PSDepend, if you're after specific features. + $MinimumPSDependVersion, + + [Parameter()] + [Switch] + $AllowPrerelease, + + [Parameter()] + [Switch] + $WithYAML +) + +# Load Defaults for parameters values from Resolve-Dependency.psd1 if not provided as parameter +try +{ + Write-Verbose -Message "Importing Bootstrap default parameters from '$PSScriptRoot/Resolve-Dependency.psd1'." + $ResolveDependencyDefaults = Import-PowerShellDataFile -Path (Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1' -Resolve -ErrorAction Stop) + $ParameterToDefault = $MyInvocation.MyCommand.ParameterSets.Where{ $_.Name -eq $PSCmdlet.ParameterSetName }.Parameters.Keys + if ($ParameterToDefault.Count -eq 0) + { + $ParameterToDefault = $MyInvocation.MyCommand.Parameters.Keys + } + # Set the parameters available in the Parameter Set, or it's not possible to choose yet, so all parameters are an option + foreach ($ParamName in $ParameterToDefault) + { + if (-Not $PSBoundParameters.Keys.Contains($ParamName) -and $ResolveDependencyDefaults.ContainsKey($ParamName)) + { + Write-Verbose -Message "Setting $ParamName with $($ResolveDependencyDefaults[$ParamName])" + try + { + $variableValue = $ResolveDependencyDefaults[$ParamName] + if ($variableValue -is [string]) + { + $variableValue = $ExecutionContext.InvokeCommand.ExpandString($variableValue) + } + $PSBoundParameters.Add($ParamName, $variableValue) + Set-Variable -Name $ParamName -value $variableValue -Force -ErrorAction SilentlyContinue + } + catch + { + Write-Verbose -Message "Error adding default for $ParamName : $($_.Exception.Message)" + } + } + } +} +catch +{ + Write-Warning -Message "Error attempting to import Bootstrap's default parameters from $(Join-Path $PSScriptRoot '.\Resolve-Dependency.psd1'): $($_.Exception.Message)." +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 0 -CurrentOperation "NuGet Bootstrap" + +if (!(Get-PackageProvider -Name NuGet -ForceBootstrap -ErrorAction SilentlyContinue)) +{ + $providerBootstrapParams = @{ + Name = 'nuget' + force = $true + ForceBootstrap = $true + ErrorAction = 'Stop' + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $providerBootstrapParams.Add('Proxy', $Proxy) + } + 'ProxyCredential' + { + $providerBootstrapParams.Add('ProxyCredential', $ProxyCredential) + } + 'Scope' + { + $providerBootstrapParams.Add('Scope', $Scope) + } + } + + if ($AllowPrerelease) + { + $providerBootstrapParams.Add('AllowPrerelease', $true) + } + + Write-Information "Bootstrap: Installing NuGet Package Provider from the web (Make sure Microsoft addresses/ranges are allowed)" + $null = Install-PackageProvider @providerBootstrapParams + $latestNuGetVersion = (Get-PackageProvider -Name NuGet -ListAvailable | Select-Object -First 1).Version.ToString() + Write-Information "Bootstrap: Importing NuGet Package Provider version $latestNuGetVersion to current session." + $Null = Import-PackageProvider -Name NuGet -RequiredVersion $latestNuGetVersion -Force +} + +Write-Progress -Activity "Bootstrap:" -PercentComplete 10 -CurrentOperation "Ensuring Gallery $Gallery is trusted" + +# Fail if the given PSGallery is not Registered +$Policy = (Get-PSRepository $Gallery -ErrorAction Stop).InstallationPolicy +Set-PSRepository -Name $Gallery -InstallationPolicy Trusted -ErrorAction Ignore +try +{ + Write-Progress -Activity "Bootstrap:" -PercentComplete 25 -CurrentOperation "Checking PowerShellGet" + # Ensure the module is loaded and retrieve the version you have + $PowerShellGetVersion = (Import-Module PowerShellGet -PassThru -ErrorAction SilentlyContinue).Version + + Write-Verbose "Bootstrap: The PowerShellGet version is $PowerShellGetVersion" + # Versions below 1.6.0 are considered old, unreliable & not recommended + if (!$PowerShellGetVersion -or ($PowerShellGetVersion -lt [System.version]'1.6.0' -and !$AllowOldPowerShellGetModule)) + { + Write-Progress -Activity "Bootstrap:" -PercentComplete 40 -CurrentOperation "Installing newer version of PowerShellGet" + $InstallPSGetParam = @{ + Name = 'PowerShellGet' + Force = $true + SkipPublisherCheck = $true + AllowClobber = $true + Scope = $Scope + Repository = $Gallery + } + + switch ($PSBoundParameters.Keys) + { + 'Proxy' + { + $InstallPSGetParam.Add('Proxy', $Proxy) + } + 'ProxyCredential' + { + $InstallPSGetParam.Add('ProxyCredential', $ProxyCredential) + } + 'GalleryCredential' + { + $InstallPSGetParam.Add('Credential', $GalleryCredential) + } + } + + Install-Module @InstallPSGetParam + Remove-Module PowerShellGet -force -ErrorAction SilentlyContinue + Import-Module PowerShellGet -Force + $NewLoadedVersion = (Get-Module PowerShellGet).Version.ToString() + Write-Information "Bootstrap: PowerShellGet version loaded is $NewLoadedVersion" + Write-Progress -Activity "Bootstrap:" -PercentComplete 60 -CurrentOperation "Installing newer version of PowerShellGet" + } + + # Try to import the PSDepend module from the available modules + try + { + $ImportPSDependParam = @{ + Name = 'PSDepend' + ErrorAction = 'Stop' + Force = $true + } + + if ($MinimumPSDependVersion) + { + $ImportPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + $null = Import-Module @ImportPSDependParam + } + catch + { + # PSDepend module not found, installing or saving it + if ($PSDependTarget -in 'CurrentUser', 'AllUsers') + { + Write-Debug "PSDepend module not found. Attempting to install from Gallery $Gallery" + Write-Warning "Installing PSDepend in $PSDependTarget Scope" + $InstallPSDependParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Force = $true + Scope = $PSDependTarget + SkipPublisherCheck = $true + AllowClobber = $true + } + + if ($MinimumPSDependVersion) + { + $InstallPSDependParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Installing PSDepend from $Gallery" + Install-Module @InstallPSDependParam + } + else + { + Write-Debug "PSDepend module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PSDepend' + Repository = $Gallery + Path = $PSDependTarget + } + + if ($MinimumPSDependVersion) + { + $SaveModuleParam.add('MinimumVersion', $MinimumPSDependVersion) + } + + Write-Progress -Activity "Bootstrap:" -PercentComplete 75 -CurrentOperation "Saving & Importing PSDepend from $Gallery to $Scope" + Save-Module @SaveModuleParam + } + } + finally + { + Write-Progress -Activity "Bootstrap:" -PercentComplete 100 -CurrentOperation "Loading PSDepend" + # We should have successfully bootstrapped PSDepend. Fail if not available + Import-Module PSDepend -ErrorAction Stop + } + + if ($WithYAML) + { + if (-Not (Get-Module -ListAvailable -Name 'PowerShell-Yaml')) + { + Write-Verbose "PowerShell-Yaml module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget" + $SaveModuleParam = @{ + Name = 'PowerShell-Yaml' + Repository = $Gallery + Path = $PSDependTarget + } + + Save-Module @SaveModuleParam + Import-Module "PowerShell-Yaml" -ErrorAction Stop + } + else + { + Write-Verbose "PowerShell-Yaml is already available" + } + } + + Write-Progress -Activity "PSDepend:" -PercentComplete 0 -CurrentOperation "Restoring Build Dependencies" + if (Test-Path $DependencyFile) + { + $PSDependParams = @{ + Force = $true + Path = $DependencyFile + } + + # TODO: Handle when the Dependency file is in YAML, and -WithYAML is specified + Invoke-PSDepend @PSDependParams + } + Write-Progress -Activity "PSDepend:" -PercentComplete 100 -CurrentOperation "Dependencies restored" -Completed +} +finally +{ + # Reverting the Installation Policy for the given gallery + Set-PSRepository -Name $Gallery -InstallationPolicy $Policy + Write-Verbose "Project Bootstrapped, returning to Invoke-Build" +} diff --git a/Resolve-Dependency.psd1 b/Resolve-Dependency.psd1 new file mode 100644 index 00000000..2ae8c0da --- /dev/null +++ b/Resolve-Dependency.psd1 @@ -0,0 +1,5 @@ +@{ + Gallery = 'PSGallery' + AllowPrerelease = $false + WithYAML = $true +} diff --git a/Tests/Unit/MSFT_ScheduledTask.Tests.ps1 b/Tests/Unit/MSFT_ScheduledTask.Tests.ps1 index dd974827..4ab23467 100644 --- a/Tests/Unit/MSFT_ScheduledTask.Tests.ps1 +++ b/Tests/Unit/MSFT_ScheduledTask.Tests.ps1 @@ -2123,7 +2123,7 @@ try Context 'When a scheduled task is configured with a description that contains various forms of whitespace but is in the desired state' { <# This test verifies issue #258: - https://github.com/PowerShell/ComputerManagementDsc/issues/258 + https://github.com/dsccommunity/ComputerManagementDsc/issues/258 #> $testParameters = $getTargetResourceParameters + @{ ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 84c8d717..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,44 +0,0 @@ -#---------------------------------# -# environment configuration # -#---------------------------------# -version: 1.9.{build}.0 -environment: - gallery_api: - secure: 9ekJzfsPCDBkyLrfmov83XbbhZ6E2N3z+B/Io8NbDetbHc6hWS19zsDmy7t0Vvxv -install: - - git clone https://github.com/PowerShell/DscResource.Tests - - - ps: | - $moduleName = 'ComputerManagementDsc' - Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" - Invoke-AppveyorInstallTask - -#---------------------------------# -# build configuration # -#---------------------------------# - -build: false - -#---------------------------------# -# test configuration # -#---------------------------------# - -test_script: - - ps: | - Invoke-AppveyorTestScriptTask ` - -CodeCoverage ` - -CodeCovIo ` - -ExcludeTag @() - -#---------------------------------# -# deployment configuration # -#---------------------------------# - -# scripts to run before deployment -deploy_script: - - ps: | - Invoke-AppveyorAfterTestTask ` - -Type 'Wiki' ` - -ResourceModuleName $moduleName - - Invoke-AppVeyorDeployTask diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..17c374ba --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,289 @@ +trigger: + branches: + include: + - master + paths: + exclude: + - CHANGELOG.md + tags: + include: + - "v*" + exclude: + - "*-*" + +stages: + - stage: Build + jobs: + - job: Package_Module + displayName: 'Package Module' + pool: + vmImage: 'ubuntu 16.04' + steps: + - task: GitVersion@5 + name: gitversion + displayName: 'Evaluate Next Version' + inputs: + runtime: 'core' + configFilePath: 'GitVersion.yml' + + - task: PowerShell@2 + name: package + displayName: 'Build & Package Module' + inputs: + filePath: './build.ps1' + arguments: '-Tasks pack -ResolveDependency' + pwsh: true + env: + ModuleVersion: $(gitVersion.Informationalversion) + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Build Artifact' + inputs: + PathtoPublish: 'output/' + ArtifactName: 'output' + publishLocation: 'Container' + + - stage: Test + dependsOn: Build + jobs: + - job: Test_HQRM + displayName: 'HQRM' + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: test + displayName: 'Run HQRM Test' + inputs: + filePath: './build.ps1' + arguments: '-Tasks hqrmtest' + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'HQRM' + condition: succeededOrFailed() + + - job: Test_Unit_2016 + displayName: 'Unit (Windows Server 2016)' + pool: + vmImage: 'vs2017-win2016' + timeoutInMinutes: 0 + steps: + - powershell: | + $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' + echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" + echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" + name: dscBuildVariable + displayName: 'Set Environment Variables' + + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: test + displayName: 'Run Unit Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Unit'" + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Unit (Windows Server 2016)' + condition: succeededOrFailed() + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Code Coverage' + condition: succeededOrFailed() + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: 'output/testResults/CodeCov*.xml' + pathToSources: '$(Build.SourcesDirectory)/output/$(DscBuildVariable.RepositoryName)' + + - job: Test_Integration_2016 + displayName: 'Integration (Windows Server 2016)' + pool: + vmImage: 'vs2017-win2016' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + + - task: PowerShell@2 + name: test + displayName: 'Run Integration Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0" + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Integration (Windows Server 2016)' + condition: succeededOrFailed() + + - job: Test_Unit_2019 + displayName: 'Unit (Windows Server 2019)' + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + steps: + - powershell: | + $repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/' + echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner" + echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName" + name: dscBuildVariable + displayName: 'Set Environment Variables' + + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: test + displayName: 'Run Unit Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Unit'" + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Unit (Windows Server 2019)' + condition: succeededOrFailed() + + - task: PublishCodeCoverageResults@1 + displayName: 'Publish Code Coverage' + condition: succeededOrFailed() + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: 'output/testResults/CodeCov*.xml' + pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)' + + - job: Test_Integration_2019 + displayName: 'Integration (Windows Server 2019)' + pool: + vmImage: 'windows-2019' + timeoutInMinutes: 0 + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: configureWinRM + displayName: 'Configure WinRM' + inputs: + targetType: 'inline' + script: 'winrm quickconfig -quiet' + pwsh: false + + - task: PowerShell@2 + name: test + displayName: 'Run Integration Test' + inputs: + filePath: './build.ps1' + arguments: "-Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0" + pwsh: false + + - task: PublishTestResults@2 + displayName: 'Publish Test Results' + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'output/testResults/NUnit*.xml' + testRunTitle: 'Integration (Windows Server 2019)' + condition: succeededOrFailed() + + - stage: Deploy + dependsOn: Test + condition: | + and( + succeeded(), + or( + eq(variables['Build.SourceBranch'], 'refs/heads/master'), + startsWith(variables['Build.SourceBranch'], 'refs/tags/') + ), + contains(variables['System.TeamFoundationCollectionUri'], 'dsccommunity') + ) + jobs: + - job: Deploy_Module + displayName: 'Deploy Module' + pool: + vmImage: 'ubuntu 16.04' + steps: + - task: DownloadBuildArtifacts@0 + displayName: 'Download Build Artifact' + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'output' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + name: publishRelease + displayName: 'Publish Release' + inputs: + filePath: './build.ps1' + arguments: '-tasks publish' + pwsh: true + env: + GitHubToken: $(GitHubToken) + GalleryApiToken: $(GalleryApiToken) + + - task: PowerShell@2 + name: sendChangelogPR + displayName: 'Send Changelog PR' + inputs: + filePath: './build.ps1' + arguments: '-tasks Create_ChangeLog_GitHub_PR' + pwsh: true + env: + GitHubToken: $(GitHubToken) diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 00000000..ff53c84f --- /dev/null +++ b/build.ps1 @@ -0,0 +1,354 @@ +<# + +.DESCRIPTION + Bootstrap and build script for PowerShell module pipeline + +#> +[CmdletBinding()] +param +( + [Parameter(Position = 0)] + [string[]]$Tasks = '.', + + [Parameter()] + [String] + $CodeCoverageThreshold = '', + + [Parameter()] + [validateScript( + { Test-Path -Path $_ } + )] + $BuildConfig = './build.yaml', + + [Parameter()] + # A Specific folder to build the artefact into. + $OutputDirectory = 'output', + + [Parameter()] + # Subdirectory name to build the module (under $OutputDirectory) + $BuiltModuleSubdirectory = '', + + # Can be a path (relative to $PSScriptRoot or absolute) to tell Resolve-Dependency & PSDepend where to save the required modules, + # or use CurrentUser, AllUsers to target where to install missing dependencies + # You can override the value for PSDepend in the Build.psd1 build manifest + # This defaults to $OutputDirectory/modules (by default: ./output/modules) + [Parameter()] + $RequiredModulesDirectory = $(Join-Path 'output' 'RequiredModules'), + + # Filter which tags to run when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [Parameter()] + [string[]] + $PesterTag, + + [Parameter()] + [string[]] + $PesterScript, + + # Filter which tags to exclude when invoking Pester tests + # This is used in the Invoke-Pester.pester.build.ps1 tasks + [Parameter()] + [string[]] + $PesterExcludeTag, + + [Parameter()] + [Alias('bootstrap')] + [switch] + $ResolveDependency, + + [Parameter(DontShow)] + [AllowNull()] + $BuildInfo, + + [Parameter()] + [switch] + $AutoRestore +) + +# The BEGIN block (at the end of this file) handles the Bootstrap of the Environment before Invoke-Build can run the tasks +# if the -ResolveDependency (aka Bootstrap) is specified, the modules are already available, and can be auto loaded + +process +{ + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + # Only run the process block through InvokeBuild (Look at the Begin block at the bottom of this script) + return + } + + # Execute the Build Process from the .build.ps1 path. + Push-Location -Path $PSScriptRoot -StackName BeforeBuild + + try + { + Write-Host -ForeGroundColor magenta "[build] Parsing defined tasks" + + # Load Default BuildInfo if not provided as parameter + if (!$PSBoundParameters.ContainsKey('BuildInfo')) + { + try + { + if (Test-Path $BuildConfig) + { + $ConfigFile = (Get-Item -Path $BuildConfig) + Write-Host "[build] Loading Configuration from $ConfigFile" + $BuildInfo = switch -Regex ($ConfigFile.Extension) + { + # Native Support for PSD1 + '\.psd1' + { + Import-PowerShellDataFile -Path $BuildConfig + } + # Support for yaml when module PowerShell-Yaml is available + '\.[yaml|yml]' + { + Import-Module -ErrorAction Stop -Name 'powershell-yaml' + ConvertFrom-Yaml -Yaml (Get-Content -Raw $ConfigFile) + } + # Native Support for JSON and JSONC (by Removing comments) + '\.[json|jsonc]' + { + $JSONC = (Get-Content -Raw -Path $ConfigFile) + $JSON = $JSONC -replace '(?m)\s*//.*?$' -replace '(?ms)/\*.*?\*/' + # This should probably be converted to hashtable for splatting + $JSON | ConvertFrom-Json + } + default + { + Write-Error "Extension '$_' not supported. using @{}" + @{ } + } + } + } + else + { + Write-Host -Object "Configuration file $BuildConfig not found" -ForegroundColor Red + $BuildInfo = @{ } + } + } + catch + { + Write-Host -Object "Error loading Config $ConfigFile.`r`n Are you missing dependencies?" -ForegroundColor Yellow + Write-Host -Object "Make sure you run './build.ps1 -ResolveDependency -tasks noop' to restore the Required modules the first time" -ForegroundColor Yellow + $BuildInfo = @{ } + Write-Error $_.Exception.Message + } + } + + # If the Invoke-Build Task Header is specified in the Build Info, set it + if ($BuildInfo.TaskHeader) + { + Set-BuildHeader ([scriptblock]::Create($BuildInfo.TaskHeader)) + } + + # Import Tasks from modules via their exported aliases when defined in BUild Manifest + # https://github.com/nightroman/Invoke-Build/tree/master/Tasks/Import#example-2-import-from-a-module-with-tasks + if ($BuildInfo.containsKey('ModuleBuildTasks')) + { + foreach ($Module in $BuildInfo['ModuleBuildTasks'].Keys) + { + try + { + Write-Host -ForegroundColor DarkGray -Verbose "Importing tasks from module $Module" + $LoadedModule = Import-Module $Module -PassThru -ErrorAction Stop + foreach ($TaskToExport in $BuildInfo['ModuleBuildTasks'].($Module)) + { + $LoadedModule.ExportedAliases.GetEnumerator().Where{ + # using -like to support wildcard + Write-Host -ForegroundColor DarkGray "`t Loading $($_.Key)..." + $_.Key -like $TaskToExport + }.ForEach{ + # Dot sourcing the Tasks via their exported aliases + . (Get-Alias $_.Key) + } + } + } + catch + { + Write-Host -ForegroundColor Red -Object "Could not load tasks for module $Module." + Write-Error $_ + } + } + } + + # Loading Build Tasks defined in the .build/ folder (will override the ones imported above if same task name) + Get-ChildItem -Path ".build/" -Recurse -Include *.ps1 -ErrorAction Ignore | ForEach-Object { + "Importing file $($_.BaseName)" | Write-Verbose + . $_.FullName + } + + # Synopsis: Empty task, useful to test the bootstrap process + task noop { } + + # Define default task sequence ("."), can be overridden in the $BuildInfo + task . { + Write-Build Yellow "No sequence currently defined for the default task" + } + + # Load Invoke-Build task sequences/workflows from $BuildInfo + Write-Host -ForegroundColor DarkGray "Adding Workflow from configuration:" + foreach ($Workflow in $BuildInfo.BuildWorkflow.keys) + { + Write-Verbose "Creating Build Workflow '$Workflow' with tasks $($BuildInfo.BuildWorkflow.($Workflow) -join ', ')" + $WorkflowItem = $BuildInfo.BuildWorkflow.($Workflow) + if ($WorkflowItem.Trim() -match '^\{(?[\w\W]*)\}$') + { + $WorkflowItem = [ScriptBlock]::Create($Matches['sb']) + } + Write-Host -ForegroundColor DarkGray " +-> $Workflow" + task $Workflow $WorkflowItem + } + + Write-Host -ForeGroundColor magenta "[build] Executing requested workflow: $($Tasks -join ', ')" + + } + finally + { + Pop-Location -StackName BeforeBuild + } +} + +Begin +{ + # Bootstrapping the environment before using Invoke-Build as task runner + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + Write-Host -foregroundColor Green "[pre-build] Starting Build Init" + Push-Location $PSScriptRoot -StackName BuildModule + } + + if ($RequiredModulesDirectory -in @('CurrentUser', 'AllUsers')) + { + # Installing modules instead of saving them + Write-Host -foregroundColor Green "[pre-build] Required Modules will be installed for $RequiredModulesDirectory, not saved." + # Tell Resolve-Dependency to use provided scope as the -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesDirectory + } + else + { + if (-Not (Split-Path -IsAbsolute -Path $OutputDirectory)) + { + $OutputDirectory = Join-Path -Path $PSScriptRoot -ChildPath $OutputDirectory + } + + # Resolving the absolute path to save the required modules to + if (-Not (Split-Path -IsAbsolute -Path $RequiredModulesDirectory)) + { + $RequiredModulesDirectory = Join-Path -Path $PSScriptRoot -ChildPath $RequiredModulesDirectory + } + + # Create the output/modules folder if not exists, or resolve the Absolute path otherwise + if (Resolve-Path $RequiredModulesDirectory -ErrorAction SilentlyContinue) + { + Write-Debug "[pre-build] Required Modules path already exist at $RequiredModulesDirectory" + $RequiredModulesPath = Convert-Path $RequiredModulesDirectory + } + else + { + Write-Host -foregroundColor Green "[pre-build] Creating required modules directory $RequiredModulesDirectory." + $RequiredModulesPath = (New-Item -ItemType Directory -Force -Path $RequiredModulesDirectory).FullName + } + + # Prepending $RequiredModulesPath folder to PSModulePath to resolve from this folder FIRST + if ($RequiredModulesDirectory -notIn @('CurrentUser', 'AllUsers') -and + (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $RequiredModulesDirectory)) + { + Write-Host -foregroundColor Green "[pre-build] Prepending '$RequiredModulesDirectory' folder to PSModulePath" + $Env:PSModulePath = $RequiredModulesDirectory + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Checking if the user should -ResolveDependency + if ((!(Get-Module -ListAvailable powershell-yaml) -or !(Get-Module -ListAvailable InvokeBuild) -or !(Get-Module -ListAvailable PSDepend)) -and !$ResolveDependency) + { + if ($AutoRestore -or !$PSBoundParameters.ContainsKey('Tasks') -or $Tasks -contains 'build') + { + Write-Host -ForegroundColor Yellow "[pre-build] Dependency missing, running './build.ps1 -ResolveDependency -Tasks noop' for you `r`n" + $ResolveDependency = $true + } + else + { + Write-Warning "Some required Modules are missing, make sure you first run with the '-ResolveDependency' parameter." + Write-Warning "Running 'build.ps1 -ResolveDependency -Tasks noop' will pull required modules without running the build task." + } + } + + if ($BuiltModuleSubdirectory) + { + if (-Not (Split-Path -IsAbsolute $BuiltModuleSubdirectory)) + { + $BuildModuleOutput = Join-Path $OutputDirectory $BuiltModuleSubdirectory + } + else + { + $BuildModuleOutput = $BuiltModuleSubdirectory + } + } + else + { + $BuildModuleOutput = $OutputDirectory + } + + # Prepending $BuildModuleOutput folder to PSModulePath to resolve built module from this folder + if (($Env:PSModulePath -split [io.path]::PathSeparator) -notContains $BuildModuleOutput) + { + Write-Host -foregroundColor Green "[pre-build] Prepending '$BuildModuleOutput' folder to PSModulePath" + $Env:PSModulePath = $BuildModuleOutput + [io.path]::PathSeparator + $Env:PSModulePath + } + + # Tell Resolve-Dependency to use $RequiredModulesPath as -PSDependTarget if not overridden in Build.psd1 + $PSDependTarget = $RequiredModulesPath + } + + if ($ResolveDependency) + { + Write-Host -Object "[pre-build] Resolving dependencies." -foregroundColor Green + $ResolveDependencyParams = @{ } + + # If BuildConfig is a Yaml file, bootstrap powershell-yaml via ResolveDependency + if ($BuildConfig -match '\.[yaml|yml]$') + { + $ResolveDependencyParams.add('WithYaml', $true) + } + + $ResolveDependencyAvailableParams = (Get-Command -Name '.\Resolve-Dependency.ps1').parameters.keys + foreach ($CmdParameter in $ResolveDependencyAvailableParams) + { + + # The parameter has been explicitly used for calling the .build.ps1 + if ($MyInvocation.BoundParameters.ContainsKey($CmdParameter)) + { + $ParamValue = $MyInvocation.BoundParameters.ContainsKey($CmdParameter) + Write-Debug " adding $CmdParameter :: $ParamValue [from user-provided parameters to Build.ps1]" + $ResolveDependencyParams.Add($CmdParameter, $ParamValue) + } + # Use defaults parameter value from Build.ps1, if any + else + { + if ($ParamValue = Get-Variable -Name $CmdParameter -ValueOnly -ErrorAction Ignore) + { + Write-Debug " adding $CmdParameter :: $ParamValue [from default Build.ps1 variable]" + $ResolveDependencyParams.add($CmdParameter, $ParamValue) + } + } + } + + Write-Host -foregroundColor Green "[pre-build] Starting bootstrap process." + .\Resolve-Dependency.ps1 @ResolveDependencyParams + } + + if ($MyInvocation.ScriptName -notLike '*Invoke-Build.ps1') + { + Write-Verbose "Bootstrap completed. Handing back to InvokeBuild." + if ($PSBoundParameters.ContainsKey('ResolveDependency')) + { + Write-Verbose "Dependency already resolved. Removing task" + $null = $PSBoundParameters.Remove('ResolveDependency') + } + Write-Host -foregroundColor Green "[build] Starting build with InvokeBuild." + Invoke-Build @PSBoundParameters -Task $Tasks -File $MyInvocation.MyCommand.Path + Pop-Location -StackName BuildModule + return + } +} diff --git a/build.yaml b/build.yaml new file mode 100644 index 00000000..1c486101 --- /dev/null +++ b/build.yaml @@ -0,0 +1,88 @@ +--- +#################################################### +# ModuleBuilder Configuration # +#################################################### +CopyDirectories: + - en-US + - DSCResources + - Modules +Encoding: UTF8 +VersionedOutputDirectory: true + +#################################################### +# Pipeline Configuration # +#################################################### +BuildWorkflow: + '.': + - build + - test + + build: + - Clean + - Build_Module_ModuleBuilder + - Build_NestedModules_ModuleBuilder + - Create_changelog_release_output + + pack: + - build + - package_module_nupkg + + hqrmtest: + - DscResource_Tests_Stop_On_Fail + + test: + - Pester_Tests_Stop_On_Fail + - Pester_if_Code_Coverage_Under_Threshold + + publish: + - Publish_release_to_GitHub + - publish_module_to_gallery + + +#################################################### +# PESTER Configuration # +#################################################### + +Pester: + OutputFormat: NUnitXML + ExcludeFromCodeCoverage: + Script: + - tests/Unit + - tests/Integration + ExcludeTag: + Tag: + CodeCoverageThreshold: 70 + +DscTest: + OutputFormat: NUnitXML + ExcludeTag: + - 'Common Tests - New Error-Level Script Analyzer Rules' + ExcludeSourceFile: + - output + +Resolve-Dependency: + Gallery: 'PSGallery' + AllowPrerelease: false + Verbose: false + +ModuleBuildTasks: + Sampler: + - '*.build.Sampler.ib.tasks' + +TaskHeader: | + param($Path) + "" + "=" * 79 + Write-Build Cyan "`t`t`t$($Task.Name.replace("_"," ").ToUpper())" + Write-Build DarkGray "$(Get-BuildSynopsis $Task)" + "-" * 79 + Write-Build DarkGray " $Path" + Write-Build DarkGray " $($Task.InvocationInfo.ScriptName):$($Task.InvocationInfo.ScriptLineNumber)" + "" + +GitHubConfig: + GitHubFilesToAdd: + - 'CHANGELOG.md' + GitHubConfigUserName: dscbot + GitHubConfigUserEmail: dsccommunity@outlook.com + UpdateChangelogOnPrerelease: false diff --git a/source/Build.psd1 b/source/Build.psd1 new file mode 100644 index 00000000..3009ed89 --- /dev/null +++ b/source/Build.psd1 @@ -0,0 +1,5 @@ +@{ + Path = 'ComputerManagementDsc.psd1' +} +# Waiting for ModuleBuilder to do away with this file +# when all parameters are provided to the function diff --git a/source/ComputerManagementDsc.psd1 b/source/ComputerManagementDsc.psd1 new file mode 100644 index 00000000..c773ee06 --- /dev/null +++ b/source/ComputerManagementDsc.psd1 @@ -0,0 +1,90 @@ +@{ + # Version number of this module. + moduleVersion = '0.0.1' + + # ID used to uniquely identify this module + GUID = 'B5004952-489E-43EA-999C-F16A25355B89' + + # Author of this module + Author = 'DSC Community' + + # Company or vendor of this module + CompanyName = 'DSC Community' + + # Copyright statement for this module + Copyright = 'Copyright the DSC Community contributors. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'DSC resources for configuration of a Windows computer. These DSC resources allow you to perform computer management tasks, such as renaming the computer, joining a domain and scheduling tasks as well as configuring items such as virtual memory, event logs, time zones and power settings.' + + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '4.0' + + # Minimum version of the common language runtime (CLR) required by this module + CLRVersion = '4.0' + + # 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 = @() + + # 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 = @() + + # DSC resources to export from this module + DscResourcesToExport = @( + 'Computer' + 'OfflineDomainJoin' + 'PendingReboot' + 'PowerPlan' + 'PowerShellExecutionPolicy' + 'RemoteDesktopAdmin' + 'ScheduledTask' + 'SmbServerConfiguration' + 'SmbShare' + 'SystemLocale' + 'TimeZone' + 'VirtualMemory' + 'WindowsEventLog' + 'WindowsCapability' + ) + + # 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 = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResource') + + # A URL to the license for this module. + LicenseUri = 'https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/dsccommunity/ComputerManagementDsc' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + ReleaseNotes = '' + + } # End of PSData hashtable + + } # End of PrivateData hashtable +} + + + + + + + + + + + diff --git a/DSCResources/MSFT_Computer/MSFT_Computer.psm1 b/source/DSCResources/MSFT_Computer/MSFT_Computer.psm1 similarity index 100% rename from DSCResources/MSFT_Computer/MSFT_Computer.psm1 rename to source/DSCResources/MSFT_Computer/MSFT_Computer.psm1 diff --git a/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof b/source/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof similarity index 100% rename from DSCResources/MSFT_Computer/MSFT_Computer.schema.mof rename to source/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof diff --git a/DSCResources/MSFT_Computer/README.md b/source/DSCResources/MSFT_Computer/README.md similarity index 100% rename from DSCResources/MSFT_Computer/README.md rename to source/DSCResources/MSFT_Computer/README.md diff --git a/DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 b/source/DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 similarity index 100% rename from DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 rename to source/DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 diff --git a/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 b/source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 similarity index 100% rename from DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 rename to source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 diff --git a/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof b/source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof similarity index 100% rename from DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof rename to source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof diff --git a/DSCResources/MSFT_OfflineDomainJoin/README.md b/source/DSCResources/MSFT_OfflineDomainJoin/README.md similarity index 100% rename from DSCResources/MSFT_OfflineDomainJoin/README.md rename to source/DSCResources/MSFT_OfflineDomainJoin/README.md diff --git a/DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 b/source/DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 similarity index 100% rename from DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 rename to source/DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 diff --git a/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.psm1 b/source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.psm1 similarity index 100% rename from DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.psm1 rename to source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.psm1 diff --git a/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.schema.mof b/source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.schema.mof similarity index 100% rename from DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.schema.mof rename to source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.schema.mof diff --git a/DSCResources/MSFT_PendingReboot/README.md b/source/DSCResources/MSFT_PendingReboot/README.md similarity index 100% rename from DSCResources/MSFT_PendingReboot/README.md rename to source/DSCResources/MSFT_PendingReboot/README.md diff --git a/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.data.psd1 b/source/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.data.psd1 similarity index 100% rename from DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.data.psd1 rename to source/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.data.psd1 diff --git a/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.strings.psd1 b/source/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.strings.psd1 similarity index 100% rename from DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.strings.psd1 rename to source/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.strings.psd1 diff --git a/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 b/source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 similarity index 100% rename from DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 rename to source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 diff --git a/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof b/source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof similarity index 100% rename from DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof rename to source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof diff --git a/DSCResources/MSFT_PowerPlan/README.md b/source/DSCResources/MSFT_PowerPlan/README.md similarity index 100% rename from DSCResources/MSFT_PowerPlan/README.md rename to source/DSCResources/MSFT_PowerPlan/README.md diff --git a/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl b/source/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl similarity index 100% rename from DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl rename to source/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl diff --git a/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 b/source/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 similarity index 100% rename from DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 rename to source/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 diff --git a/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 b/source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 similarity index 100% rename from DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 rename to source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 diff --git a/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof b/source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof similarity index 100% rename from DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof rename to source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof diff --git a/DSCResources/MSFT_PowerShellExecutionPolicy/README.md b/source/DSCResources/MSFT_PowerShellExecutionPolicy/README.md similarity index 100% rename from DSCResources/MSFT_PowerShellExecutionPolicy/README.md rename to source/DSCResources/MSFT_PowerShellExecutionPolicy/README.md diff --git a/DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 b/source/DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 similarity index 100% rename from DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 rename to source/DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 diff --git a/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.psm1 b/source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.psm1 similarity index 100% rename from DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.psm1 rename to source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.psm1 diff --git a/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.schema.mof b/source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.schema.mof similarity index 100% rename from DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.schema.mof rename to source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.schema.mof diff --git a/DSCResources/MSFT_RemoteDesktopAdmin/README.md b/source/DSCResources/MSFT_RemoteDesktopAdmin/README.md similarity index 100% rename from DSCResources/MSFT_RemoteDesktopAdmin/README.md rename to source/DSCResources/MSFT_RemoteDesktopAdmin/README.md diff --git a/DSCResources/MSFT_RemoteDesktopAdmin/en-US/MSFT_RemoteDesktopAdmin.strings.psd1 b/source/DSCResources/MSFT_RemoteDesktopAdmin/en-US/MSFT_RemoteDesktopAdmin.strings.psd1 similarity index 100% rename from DSCResources/MSFT_RemoteDesktopAdmin/en-US/MSFT_RemoteDesktopAdmin.strings.psd1 rename to source/DSCResources/MSFT_RemoteDesktopAdmin/en-US/MSFT_RemoteDesktopAdmin.strings.psd1 diff --git a/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 b/source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 similarity index 99% rename from DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 rename to source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 index a618dadc..290b69b5 100644 --- a/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 +++ b/source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 @@ -1456,7 +1456,7 @@ function Test-TargetResource <# All forms of whitespace is automatically trimmed from the description when it is set, so we must not compare it here. See issue #258: - https://github.com/PowerShell/ComputerManagementDsc/issues/258 + https://github.com/dsccommunity/ComputerManagementDsc/issues/258 #> $PSBoundParameters['Description'] = $PSBoundParameters.Description.Trim() } diff --git a/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof b/source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof similarity index 100% rename from DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof rename to source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof diff --git a/DSCResources/MSFT_ScheduledTask/README.md b/source/DSCResources/MSFT_ScheduledTask/README.md similarity index 100% rename from DSCResources/MSFT_ScheduledTask/README.md rename to source/DSCResources/MSFT_ScheduledTask/README.md diff --git a/DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 b/source/DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 similarity index 100% rename from DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 rename to source/DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 diff --git a/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.data.psd1 b/source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.data.psd1 similarity index 100% rename from DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.data.psd1 rename to source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.data.psd1 diff --git a/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.psm1 b/source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.psm1 similarity index 100% rename from DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.psm1 rename to source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.psm1 diff --git a/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.schema.mof b/source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.schema.mof similarity index 100% rename from DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.schema.mof rename to source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.schema.mof diff --git a/DSCResources/MSFT_SmbServerConfiguration/README.md b/source/DSCResources/MSFT_SmbServerConfiguration/README.md similarity index 100% rename from DSCResources/MSFT_SmbServerConfiguration/README.md rename to source/DSCResources/MSFT_SmbServerConfiguration/README.md diff --git a/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.schema.mfl b/source/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.schema.mfl similarity index 100% rename from DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.schema.mfl rename to source/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.schema.mfl diff --git a/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.strings.psd1 b/source/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.strings.psd1 rename to source/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.strings.psd1 diff --git a/DSCResources/MSFT_SmbShare/MSFT_SmbShare.psm1 b/source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.psm1 similarity index 100% rename from DSCResources/MSFT_SmbShare/MSFT_SmbShare.psm1 rename to source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.psm1 diff --git a/DSCResources/MSFT_SmbShare/MSFT_SmbShare.schema.mof b/source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.schema.mof similarity index 100% rename from DSCResources/MSFT_SmbShare/MSFT_SmbShare.schema.mof rename to source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.schema.mof diff --git a/DSCResources/MSFT_SmbShare/README.md b/source/DSCResources/MSFT_SmbShare/README.md similarity index 100% rename from DSCResources/MSFT_SmbShare/README.md rename to source/DSCResources/MSFT_SmbShare/README.md diff --git a/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.schema.mfl b/source/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.schema.mfl similarity index 100% rename from DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.schema.mfl rename to source/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.schema.mfl diff --git a/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.strings.psd1 b/source/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.strings.psd1 rename to source/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.strings.psd1 diff --git a/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.psm1 b/source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.psm1 similarity index 100% rename from DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.psm1 rename to source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.psm1 diff --git a/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.schema.mof b/source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.schema.mof similarity index 100% rename from DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.schema.mof rename to source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.schema.mof diff --git a/DSCResources/MSFT_SystemLocale/README.md b/source/DSCResources/MSFT_SystemLocale/README.md similarity index 100% rename from DSCResources/MSFT_SystemLocale/README.md rename to source/DSCResources/MSFT_SystemLocale/README.md diff --git a/DSCResources/MSFT_SystemLocale/en-US/MSFT_SystemLocale.strings.psd1 b/source/DSCResources/MSFT_SystemLocale/en-US/MSFT_SystemLocale.strings.psd1 similarity index 100% rename from DSCResources/MSFT_SystemLocale/en-US/MSFT_SystemLocale.strings.psd1 rename to source/DSCResources/MSFT_SystemLocale/en-US/MSFT_SystemLocale.strings.psd1 diff --git a/DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 b/source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 similarity index 100% rename from DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 rename to source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 diff --git a/DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof b/source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof similarity index 100% rename from DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof rename to source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof diff --git a/DSCResources/MSFT_TimeZone/README.md b/source/DSCResources/MSFT_TimeZone/README.md similarity index 100% rename from DSCResources/MSFT_TimeZone/README.md rename to source/DSCResources/MSFT_TimeZone/README.md diff --git a/DSCResources/MSFT_TimeZone/en-US/MSFT_TimeZone.strings.psd1 b/source/DSCResources/MSFT_TimeZone/en-US/MSFT_TimeZone.strings.psd1 similarity index 100% rename from DSCResources/MSFT_TimeZone/en-US/MSFT_TimeZone.strings.psd1 rename to source/DSCResources/MSFT_TimeZone/en-US/MSFT_TimeZone.strings.psd1 diff --git a/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 b/source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 similarity index 100% rename from DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 rename to source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 diff --git a/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof b/source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof similarity index 100% rename from DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof rename to source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof diff --git a/DSCResources/MSFT_VirtualMemory/README.md b/source/DSCResources/MSFT_VirtualMemory/README.md similarity index 100% rename from DSCResources/MSFT_VirtualMemory/README.md rename to source/DSCResources/MSFT_VirtualMemory/README.md diff --git a/DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 b/source/DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 similarity index 100% rename from DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 rename to source/DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 diff --git a/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.psm1 b/source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.psm1 similarity index 100% rename from DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.psm1 rename to source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.psm1 diff --git a/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.schema.mof b/source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.schema.mof similarity index 100% rename from DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.schema.mof rename to source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.schema.mof diff --git a/DSCResources/MSFT_WindowsCapability/README.md b/source/DSCResources/MSFT_WindowsCapability/README.md similarity index 100% rename from DSCResources/MSFT_WindowsCapability/README.md rename to source/DSCResources/MSFT_WindowsCapability/README.md diff --git a/DSCResources/MSFT_WindowsCapability/en-US/MSFT_WindowsCapability.strings.psd1 b/source/DSCResources/MSFT_WindowsCapability/en-US/MSFT_WindowsCapability.strings.psd1 similarity index 100% rename from DSCResources/MSFT_WindowsCapability/en-US/MSFT_WindowsCapability.strings.psd1 rename to source/DSCResources/MSFT_WindowsCapability/en-US/MSFT_WindowsCapability.strings.psd1 diff --git a/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 b/source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 similarity index 100% rename from DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 rename to source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 diff --git a/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof b/source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof similarity index 100% rename from DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof rename to source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof diff --git a/DSCResources/MSFT_WindowsEventLog/README.md b/source/DSCResources/MSFT_WindowsEventLog/README.md similarity index 100% rename from DSCResources/MSFT_WindowsEventLog/README.md rename to source/DSCResources/MSFT_WindowsEventLog/README.md diff --git a/DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 b/source/DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 similarity index 100% rename from DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 rename to source/DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 diff --git a/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 b/source/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 similarity index 73% rename from Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 rename to source/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 index b551ac12..9a1d0581 100644 --- a/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 +++ b/source/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 594bfeff-8e83-4cc4-8141-f3b39795c85b -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 b/source/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 similarity index 78% rename from Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 rename to source/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 index 57aafc02..748bd4c9 100644 --- a/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 +++ b/source/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID a8b9b735-a13d-4901-8edd-a2eb3a589183 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 b/source/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 similarity index 78% rename from Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 rename to source/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 index c26ea420..9f2bdb22 100644 --- a/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 +++ b/source/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 7e77ef8f-69ac-4e86-8a95-e38d3350118f -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 b/source/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 similarity index 70% rename from Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 rename to source/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 index 6d99e6bc..73519a98 100644 --- a/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 +++ b/source/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 7a5bc1c3-5229-48ec-9145-816d02e4544d -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 b/source/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 similarity index 78% rename from Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 rename to source/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 index 2d880fbc..b9c09ec7 100644 --- a/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 +++ b/source/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 9625caff-9065-4d04-9585-934998d81591 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 b/source/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 similarity index 71% rename from Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 rename to source/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 index 6a9c8d6d..96e733b4 100644 --- a/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 +++ b/source/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 315d9349-c340-4c6d-970e-8e5d2bb5b12b -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 b/source/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 similarity index 79% rename from Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 rename to source/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 index 0ef74f61..35165de1 100644 --- a/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 +++ b/source/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 5964d0b3-be15-455e-8233-4f655150de79 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 b/source/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 similarity index 72% rename from Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 rename to source/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 index cd7e208b..b53fd49b 100644 --- a/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 +++ b/source/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID fc143221-396c-4407-9aa8-c5878326e4ff -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/PendingReboot/1-PendingReboot_RebootAfterDomainJoin_Config.ps1 b/source/Examples/Resources/PendingReboot/1-PendingReboot_RebootAfterDomainJoin_Config.ps1 similarity index 80% rename from Examples/Resources/PendingReboot/1-PendingReboot_RebootAfterDomainJoin_Config.ps1 rename to source/Examples/Resources/PendingReboot/1-PendingReboot_RebootAfterDomainJoin_Config.ps1 index 3232643b..e90d670b 100644 --- a/Examples/Resources/PendingReboot/1-PendingReboot_RebootAfterDomainJoin_Config.ps1 +++ b/source/Examples/Resources/PendingReboot/1-PendingReboot_RebootAfterDomainJoin_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID ca17d716-4ded-4822-8f02-6363e9fa2c71 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/PendingReboot/2-PendingReboot_ConfigMgrReboot_Config.ps1 b/source/Examples/Resources/PendingReboot/2-PendingReboot_ConfigMgrReboot_Config.ps1 similarity index 81% rename from Examples/Resources/PendingReboot/2-PendingReboot_ConfigMgrReboot_Config.ps1 rename to source/Examples/Resources/PendingReboot/2-PendingReboot_ConfigMgrReboot_Config.ps1 index 111acb61..126590a5 100644 --- a/Examples/Resources/PendingReboot/2-PendingReboot_ConfigMgrReboot_Config.ps1 +++ b/source/Examples/Resources/PendingReboot/2-PendingReboot_ConfigMgrReboot_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 0d920405-2238-4ab5-871a-995e9baa0e28 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 b/source/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 similarity index 71% rename from Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 rename to source/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 index 9142e10f..bc8bb270 100644 --- a/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 +++ b/source/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 547354f3-f5d1-4c76-8988-72887938e852 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 b/source/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 similarity index 75% rename from Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 rename to source/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 index 316f5253..f0c5388d 100644 --- a/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 +++ b/source/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPolicy_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID d878a4e7-da0b-4099-b8e3-3442717b4c97 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 b/source/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 similarity index 80% rename from Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 rename to source/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 index c9f0bc58..779d2818 100644 --- a/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 +++ b/source/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPolicyForMultipleScopes_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 6900f247-5477-4821-9718-480f485db688 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/RemoteDesktopAdmin/1-RemoteDesktopAdmin_SetSecureRemoteDesktopAdmin_Config.ps1 b/source/Examples/Resources/RemoteDesktopAdmin/1-RemoteDesktopAdmin_SetSecureRemoteDesktopAdmin_Config.ps1 similarity index 75% rename from Examples/Resources/RemoteDesktopAdmin/1-RemoteDesktopAdmin_SetSecureRemoteDesktopAdmin_Config.ps1 rename to source/Examples/Resources/RemoteDesktopAdmin/1-RemoteDesktopAdmin_SetSecureRemoteDesktopAdmin_Config.ps1 index 6831d2d2..c9e8c4aa 100644 --- a/Examples/Resources/RemoteDesktopAdmin/1-RemoteDesktopAdmin_SetSecureRemoteDesktopAdmin_Config.ps1 +++ b/source/Examples/Resources/RemoteDesktopAdmin/1-RemoteDesktopAdmin_SetSecureRemoteDesktopAdmin_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID f177571b-c54b-46f2-9d55-903b794ecccd -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 b/source/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 similarity index 85% rename from Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 rename to source/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 index bf96ef2a..9a76c81f 100644 --- a/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 4310a6c2-9f34-4ebc-8895-feda5286e532 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 b/source/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 similarity index 84% rename from Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 rename to source/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 index 176d5ec0..74ade60e 100644 --- a/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 0323fac5-e026-4f41-a9be-9fdcd0967b60 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 b/source/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 similarity index 74% rename from Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 rename to source/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 index b2ee1706..48e956d3 100644 --- a/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID c3422e70-79ea-4afa-9558-1fcbe18dd0bd -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 b/source/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 similarity index 74% rename from Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 rename to source/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 index 4b322f27..d7c36520 100644 --- a/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 8bed07fe-c88f-4a22-bdd8-8ec95cf8739b -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 b/source/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 similarity index 85% rename from Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 rename to source/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 index 4f690ffd..b3ed2de4 100644 --- a/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID cff7293a-5b43-491c-9628-d6eca35c8bfd -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 b/source/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 similarity index 84% rename from Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 rename to source/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 index 6924e46d..cbb5c99f 100644 --- a/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID cc614ca9-5994-48fb-9528-46107b3eea91 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 b/source/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 similarity index 83% rename from Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 rename to source/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 index 3ebe8e0d..dc8fcb08 100644 --- a/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID ee32fb99-4150-4616-a46c-d2132ffb5205 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 b/source/Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 similarity index 84% rename from Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 rename to source/Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 index 627a1e43..a051e24c 100644 --- a/Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/16-ScheduledTask_CreateScheduledTasksAsBuiltInServiceAccount_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID a2984c97-f4fc-4936-b5d7-f8ccf726744f -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 b/source/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 similarity index 85% rename from Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 rename to source/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 index 6ba8a35c..54cfd4d5 100644 --- a/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID ce544d27-c44f-44d9-a771-1ae9b22b180c -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 b/source/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 similarity index 81% rename from Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 rename to source/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 index 047bb1dc..f240b533 100644 --- a/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID ae57d854-a9ae-4b3b-808d-3f23423beb29 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 b/source/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 similarity index 84% rename from Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 rename to source/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 index 5e7b5112..4b25015b 100644 --- a/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 8817eedf-02f5-4477-8b2d-55fa73f33902 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 b/source/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 similarity index 80% rename from Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 rename to source/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 index f436230f..d4d6441c 100644 --- a/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 282cba27-4cf3-43b8-86f2-f6ef0f8b4489 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 b/source/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 similarity index 80% rename from Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 rename to source/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 index dd786617..9dfd20a8 100644 --- a/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID d5cfbf76-5123-48bb-a856-5ea44504b4eb -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 b/source/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 similarity index 80% rename from Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 rename to source/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 index 3f095da9..a54ae12d 100644 --- a/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 6a249767-c480-453f-9e10-1ed7ef465d87 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 b/source/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 similarity index 80% rename from Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 rename to source/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 index 7cb24823..d36dc4df 100644 --- a/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID dffe47fd-73f7-47d2-8604-f381e6c18f26 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 b/source/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 similarity index 84% rename from Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 rename to source/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 index 81b67a47..fb8e6224 100644 --- a/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 +++ b/source/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 718e81fa-c553-4715-8f5d-734fb8a02204 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_AllProperties_Config.ps1 b/source/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_AllProperties_Config.ps1 similarity index 91% rename from Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_AllProperties_Config.ps1 rename to source/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_AllProperties_Config.ps1 index 63fdced8..d1ed7045 100644 --- a/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_AllProperties_Config.ps1 +++ b/source/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_AllProperties_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 4a847e98-a3f9-4552-8654-6c7006ef25cf -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/c/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_DisableSmb1_Config.ps1 b/source/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_DisableSmb1_Config.ps1 similarity index 73% rename from Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_DisableSmb1_Config.ps1 rename to source/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_DisableSmb1_Config.ps1 index 087668a0..b26312be 100644 --- a/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_DisableSmb1_Config.ps1 +++ b/source/Examples/Resources/SmbServerConfiguration/1-SmbServerConfiguration_DisableSmb1_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID e1ed9aff-7171-425b-a513-6965662816d8 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/SmbShare/1-SmbShare_CreateShare_Config.ps1 b/source/Examples/Resources/SmbShare/1-SmbShare_CreateShare_Config.ps1 similarity index 74% rename from Examples/Resources/SmbShare/1-SmbShare_CreateShare_Config.ps1 rename to source/Examples/Resources/SmbShare/1-SmbShare_CreateShare_Config.ps1 index 47154bb7..b042687f 100644 --- a/Examples/Resources/SmbShare/1-SmbShare_CreateShare_Config.ps1 +++ b/source/Examples/Resources/SmbShare/1-SmbShare_CreateShare_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID d0847694-6a83-4f5b-bf6f-30cb078033bc -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/SmbShare/2-SmbShare_CreateShareAllProperties_Config.ps1 b/source/Examples/Resources/SmbShare/2-SmbShare_CreateShareAllProperties_Config.ps1 similarity index 82% rename from Examples/Resources/SmbShare/2-SmbShare_CreateShareAllProperties_Config.ps1 rename to source/Examples/Resources/SmbShare/2-SmbShare_CreateShareAllProperties_Config.ps1 index 3afe5d23..2c5b2522 100644 --- a/Examples/Resources/SmbShare/2-SmbShare_CreateShareAllProperties_Config.ps1 +++ b/source/Examples/Resources/SmbShare/2-SmbShare_CreateShareAllProperties_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 27cc4f2a-e366-49cb-93d6-2f094567ebf3 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/SmbShare/3-SmbShare_RemoveShare_Config.ps1 b/source/Examples/Resources/SmbShare/3-SmbShare_RemoveShare_Config.ps1 similarity index 73% rename from Examples/Resources/SmbShare/3-SmbShare_RemoveShare_Config.ps1 rename to source/Examples/Resources/SmbShare/3-SmbShare_RemoveShare_Config.ps1 index a2e26eb3..7b465390 100644 --- a/Examples/Resources/SmbShare/3-SmbShare_RemoveShare_Config.ps1 +++ b/source/Examples/Resources/SmbShare/3-SmbShare_RemoveShare_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID f11d7558-0748-4a72-b743-34424cbf4407 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/c/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/SmbShare/4-SmbShare_RecreateShare_Config.ps1 b/source/Examples/Resources/SmbShare/4-SmbShare_RecreateShare_Config.ps1 similarity index 78% rename from Examples/Resources/SmbShare/4-SmbShare_RecreateShare_Config.ps1 rename to source/Examples/Resources/SmbShare/4-SmbShare_RecreateShare_Config.ps1 index 2ce8974a..0ef20cb2 100644 --- a/Examples/Resources/SmbShare/4-SmbShare_RecreateShare_Config.ps1 +++ b/source/Examples/Resources/SmbShare/4-SmbShare_RecreateShare_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID ea641782-74b4-4673-94fe-336cbd196c16 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/SystemLocale/1-SystemLocale_SetSystemLocale_Config.ps1 b/source/Examples/Resources/SystemLocale/1-SystemLocale_SetSystemLocale_Config.ps1 similarity index 75% rename from Examples/Resources/SystemLocale/1-SystemLocale_SetSystemLocale_Config.ps1 rename to source/Examples/Resources/SystemLocale/1-SystemLocale_SetSystemLocale_Config.ps1 index 5a478bb1..4e487da2 100644 --- a/Examples/Resources/SystemLocale/1-SystemLocale_SetSystemLocale_Config.ps1 +++ b/source/Examples/Resources/SystemLocale/1-SystemLocale_SetSystemLocale_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 66476d02-bd04-4d5d-ac49-d64724716f41 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 b/source/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 similarity index 71% rename from Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 rename to source/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 index 184f1a82..096a2892 100644 --- a/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 +++ b/source/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID d39a7d09-4baa-44d2-bcb4-b37ae3f2e16b -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 b/source/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 similarity index 73% rename from Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 rename to source/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 index 3b178a11..d88e9139 100644 --- a/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 +++ b/source/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 8ea6bdd3-8822-4e6e-9957-d8576a45c55a -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/WindowsCapability/1-WindowsCapability_AddWindowsCapability_Config.ps1 b/source/Examples/Resources/WindowsCapability/1-WindowsCapability_AddWindowsCapability_Config.ps1 similarity index 71% rename from Examples/Resources/WindowsCapability/1-WindowsCapability_AddWindowsCapability_Config.ps1 rename to source/Examples/Resources/WindowsCapability/1-WindowsCapability_AddWindowsCapability_Config.ps1 index d59b4a44..d154a920 100644 --- a/Examples/Resources/WindowsCapability/1-WindowsCapability_AddWindowsCapability_Config.ps1 +++ b/source/Examples/Resources/WindowsCapability/1-WindowsCapability_AddWindowsCapability_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID adade795-9143-4f4a-ae2d-4e31e81029a2 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/WindowsCapability/2-WindowsCapability_RemoveWindowsCapability_Config.ps1 b/source/Examples/Resources/WindowsCapability/2-WindowsCapability_RemoveWindowsCapability_Config.ps1 similarity index 71% rename from Examples/Resources/WindowsCapability/2-WindowsCapability_RemoveWindowsCapability_Config.ps1 rename to source/Examples/Resources/WindowsCapability/2-WindowsCapability_RemoveWindowsCapability_Config.ps1 index ea140253..492d6851 100644 --- a/Examples/Resources/WindowsCapability/2-WindowsCapability_RemoveWindowsCapability_Config.ps1 +++ b/source/Examples/Resources/WindowsCapability/2-WindowsCapability_RemoveWindowsCapability_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 87cc15cc-113a-410a-acad-7333768d648b -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/WindowsCapability/3-WindowsCapability_AddWindowsCapabilitywithLogLevelandLogPath_Config.ps1 b/source/Examples/Resources/WindowsCapability/3-WindowsCapability_AddWindowsCapabilitywithLogLevelandLogPath_Config.ps1 similarity index 76% rename from Examples/Resources/WindowsCapability/3-WindowsCapability_AddWindowsCapabilitywithLogLevelandLogPath_Config.ps1 rename to source/Examples/Resources/WindowsCapability/3-WindowsCapability_AddWindowsCapabilitywithLogLevelandLogPath_Config.ps1 index c44fcec0..e288efcd 100644 --- a/Examples/Resources/WindowsCapability/3-WindowsCapability_AddWindowsCapabilitywithLogLevelandLogPath_Config.ps1 +++ b/source/Examples/Resources/WindowsCapability/3-WindowsCapability_AddWindowsCapabilitywithLogLevelandLogPath_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID c966b525-2764-461e-b48e-b9f479c86a64 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 b/source/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 similarity index 77% rename from Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 rename to source/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 index d481b56b..5690f4b4 100644 --- a/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 +++ b/source/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID f8fb71fd-9f4a-4ae5-93b8-53362752e37d -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 b/source/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 similarity index 79% rename from Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 rename to source/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 index 7c437c81..338ae385 100644 --- a/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 +++ b/source/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 5e3f845c-58ce-4e46-baaf-2422d30176ca -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 b/source/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 similarity index 79% rename from Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 rename to source/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 index ddd51c02..4a2d01ec 100644 --- a/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 +++ b/source/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID f05286e4-e357-40f8-ba62-e49d4d50eb0f -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 b/source/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 similarity index 77% rename from Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 rename to source/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 index 135dd66d..792a8818 100644 --- a/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 +++ b/source/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 1e24ee07-cb2f-489b-af15-ebf6ffa864fe -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 b/source/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 similarity index 80% rename from Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 rename to source/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 index 003835d4..0f8c89ee 100644 --- a/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 +++ b/source/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 07323d21-39a0-4f62-bed7-7acc943f9234 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 b/source/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 similarity index 74% rename from Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 rename to source/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 index 61ee8b5f..1004de27 100644 --- a/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 +++ b/source/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 @@ -1,12 +1,12 @@ <#PSScriptInfo .VERSION 1.0.0 .GUID 1d426e51-df3b-4723-96ac-e7d790744f69 -.AUTHOR Microsoft Corporation -.COMPANYNAME Microsoft Corporation -.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.AUTHOR DSC Community +.COMPANYNAME DSC Community +.COPYRIGHT Copyright the DSC Community contributors. All rights reserved. .TAGS DSCConfiguration -.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE -.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.LICENSEURI https://github.com/dsccommunity/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/dsccommunity/ComputerManagementDsc .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS diff --git a/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 b/source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 similarity index 100% rename from Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 rename to source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 diff --git a/Modules/ComputerManagementDsc.Common/SetTimeZone.cs b/source/Modules/ComputerManagementDsc.Common/SetTimeZone.cs similarity index 100% rename from Modules/ComputerManagementDsc.Common/SetTimeZone.cs rename to source/Modules/ComputerManagementDsc.Common/SetTimeZone.cs diff --git a/Modules/ComputerManagementDsc.Common/en-US/ComputerManagementDsc.Common.strings.psd1 b/source/Modules/ComputerManagementDsc.Common/en-US/ComputerManagementDsc.Common.strings.psd1 similarity index 100% rename from Modules/ComputerManagementDsc.Common/en-US/ComputerManagementDsc.Common.strings.psd1 rename to source/Modules/ComputerManagementDsc.Common/en-US/ComputerManagementDsc.Common.strings.psd1 diff --git a/source/en-US/about_ComputerManagementDsc.help.txt b/source/en-US/about_ComputerManagementDsc.help.txt new file mode 100644 index 00000000..71a4fcbc --- /dev/null +++ b/source/en-US/about_ComputerManagementDsc.help.txt @@ -0,0 +1,34 @@ +TOPIC + about_ComputerManagementDsc + +SHORT DESCRIPTION + DSC resources for configuration of a Windows computer. These DSC resources + allow you to perform computer management tasks, such as renaming the computer, + joining a domain and scheduling tasks as well as configuring items such as + virtual memory, event logs, time zones and power settings. + +LONG DESCRIPTION + This module contains DSC resources for configuration of a Windows computer. + These DSC resources allow you to perform computer management tasks, such as + renaming the computer, joining a domain and scheduling tasks as well as + configuring items such as virtual memory, event logs, time zones and power + settings. + +EXAMPLES + PS C:\> Get-DscResource -Module ComputerManagementDsc + +NOTE: + Thank you to the DSC Community contributors who contributed to this module by + writing code, sharing opinions, and provided feedback. + +TROUBLESHOOTING NOTE: + Go to the Github repository for read about issues, submit a new issue, and read + about new releases. https://github.com/dsccommunity/ComputerManagementDsc + +SEE ALSO + - https://github.com/dsccommunity/ComputerManagementDsc + +KEYWORDS + DSC, DscResource, Computer, OfflineDomainJoin, PendingReboot, PowerPlan, + PowerShellExecutionPolicy, RemoteDesktopAdmin, ScheduledTask, SmbServerConfiguration + SmbShare, SystemLocale, TimeZone, VirtualMemory, WindowsEventLog, WindowsCapability From 4f0945e902da4e94accff006c7c18ab02d6b0423 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 19:52:30 +1300 Subject: [PATCH 02/30] Rename tests folder --- .../Integration/ComputerManagementDsc.Common.Tests.ps1 | 0 {Tests => tests}/Integration/MSFT_PendingReboot.Config.ps1 | 0 {Tests => tests}/Integration/MSFT_PendingReboot.Tests.ps1 | 0 .../MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 | 0 .../Integration/MSFT_PowerShellExecutionPolicy.config.ps1 | 0 {Tests => tests}/Integration/MSFT_RemoteDesktopAdmin.Config.ps1 | 0 .../Integration/MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 | 0 {Tests => tests}/Integration/MSFT_ScheduledTask.Config.ps1 | 0 .../Integration/MSFT_ScheduledTask.Integration.Tests.ps1 | 0 .../Integration/MSFT_SmbServerConfiguration.Config.ps1 | 0 .../Integration/MSFT_SmbServerConfiguration.Tests.ps1 | 0 {Tests => tests}/Integration/MSFT_SmbShare.Integration.Tests.ps1 | 0 {Tests => tests}/Integration/MSFT_SmbShare.config.ps1 | 0 .../Integration/MSFT_SystemLocale.Integration.Tests.ps1 | 0 {Tests => tests}/Integration/MSFT_SystemLocale.config.ps1 | 0 {Tests => tests}/Integration/MSFT_TimeZone.Integration.Tests.ps1 | 0 {Tests => tests}/Integration/MSFT_TimeZone.config.ps1 | 0 {Tests => tests}/Integration/MSFT_VirtualMemory.Config.ps1 | 0 .../Integration/MSFT_VirtualMemory.Integration.Tests.ps1 | 0 {Tests => tests}/Integration/MSFT_WindowsCapability.Config.ps1 | 0 .../Integration/MSFT_WindowsCapability.Integration.Tests.ps1 | 0 .../Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 | 0 {Tests => tests}/Integration/MSFT_WindowsEventLog.config.ps1 | 0 {Tests => tests}/TestHelpers/CommonTestHelper.psm1 | 0 {Tests => tests}/Unit/ComputerManagementDsc.Common.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_Computer.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_OfflineDomainJoin.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_PendingReboot.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_PowerPlan.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_RemoteDesktopAdmin.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_ScheduledTask.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_SmbServerConfiguration.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_SmbShare.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_SystemLocale.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_TimeZone.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_VirtualMemory.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_WindowsCapability.Tests.ps1 | 0 {Tests => tests}/Unit/MSFT_WindowsEventLog.Tests.ps1 | 0 39 files changed, 0 insertions(+), 0 deletions(-) rename {Tests => tests}/Integration/ComputerManagementDsc.Common.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_PendingReboot.Config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_PendingReboot.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_PowerShellExecutionPolicy.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_RemoteDesktopAdmin.Config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_ScheduledTask.Config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SmbServerConfiguration.Config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SmbServerConfiguration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SmbShare.Integration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SmbShare.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SystemLocale.Integration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_SystemLocale.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_TimeZone.Integration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_TimeZone.config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_VirtualMemory.Config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_WindowsCapability.Config.ps1 (100%) rename {Tests => tests}/Integration/MSFT_WindowsCapability.Integration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 (100%) rename {Tests => tests}/Integration/MSFT_WindowsEventLog.config.ps1 (100%) rename {Tests => tests}/TestHelpers/CommonTestHelper.psm1 (100%) rename {Tests => tests}/Unit/ComputerManagementDsc.Common.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_Computer.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_OfflineDomainJoin.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_PendingReboot.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_PowerPlan.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_RemoteDesktopAdmin.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_ScheduledTask.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_SmbServerConfiguration.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_SmbShare.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_SystemLocale.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_TimeZone.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_VirtualMemory.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_WindowsCapability.Tests.ps1 (100%) rename {Tests => tests}/Unit/MSFT_WindowsEventLog.Tests.ps1 (100%) diff --git a/Tests/Integration/ComputerManagementDsc.Common.Tests.ps1 b/tests/Integration/ComputerManagementDsc.Common.Tests.ps1 similarity index 100% rename from Tests/Integration/ComputerManagementDsc.Common.Tests.ps1 rename to tests/Integration/ComputerManagementDsc.Common.Tests.ps1 diff --git a/Tests/Integration/MSFT_PendingReboot.Config.ps1 b/tests/Integration/MSFT_PendingReboot.Config.ps1 similarity index 100% rename from Tests/Integration/MSFT_PendingReboot.Config.ps1 rename to tests/Integration/MSFT_PendingReboot.Config.ps1 diff --git a/Tests/Integration/MSFT_PendingReboot.Tests.ps1 b/tests/Integration/MSFT_PendingReboot.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_PendingReboot.Tests.ps1 rename to tests/Integration/MSFT_PendingReboot.Tests.ps1 diff --git a/Tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 b/tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 rename to tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 diff --git a/Tests/Integration/MSFT_PowerShellExecutionPolicy.config.ps1 b/tests/Integration/MSFT_PowerShellExecutionPolicy.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_PowerShellExecutionPolicy.config.ps1 rename to tests/Integration/MSFT_PowerShellExecutionPolicy.config.ps1 diff --git a/Tests/Integration/MSFT_RemoteDesktopAdmin.Config.ps1 b/tests/Integration/MSFT_RemoteDesktopAdmin.Config.ps1 similarity index 100% rename from Tests/Integration/MSFT_RemoteDesktopAdmin.Config.ps1 rename to tests/Integration/MSFT_RemoteDesktopAdmin.Config.ps1 diff --git a/Tests/Integration/MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 b/tests/Integration/MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 rename to tests/Integration/MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 diff --git a/Tests/Integration/MSFT_ScheduledTask.Config.ps1 b/tests/Integration/MSFT_ScheduledTask.Config.ps1 similarity index 100% rename from Tests/Integration/MSFT_ScheduledTask.Config.ps1 rename to tests/Integration/MSFT_ScheduledTask.Config.ps1 diff --git a/Tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 b/tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 rename to tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 diff --git a/Tests/Integration/MSFT_SmbServerConfiguration.Config.ps1 b/tests/Integration/MSFT_SmbServerConfiguration.Config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SmbServerConfiguration.Config.ps1 rename to tests/Integration/MSFT_SmbServerConfiguration.Config.ps1 diff --git a/Tests/Integration/MSFT_SmbServerConfiguration.Tests.ps1 b/tests/Integration/MSFT_SmbServerConfiguration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_SmbServerConfiguration.Tests.ps1 rename to tests/Integration/MSFT_SmbServerConfiguration.Tests.ps1 diff --git a/Tests/Integration/MSFT_SmbShare.Integration.Tests.ps1 b/tests/Integration/MSFT_SmbShare.Integration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_SmbShare.Integration.Tests.ps1 rename to tests/Integration/MSFT_SmbShare.Integration.Tests.ps1 diff --git a/Tests/Integration/MSFT_SmbShare.config.ps1 b/tests/Integration/MSFT_SmbShare.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SmbShare.config.ps1 rename to tests/Integration/MSFT_SmbShare.config.ps1 diff --git a/Tests/Integration/MSFT_SystemLocale.Integration.Tests.ps1 b/tests/Integration/MSFT_SystemLocale.Integration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_SystemLocale.Integration.Tests.ps1 rename to tests/Integration/MSFT_SystemLocale.Integration.Tests.ps1 diff --git a/Tests/Integration/MSFT_SystemLocale.config.ps1 b/tests/Integration/MSFT_SystemLocale.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_SystemLocale.config.ps1 rename to tests/Integration/MSFT_SystemLocale.config.ps1 diff --git a/Tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 b/tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 rename to tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 diff --git a/Tests/Integration/MSFT_TimeZone.config.ps1 b/tests/Integration/MSFT_TimeZone.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_TimeZone.config.ps1 rename to tests/Integration/MSFT_TimeZone.config.ps1 diff --git a/Tests/Integration/MSFT_VirtualMemory.Config.ps1 b/tests/Integration/MSFT_VirtualMemory.Config.ps1 similarity index 100% rename from Tests/Integration/MSFT_VirtualMemory.Config.ps1 rename to tests/Integration/MSFT_VirtualMemory.Config.ps1 diff --git a/Tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 b/tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 rename to tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 diff --git a/Tests/Integration/MSFT_WindowsCapability.Config.ps1 b/tests/Integration/MSFT_WindowsCapability.Config.ps1 similarity index 100% rename from Tests/Integration/MSFT_WindowsCapability.Config.ps1 rename to tests/Integration/MSFT_WindowsCapability.Config.ps1 diff --git a/Tests/Integration/MSFT_WindowsCapability.Integration.Tests.ps1 b/tests/Integration/MSFT_WindowsCapability.Integration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_WindowsCapability.Integration.Tests.ps1 rename to tests/Integration/MSFT_WindowsCapability.Integration.Tests.ps1 diff --git a/Tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 b/tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 similarity index 100% rename from Tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 rename to tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 diff --git a/Tests/Integration/MSFT_WindowsEventLog.config.ps1 b/tests/Integration/MSFT_WindowsEventLog.config.ps1 similarity index 100% rename from Tests/Integration/MSFT_WindowsEventLog.config.ps1 rename to tests/Integration/MSFT_WindowsEventLog.config.ps1 diff --git a/Tests/TestHelpers/CommonTestHelper.psm1 b/tests/TestHelpers/CommonTestHelper.psm1 similarity index 100% rename from Tests/TestHelpers/CommonTestHelper.psm1 rename to tests/TestHelpers/CommonTestHelper.psm1 diff --git a/Tests/Unit/ComputerManagementDsc.Common.Tests.ps1 b/tests/Unit/ComputerManagementDsc.Common.Tests.ps1 similarity index 100% rename from Tests/Unit/ComputerManagementDsc.Common.Tests.ps1 rename to tests/Unit/ComputerManagementDsc.Common.Tests.ps1 diff --git a/Tests/Unit/MSFT_Computer.Tests.ps1 b/tests/Unit/MSFT_Computer.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_Computer.Tests.ps1 rename to tests/Unit/MSFT_Computer.Tests.ps1 diff --git a/Tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 b/tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 rename to tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 diff --git a/Tests/Unit/MSFT_PendingReboot.Tests.ps1 b/tests/Unit/MSFT_PendingReboot.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_PendingReboot.Tests.ps1 rename to tests/Unit/MSFT_PendingReboot.Tests.ps1 diff --git a/Tests/Unit/MSFT_PowerPlan.Tests.ps1 b/tests/Unit/MSFT_PowerPlan.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_PowerPlan.Tests.ps1 rename to tests/Unit/MSFT_PowerPlan.Tests.ps1 diff --git a/Tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 b/tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 rename to tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 diff --git a/Tests/Unit/MSFT_RemoteDesktopAdmin.Tests.ps1 b/tests/Unit/MSFT_RemoteDesktopAdmin.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_RemoteDesktopAdmin.Tests.ps1 rename to tests/Unit/MSFT_RemoteDesktopAdmin.Tests.ps1 diff --git a/Tests/Unit/MSFT_ScheduledTask.Tests.ps1 b/tests/Unit/MSFT_ScheduledTask.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_ScheduledTask.Tests.ps1 rename to tests/Unit/MSFT_ScheduledTask.Tests.ps1 diff --git a/Tests/Unit/MSFT_SmbServerConfiguration.Tests.ps1 b/tests/Unit/MSFT_SmbServerConfiguration.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_SmbServerConfiguration.Tests.ps1 rename to tests/Unit/MSFT_SmbServerConfiguration.Tests.ps1 diff --git a/Tests/Unit/MSFT_SmbShare.Tests.ps1 b/tests/Unit/MSFT_SmbShare.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_SmbShare.Tests.ps1 rename to tests/Unit/MSFT_SmbShare.Tests.ps1 diff --git a/Tests/Unit/MSFT_SystemLocale.Tests.ps1 b/tests/Unit/MSFT_SystemLocale.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_SystemLocale.Tests.ps1 rename to tests/Unit/MSFT_SystemLocale.Tests.ps1 diff --git a/Tests/Unit/MSFT_TimeZone.Tests.ps1 b/tests/Unit/MSFT_TimeZone.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_TimeZone.Tests.ps1 rename to tests/Unit/MSFT_TimeZone.Tests.ps1 diff --git a/Tests/Unit/MSFT_VirtualMemory.Tests.ps1 b/tests/Unit/MSFT_VirtualMemory.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_VirtualMemory.Tests.ps1 rename to tests/Unit/MSFT_VirtualMemory.Tests.ps1 diff --git a/Tests/Unit/MSFT_WindowsCapability.Tests.ps1 b/tests/Unit/MSFT_WindowsCapability.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_WindowsCapability.Tests.ps1 rename to tests/Unit/MSFT_WindowsCapability.Tests.ps1 diff --git a/Tests/Unit/MSFT_WindowsEventLog.Tests.ps1 b/tests/Unit/MSFT_WindowsEventLog.Tests.ps1 similarity index 100% rename from Tests/Unit/MSFT_WindowsEventLog.Tests.ps1 rename to tests/Unit/MSFT_WindowsEventLog.Tests.ps1 From 7b26d9d3540e45fbdd5a21bb7fb55862a27ccd02 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 20:14:14 +1300 Subject: [PATCH 03/30] Update 2 to move to new CIprocess --- HISTORIC_CHANGELOG.md | 8 +- source/ComputerManagementDsc.psd1 | 17 +- .../DSC_Computer.psm1} | 34 +- .../DSC_Computer.schema.mof} | 2 +- .../{MSFT_Computer => DSC_Computer}/README.md | 0 .../en-US/DSC_Computer.strings.psd1} | 0 .../DSC_OfflineDomainJoin.psm1} | 2 +- .../DSC_OfflineDomainJoin.schema.mof} | 2 +- .../README.md | 0 .../en-US/DSC_OfflineDomainJoin.strings.psd1} | 0 .../DSC_PendingReboot.psm1} | 4 +- .../DSC_PendingReboot.schema.mof} | 2 +- .../README.md | 0 .../en-US/DSC_PendingReboot.data.psd1} | 0 .../en-US/DSC_PendingReboot.strings.psd1} | 0 .../DSC_PowerPlan.psm1} | 2 +- .../DSC_PowerPlan.schema.mof} | 2 +- .../README.md | 0 .../en-US/DSC_PowerPlan.schema.mfl} | 2 +- .../en-US/DSC_PowerPlan.strings.psd1} | 0 .../DSC_PowerShellExecutionPolicy.psm1} | 2 +- .../DSC_PowerShellExecutionPolicy.schema.mof} | 2 +- .../README.md | 0 ...SC_PowerShellExecutionPolicy.strings.psd1} | 0 .../DSC_RemoteDesktopAdmin.psm1} | 2 +- .../DSC_RemoteDesktopAdmin.schema.mof} | 2 +- .../README.md | 0 .../DSC_RemoteDesktopAdmin.strings.psd1} | 0 .../DSC_ScheduledTask.psm1} | 2 +- .../DSC_ScheduledTask.schema.mof} | 2 +- .../README.md | 0 .../en-US/DSC_ScheduledTask.strings.psd1} | 0 .../DSC_SmbServerConfiguration.data.psd1} | 0 .../DSC_SmbServerConfiguration.psm1} | 4 +- .../DSC_SmbServerConfiguration.schema.mof} | 2 +- .../README.md | 0 .../DSC_SmbServerConfiguration.schema.mfl} | 2 +- .../DSC_SmbServerConfiguration.strings.psd1} | 0 .../DSC_SmbShare.psm1} | 2 +- .../DSC_SmbShare.schema.mof} | 2 +- .../{MSFT_SmbShare => DSC_SmbShare}/README.md | 0 .../en-US/DSC_SmbShare.schema.mfl} | 2 +- .../en-US/DSC_SmbShare.strings.psd1} | 0 .../DSC_SystemLocale.psm1} | 2 +- .../DSC_SystemLocale.schema.mof} | 2 +- .../README.md | 0 .../en-US/DSC_SystemLocale.strings.psd1} | 0 .../DSC_TimeZone.psm1} | 2 +- .../DSC_TimeZone.schema.mof} | 2 +- .../{MSFT_TimeZone => DSC_TimeZone}/README.md | 0 .../en-US/DSC_TimeZone.strings.psd1} | 0 .../DSC_VirtualMemory.psm1} | 2 +- .../DSC_VirtualMemory.schema.mof} | 2 +- .../README.md | 0 .../en-US/DSC_VirtualMemory.strings.psd1} | 0 .../DSC_WindowsCapability.psm1} | 2 +- .../DSC_WindowsCapability.schema.mof} | 2 +- .../README.md | 0 .../en-US/DSC_WindowsCapability.strings.psd1} | 0 .../DSC_WindowsEventLog.psm1} | 2 +- .../DSC_WindowsEventLog.schema.mof} | 2 +- .../README.md | 0 .../en-US/DSC_WindowsEventLog.strings.psd1} | 0 .../ComputerManagementDsc.Common.psm1 | 6 +- ...onfig.ps1 => DSC_PendingReboot.Config.ps1} | 2 +- ....Tests.ps1 => DSC_PendingReboot.Tests.ps1} | 2 +- ...hellExecutionPolicy.Integration.Tests.ps1} | 2 +- ... DSC_PowerShellExecutionPolicy.config.ps1} | 2 +- ....ps1 => DSC_RemoteDesktopAdmin.Config.ps1} | 0 ..._RemoteDesktopAdmin.Integration.Tests.ps1} | 2 +- ...onfig.ps1 => DSC_ScheduledTask.Config.ps1} | 0 ...> DSC_ScheduledTask.Integration.Tests.ps1} | 2 +- ... => DSC_SmbServerConfiguration.Config.ps1} | 2 +- ...1 => DSC_SmbServerConfiguration.Tests.ps1} | 2 +- ...ps1 => DSC_SmbShare.Integration.Tests.ps1} | 4 +- ...are.config.ps1 => DSC_SmbShare.config.ps1} | 18 +- ...=> DSC_SystemLocale.Integration.Tests.ps1} | 2 +- ...config.ps1 => DSC_SystemLocale.config.ps1} | 2 +- ...ps1 => DSC_TimeZone.Integration.Tests.ps1} | 2 +- ...one.config.ps1 => DSC_TimeZone.config.ps1} | 2 +- ...onfig.ps1 => DSC_VirtualMemory.Config.ps1} | 0 ...> DSC_VirtualMemory.Integration.Tests.ps1} | 2 +- ...g.ps1 => DSC_WindowsCapability.Config.ps1} | 2 +- ...C_WindowsCapability.Integration.Tests.ps1} | 2 +- ...DSC_WindowsEventLog.Integration.Tests.ps1} | 22 +- ...fig.ps1 => DSC_WindowsEventLog.config.ps1} | 18 +- .../ComputerManagementDsc.Common.Tests.ps1 | 2618 ++++++++--------- ...puter.Tests.ps1 => DSC_Computer.Tests.ps1} | 4 +- ...ts.ps1 => DSC_OfflineDomainJoin.Tests.ps1} | 4 +- ....Tests.ps1 => DSC_PendingReboot.Tests.ps1} | 54 +- ...Plan.Tests.ps1 => DSC_PowerPlan.Tests.ps1} | 2 +- ...> DSC_PowerShellExecutionpolicy.Tests.ps1} | 4 +- ...s.ps1 => DSC_RemoteDesktopAdmin.Tests.ps1} | 8 +- ....Tests.ps1 => DSC_ScheduledTask.Tests.ps1} | 6 +- ...1 => DSC_SmbServerConfiguration.Tests.ps1} | 8 +- ...Share.Tests.ps1 => DSC_SmbShare.Tests.ps1} | 14 +- ...e.Tests.ps1 => DSC_SystemLocale.Tests.ps1} | 10 +- ...eZone.Tests.ps1 => DSC_TimeZone.Tests.ps1} | 4 +- ....Tests.ps1 => DSC_VirtualMemory.Tests.ps1} | 18 +- ...ts.ps1 => DSC_WindowsCapability.Tests.ps1} | 24 +- ...ests.ps1 => DSC_WindowsEventLog.Tests.ps1} | 4 +- 101 files changed, 1494 insertions(+), 1509 deletions(-) rename source/DSCResources/{MSFT_Computer/MSFT_Computer.psm1 => DSC_Computer/DSC_Computer.psm1} (95%) rename source/DSCResources/{MSFT_Computer/MSFT_Computer.schema.mof => DSC_Computer/DSC_Computer.schema.mof} (96%) rename source/DSCResources/{MSFT_Computer => DSC_Computer}/README.md (100%) rename source/DSCResources/{MSFT_Computer/en-US/MSFT_Computer.strings.psd1 => DSC_Computer/en-US/DSC_Computer.strings.psd1} (100%) rename source/DSCResources/{MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 => DSC_OfflineDomainJoin/DSC_OfflineDomainJoin.psm1} (98%) rename source/DSCResources/{MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof => DSC_OfflineDomainJoin/DSC_OfflineDomainJoin.schema.mof} (87%) rename source/DSCResources/{MSFT_OfflineDomainJoin => DSC_OfflineDomainJoin}/README.md (100%) rename source/DSCResources/{MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 => DSC_OfflineDomainJoin/en-US/DSC_OfflineDomainJoin.strings.psd1} (100%) rename source/DSCResources/{MSFT_PendingReboot/MSFT_PendingReboot.psm1 => DSC_PendingReboot/DSC_PendingReboot.psm1} (98%) rename source/DSCResources/{MSFT_PendingReboot/MSFT_PendingReboot.schema.mof => DSC_PendingReboot/DSC_PendingReboot.schema.mof} (97%) rename source/DSCResources/{MSFT_PendingReboot => DSC_PendingReboot}/README.md (100%) rename source/DSCResources/{MSFT_PendingReboot/en-US/MSFT_PendingReboot.data.psd1 => DSC_PendingReboot/en-US/DSC_PendingReboot.data.psd1} (100%) rename source/DSCResources/{MSFT_PendingReboot/en-US/MSFT_PendingReboot.strings.psd1 => DSC_PendingReboot/en-US/DSC_PendingReboot.strings.psd1} (100%) rename source/DSCResources/{MSFT_PowerPlan/MSFT_PowerPlan.psm1 => DSC_PowerPlan/DSC_PowerPlan.psm1} (98%) rename source/DSCResources/{MSFT_PowerPlan/MSFT_PowerPlan.schema.mof => DSC_PowerPlan/DSC_PowerPlan.schema.mof} (90%) rename source/DSCResources/{MSFT_PowerPlan => DSC_PowerPlan}/README.md (100%) rename source/DSCResources/{MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl => DSC_PowerPlan/en-US/DSC_PowerPlan.schema.mfl} (89%) rename source/DSCResources/{MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 => DSC_PowerPlan/en-US/DSC_PowerPlan.strings.psd1} (100%) rename source/DSCResources/{MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 => DSC_PowerShellExecutionPolicy/DSC_PowerShellExecutionPolicy.psm1} (97%) rename source/DSCResources/{MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof => DSC_PowerShellExecutionPolicy/DSC_PowerShellExecutionPolicy.schema.mof} (91%) rename source/DSCResources/{MSFT_PowerShellExecutionPolicy => DSC_PowerShellExecutionPolicy}/README.md (100%) rename source/DSCResources/{MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 => DSC_PowerShellExecutionPolicy/en-US/DSC_PowerShellExecutionPolicy.strings.psd1} (100%) rename source/DSCResources/{MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.psm1 => DSC_RemoteDesktopAdmin/DSC_RemoteDesktopAdmin.psm1} (98%) rename source/DSCResources/{MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.schema.mof => DSC_RemoteDesktopAdmin/DSC_RemoteDesktopAdmin.schema.mof} (93%) rename source/DSCResources/{MSFT_RemoteDesktopAdmin => DSC_RemoteDesktopAdmin}/README.md (100%) rename source/DSCResources/{MSFT_RemoteDesktopAdmin/en-US/MSFT_RemoteDesktopAdmin.strings.psd1 => DSC_RemoteDesktopAdmin/en-US/DSC_RemoteDesktopAdmin.strings.psd1} (100%) rename source/DSCResources/{MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 => DSC_ScheduledTask/DSC_ScheduledTask.psm1} (99%) rename source/DSCResources/{MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof => DSC_ScheduledTask/DSC_ScheduledTask.schema.mof} (99%) rename source/DSCResources/{MSFT_ScheduledTask => DSC_ScheduledTask}/README.md (100%) rename source/DSCResources/{MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 => DSC_ScheduledTask/en-US/DSC_ScheduledTask.strings.psd1} (100%) rename source/DSCResources/{MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.data.psd1 => DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.data.psd1} (100%) rename source/DSCResources/{MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.psm1 => DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.psm1} (99%) rename source/DSCResources/{MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.schema.mof => DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.schema.mof} (98%) rename source/DSCResources/{MSFT_SmbServerConfiguration => DSC_SmbServerConfiguration}/README.md (100%) rename source/DSCResources/{MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.schema.mfl => DSC_SmbServerConfiguration/en-US/DSC_SmbServerConfiguration.schema.mfl} (98%) rename source/DSCResources/{MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.strings.psd1 => DSC_SmbServerConfiguration/en-US/DSC_SmbServerConfiguration.strings.psd1} (100%) rename source/DSCResources/{MSFT_SmbShare/MSFT_SmbShare.psm1 => DSC_SmbShare/DSC_SmbShare.psm1} (99%) rename source/DSCResources/{MSFT_SmbShare/MSFT_SmbShare.schema.mof => DSC_SmbShare/DSC_SmbShare.schema.mof} (98%) rename source/DSCResources/{MSFT_SmbShare => DSC_SmbShare}/README.md (100%) rename source/DSCResources/{MSFT_SmbShare/en-US/MSFT_SmbShare.schema.mfl => DSC_SmbShare/en-US/DSC_SmbShare.schema.mfl} (98%) rename source/DSCResources/{MSFT_SmbShare/en-US/MSFT_SmbShare.strings.psd1 => DSC_SmbShare/en-US/DSC_SmbShare.strings.psd1} (100%) rename source/DSCResources/{MSFT_SystemLocale/MSFT_SystemLocale.psm1 => DSC_SystemLocale/DSC_SystemLocale.psm1} (98%) rename source/DSCResources/{MSFT_SystemLocale/MSFT_SystemLocale.schema.mof => DSC_SystemLocale/DSC_SystemLocale.schema.mof} (87%) rename source/DSCResources/{MSFT_SystemLocale => DSC_SystemLocale}/README.md (100%) rename source/DSCResources/{MSFT_SystemLocale/en-US/MSFT_SystemLocale.strings.psd1 => DSC_SystemLocale/en-US/DSC_SystemLocale.strings.psd1} (100%) rename source/DSCResources/{MSFT_TimeZone/MSFT_TimeZone.psm1 => DSC_TimeZone/DSC_TimeZone.psm1} (97%) rename source/DSCResources/{MSFT_TimeZone/MSFT_TimeZone.schema.mof => DSC_TimeZone/DSC_TimeZone.schema.mof} (87%) rename source/DSCResources/{MSFT_TimeZone => DSC_TimeZone}/README.md (100%) rename source/DSCResources/{MSFT_TimeZone/en-US/MSFT_TimeZone.strings.psd1 => DSC_TimeZone/en-US/DSC_TimeZone.strings.psd1} (100%) rename source/DSCResources/{MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 => DSC_VirtualMemory/DSC_VirtualMemory.psm1} (99%) rename source/DSCResources/{MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof => DSC_VirtualMemory/DSC_VirtualMemory.schema.mof} (94%) rename source/DSCResources/{MSFT_VirtualMemory => DSC_VirtualMemory}/README.md (100%) rename source/DSCResources/{MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 => DSC_VirtualMemory/en-US/DSC_VirtualMemory.strings.psd1} (100%) rename source/DSCResources/{MSFT_WindowsCapability/MSFT_WindowsCapability.psm1 => DSC_WindowsCapability/DSC_WindowsCapability.psm1} (98%) rename source/DSCResources/{MSFT_WindowsCapability/MSFT_WindowsCapability.schema.mof => DSC_WindowsCapability/DSC_WindowsCapability.schema.mof} (93%) rename source/DSCResources/{MSFT_WindowsCapability => DSC_WindowsCapability}/README.md (100%) rename source/DSCResources/{MSFT_WindowsCapability/en-US/MSFT_WindowsCapability.strings.psd1 => DSC_WindowsCapability/en-US/DSC_WindowsCapability.strings.psd1} (100%) rename source/DSCResources/{MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 => DSC_WindowsEventLog/DSC_WindowsEventLog.psm1} (99%) rename source/DSCResources/{MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof => DSC_WindowsEventLog/DSC_WindowsEventLog.schema.mof} (95%) rename source/DSCResources/{MSFT_WindowsEventLog => DSC_WindowsEventLog}/README.md (100%) rename source/DSCResources/{MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 => DSC_WindowsEventLog/en-US/DSC_WindowsEventLog.strings.psd1} (100%) rename tests/Integration/{MSFT_PendingReboot.Config.ps1 => DSC_PendingReboot.Config.ps1} (93%) rename tests/Integration/{MSFT_PendingReboot.Tests.ps1 => DSC_PendingReboot.Tests.ps1} (99%) rename tests/Integration/{MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 => DSC_PowerShellExecutionPolicy.Integration.Tests.ps1} (97%) rename tests/Integration/{MSFT_PowerShellExecutionPolicy.config.ps1 => DSC_PowerShellExecutionPolicy.config.ps1} (85%) rename tests/Integration/{MSFT_RemoteDesktopAdmin.Config.ps1 => DSC_RemoteDesktopAdmin.Config.ps1} (100%) rename tests/Integration/{MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 => DSC_RemoteDesktopAdmin.Integration.Tests.ps1} (99%) rename tests/Integration/{MSFT_ScheduledTask.Config.ps1 => DSC_ScheduledTask.Config.ps1} (100%) rename tests/Integration/{MSFT_ScheduledTask.Integration.Tests.ps1 => DSC_ScheduledTask.Integration.Tests.ps1} (99%) rename tests/Integration/{MSFT_SmbServerConfiguration.Config.ps1 => DSC_SmbServerConfiguration.Config.ps1} (98%) rename tests/Integration/{MSFT_SmbServerConfiguration.Tests.ps1 => DSC_SmbServerConfiguration.Tests.ps1} (99%) rename tests/Integration/{MSFT_SmbShare.Integration.Tests.ps1 => DSC_SmbShare.Integration.Tests.ps1} (99%) rename tests/Integration/{MSFT_SmbShare.config.ps1 => DSC_SmbShare.config.ps1} (94%) rename tests/Integration/{MSFT_SystemLocale.Integration.Tests.ps1 => DSC_SystemLocale.Integration.Tests.ps1} (98%) rename tests/Integration/{MSFT_SystemLocale.config.ps1 => DSC_SystemLocale.config.ps1} (85%) rename tests/Integration/{MSFT_TimeZone.Integration.Tests.ps1 => DSC_TimeZone.Integration.Tests.ps1} (98%) rename tests/Integration/{MSFT_TimeZone.config.ps1 => DSC_TimeZone.config.ps1} (86%) rename tests/Integration/{MSFT_VirtualMemory.Config.ps1 => DSC_VirtualMemory.Config.ps1} (100%) rename tests/Integration/{MSFT_VirtualMemory.Integration.Tests.ps1 => DSC_VirtualMemory.Integration.Tests.ps1} (99%) rename tests/Integration/{MSFT_WindowsCapability.Config.ps1 => DSC_WindowsCapability.Config.ps1} (89%) rename tests/Integration/{MSFT_WindowsCapability.Integration.Tests.ps1 => DSC_WindowsCapability.Integration.Tests.ps1} (99%) rename tests/Integration/{MSFT_WindowsEventLog.Integration.Tests.ps1 => DSC_WindowsEventLog.Integration.Tests.ps1} (94%) rename tests/Integration/{MSFT_WindowsEventLog.config.ps1 => DSC_WindowsEventLog.config.ps1} (88%) rename tests/Unit/{MSFT_Computer.Tests.ps1 => DSC_Computer.Tests.ps1} (99%) rename tests/Unit/{MSFT_OfflineDomainJoin.Tests.ps1 => DSC_OfflineDomainJoin.Tests.ps1} (98%) rename tests/Unit/{MSFT_PendingReboot.Tests.ps1 => DSC_PendingReboot.Tests.ps1} (94%) rename tests/Unit/{MSFT_PowerPlan.Tests.ps1 => DSC_PowerPlan.Tests.ps1} (99%) rename tests/Unit/{MSFT_PowerShellExecutionpolicy.Tests.ps1 => DSC_PowerShellExecutionpolicy.Tests.ps1} (98%) rename tests/Unit/{MSFT_RemoteDesktopAdmin.Tests.ps1 => DSC_RemoteDesktopAdmin.Tests.ps1} (97%) rename tests/Unit/{MSFT_ScheduledTask.Tests.ps1 => DSC_ScheduledTask.Tests.ps1} (99%) rename tests/Unit/{MSFT_SmbServerConfiguration.Tests.ps1 => DSC_SmbServerConfiguration.Tests.ps1} (98%) rename tests/Unit/{MSFT_SmbShare.Tests.ps1 => DSC_SmbShare.Tests.ps1} (99%) rename tests/Unit/{MSFT_SystemLocale.Tests.ps1 => DSC_SystemLocale.Tests.ps1} (94%) rename tests/Unit/{MSFT_TimeZone.Tests.ps1 => DSC_TimeZone.Tests.ps1} (98%) rename tests/Unit/{MSFT_VirtualMemory.Tests.ps1 => DSC_VirtualMemory.Tests.ps1} (98%) rename tests/Unit/{MSFT_WindowsCapability.Tests.ps1 => DSC_WindowsCapability.Tests.ps1} (93%) rename tests/Unit/{MSFT_WindowsEventLog.Tests.ps1 => DSC_WindowsEventLog.Tests.ps1} (99%) diff --git a/HISTORIC_CHANGELOG.md b/HISTORIC_CHANGELOG.md index a32e349b..08edee21 100644 --- a/HISTORIC_CHANGELOG.md +++ b/HISTORIC_CHANGELOG.md @@ -189,7 +189,7 @@ change log short. - Migrated the xPowershellExecutionPolicy from [xPowershellExecutionPolicy](https://github.com/PowerShell/xPowerShellExecutionPolicy) and renamed to PowershellExecutionPolicy. - Moved strings to localization file. -- Changed the scope from Global to Script in MSFT_ScheduledTask.Integration.Tests.ps1 +- Changed the scope from Global to Script in DSC_ScheduledTask.Integration.Tests.ps1 - Changed the scope from Global to Script ComputerManagementDsc.Common.Tests.ps1 - ScheduledTask: - Added support for event based triggers, implemented using the ScheduleType OnEvent @@ -395,10 +395,10 @@ change log short. ### Changed - Added the following resources: - - MSFT_xOfflineDomainJoin resource to join computers to an AD Domain using an + - DSC_xOfflineDomainJoin resource to join computers to an AD Domain using an Offline Domain Join request file. - - MSFT_xScheduledTask resource to control scheduled tasks on the local server -- MSFT_xOfflineDomainJoin: Corrected localizedData.DomainAlreadyJoinedhMessage name. + - DSC_xScheduledTask resource to control scheduled tasks on the local server +- DSC_xOfflineDomainJoin: Corrected localizedData.DomainAlreadyJoinedhMessage name. - xComputer: Changed credential generation code in tests to avoid triggering PSSA rule PSAvoidUsingConvertToSecureStringWithPlainText. Renamed unit test file to match the name of Resource file. diff --git a/source/ComputerManagementDsc.psd1 b/source/ComputerManagementDsc.psd1 index c773ee06..5f88f3d0 100644 --- a/source/ComputerManagementDsc.psd1 +++ b/source/ComputerManagementDsc.psd1 @@ -57,6 +57,8 @@ PrivateData = @{ PSData = @{ + # Set to a prerelease string value if the release should be a prerelease. + Prerelease = '' # Tags applied to this module. These help with module discovery in online galleries. Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResource') @@ -68,23 +70,10 @@ ProjectUri = 'https://github.com/dsccommunity/ComputerManagementDsc' # A URL to an icon representing this module. - # IconUri = '' + IconUri = 'https://dsccommunity.org/images/DSC_Logo_300p.png' # ReleaseNotes of this module ReleaseNotes = '' - } # End of PSData hashtable - } # End of PrivateData hashtable } - - - - - - - - - - - diff --git a/source/DSCResources/MSFT_Computer/MSFT_Computer.psm1 b/source/DSCResources/DSC_Computer/DSC_Computer.psm1 similarity index 95% rename from source/DSCResources/MSFT_Computer/MSFT_Computer.psm1 rename to source/DSCResources/DSC_Computer/DSC_Computer.psm1 index 19b973af..4ad282ee 100644 --- a/source/DSCResources/MSFT_Computer/MSFT_Computer.psm1 +++ b/source/DSCResources/DSC_Computer/DSC_Computer.psm1 @@ -11,7 +11,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_Computer' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_Computer' $FailToRenameAfterJoinDomainErrorId = 'FailToRenameAfterJoinDomain,Microsoft.PowerShell.Commands.AddComputerCommand' @@ -52,7 +52,7 @@ function Get-TargetResource ( [Parameter(Mandatory = $true)] [ValidateLength(1, 15)] - [ValidateScript( {$_ -inotmatch '[\/\\:*?"<>|]' })] + [ValidateScript( { $_ -inotmatch '[\/\\:*?"<>|]' })] [System.String] $Name, @@ -88,20 +88,20 @@ function Get-TargetResource Write-Verbose -Message ($script:localizedData.GettingComputerStateMessage -f $Name) $convertToCimCredential = New-CimInstance ` - -ClassName MSFT_Credential ` + -ClassName DSC_Credential ` -Property @{ - Username = [System.String] $Credential.UserName - Password = [System.String] $null - } ` + Username = [System.String] $Credential.UserName + Password = [System.String] $null + } ` -Namespace root/microsoft/windows/desiredstateconfiguration ` -ClientOnly $convertToCimUnjoinCredential = New-CimInstance ` - -ClassName MSFT_Credential ` + -ClassName DSC_Credential ` -Property @{ - Username = [System.String] $UnjoinCredential.UserName - Password = [System.String] $null - } ` + Username = [System.String] $UnjoinCredential.UserName + Password = [System.String] $null + } ` -Namespace root/microsoft/windows/desiredstateconfiguration ` -ClientOnly @@ -156,7 +156,7 @@ function Set-TargetResource ( [Parameter(Mandatory = $true)] [ValidateLength(1, 15)] - [ValidateScript( {$_ -inotmatch '[\/\\:*?"<>|]' })] + [ValidateScript( { $_ -inotmatch '[\/\\:*?"<>|]' })] [System.String] $Name, @@ -221,7 +221,7 @@ function Set-TargetResource $addComputerParameters = @{ DomainName = $DomainName Credential = $Credential - Force = $true + Force = $true } $rename = $false if ($Name -ne $env:COMPUTERNAME) @@ -275,7 +275,7 @@ function Set-TargetResource if ($rename) { - Write-Verbose -Message ($script:localizedData.RenamedComputerAndJoinedDomainMessage -f $Name,$DomainName) + Write-Verbose -Message ($script:localizedData.RenamedComputerAndJoinedDomainMessage -f $Name, $DomainName) } else { @@ -304,7 +304,7 @@ function Set-TargetResource -WorkgroupName $WorkGroupName ` -Force - Write-Verbose -Message ($script:localizedData.RenamedComputerAndJoinedWorkgroupMessage -f $Name,$WorkGroupName) + Write-Verbose -Message ($script:localizedData.RenamedComputerAndJoinedWorkgroupMessage -f $Name, $WorkGroupName) } else { @@ -368,7 +368,7 @@ function Set-TargetResource -WorkgroupName $WorkGroupName ` -NewName $Name - Write-Verbose -Message ($script:localizedData.RenamedComputerAndJoinedWorkgroupMessage -f $Name,$WorkGroupName) + Write-Verbose -Message ($script:localizedData.RenamedComputerAndJoinedWorkgroupMessage -f $Name, $WorkGroupName) } else { @@ -429,7 +429,7 @@ function Test-TargetResource ( [Parameter(Mandatory = $true)] [ValidateLength(1, 15)] - [ValidateScript( {$_ -inotmatch '[\/\\:*?"<>|]' })] + [ValidateScript( { $_ -inotmatch '[\/\\:*?"<>|]' })] [System.String] $Name, @@ -641,7 +641,7 @@ function Get-LogonServer [OutputType([System.String])] param () - $logonserver = $env:LOGONSERVER -replace "\\","" + $logonserver = $env:LOGONSERVER -replace "\\", "" return $logonserver } diff --git a/source/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof b/source/DSCResources/DSC_Computer/DSC_Computer.schema.mof similarity index 96% rename from source/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof rename to source/DSCResources/DSC_Computer/DSC_Computer.schema.mof index bcf895ac..96eae764 100644 --- a/source/DSCResources/MSFT_Computer/MSFT_Computer.schema.mof +++ b/source/DSCResources/DSC_Computer/DSC_Computer.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.1.0"), FriendlyName("Computer")] -class MSFT_Computer : OMI_BaseResource +class DSC_Computer : OMI_BaseResource { [Key, Description("The desired computer name.")] String Name; [Write, Description("The name of the domain to join.")] String DomainName; diff --git a/source/DSCResources/MSFT_Computer/README.md b/source/DSCResources/DSC_Computer/README.md similarity index 100% rename from source/DSCResources/MSFT_Computer/README.md rename to source/DSCResources/DSC_Computer/README.md diff --git a/source/DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 b/source/DSCResources/DSC_Computer/en-US/DSC_Computer.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_Computer/en-US/MSFT_Computer.strings.psd1 rename to source/DSCResources/DSC_Computer/en-US/DSC_Computer.strings.psd1 diff --git a/source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 b/source/DSCResources/DSC_OfflineDomainJoin/DSC_OfflineDomainJoin.psm1 similarity index 98% rename from source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 rename to source/DSCResources/DSC_OfflineDomainJoin/DSC_OfflineDomainJoin.psm1 index 70579054..4000af22 100644 --- a/source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.psm1 +++ b/source/DSCResources/DSC_OfflineDomainJoin/DSC_OfflineDomainJoin.psm1 @@ -11,7 +11,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_OfflineDomainJoin' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_OfflineDomainJoin' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof b/source/DSCResources/DSC_OfflineDomainJoin/DSC_OfflineDomainJoin.schema.mof similarity index 87% rename from source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof rename to source/DSCResources/DSC_OfflineDomainJoin/DSC_OfflineDomainJoin.schema.mof index 4301693c..787469c6 100644 --- a/source/DSCResources/MSFT_OfflineDomainJoin/MSFT_OfflineDomainJoin.schema.mof +++ b/source/DSCResources/DSC_OfflineDomainJoin/DSC_OfflineDomainJoin.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("OfflineDomainJoin")] -class MSFT_OfflineDomainJoin : OMI_BaseResource +class DSC_OfflineDomainJoin : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'."), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Required, Description("The full path to the Offline Domain Join Request file to use.")] String RequestFile; diff --git a/source/DSCResources/MSFT_OfflineDomainJoin/README.md b/source/DSCResources/DSC_OfflineDomainJoin/README.md similarity index 100% rename from source/DSCResources/MSFT_OfflineDomainJoin/README.md rename to source/DSCResources/DSC_OfflineDomainJoin/README.md diff --git a/source/DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 b/source/DSCResources/DSC_OfflineDomainJoin/en-US/DSC_OfflineDomainJoin.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_OfflineDomainJoin/en-US/MSFT_OfflineDomainJoin.strings.psd1 rename to source/DSCResources/DSC_OfflineDomainJoin/en-US/DSC_OfflineDomainJoin.strings.psd1 diff --git a/source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.psm1 b/source/DSCResources/DSC_PendingReboot/DSC_PendingReboot.psm1 similarity index 98% rename from source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.psm1 rename to source/DSCResources/DSC_PendingReboot/DSC_PendingReboot.psm1 index 77582d3e..8436157b 100644 --- a/source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.psm1 +++ b/source/DSCResources/DSC_PendingReboot/DSC_PendingReboot.psm1 @@ -9,7 +9,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_PendingReboot' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_PendingReboot' <# This data file contains a list of reboot triggers that will be checked @@ -17,7 +17,7 @@ $script:localizedData = Get-LocalizedData -ResourceName 'MSFT_PendingReboot' data file so that it can also be used in testing. #> $script:localizedResourceData = Get-LocalizedData ` - -ResourceName 'MSFT_PendingReboot' ` + -ResourceName 'DSC_PendingReboot' ` -Postfix 'data' $script:rebootTriggers = $script:localizedResourceData.RebootTriggers <# diff --git a/source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.schema.mof b/source/DSCResources/DSC_PendingReboot/DSC_PendingReboot.schema.mof similarity index 97% rename from source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.schema.mof rename to source/DSCResources/DSC_PendingReboot/DSC_PendingReboot.schema.mof index db815172..f11e51f9 100644 --- a/source/DSCResources/MSFT_PendingReboot/MSFT_PendingReboot.schema.mof +++ b/source/DSCResources/DSC_PendingReboot/DSC_PendingReboot.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("PendingReboot")] -class MSFT_PendingReboot : OMI_BaseResource +class DSC_PendingReboot : OMI_BaseResource { [Key, Description("Specifies the name of this pending reboot check.")] String Name; [Write, Description("Specifies whether to skip reboots triggered by the Component-Based Servicing component.")] Boolean SkipComponentBasedServicing; diff --git a/source/DSCResources/MSFT_PendingReboot/README.md b/source/DSCResources/DSC_PendingReboot/README.md similarity index 100% rename from source/DSCResources/MSFT_PendingReboot/README.md rename to source/DSCResources/DSC_PendingReboot/README.md diff --git a/source/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.data.psd1 b/source/DSCResources/DSC_PendingReboot/en-US/DSC_PendingReboot.data.psd1 similarity index 100% rename from source/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.data.psd1 rename to source/DSCResources/DSC_PendingReboot/en-US/DSC_PendingReboot.data.psd1 diff --git a/source/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.strings.psd1 b/source/DSCResources/DSC_PendingReboot/en-US/DSC_PendingReboot.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_PendingReboot/en-US/MSFT_PendingReboot.strings.psd1 rename to source/DSCResources/DSC_PendingReboot/en-US/DSC_PendingReboot.strings.psd1 diff --git a/source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 b/source/DSCResources/DSC_PowerPlan/DSC_PowerPlan.psm1 similarity index 98% rename from source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 rename to source/DSCResources/DSC_PowerPlan/DSC_PowerPlan.psm1 index 580e7941..f6cc17f8 100644 --- a/source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.psm1 +++ b/source/DSCResources/DSC_PowerPlan/DSC_PowerPlan.psm1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_PowerPlan' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_PowerPlan' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof b/source/DSCResources/DSC_PowerPlan/DSC_PowerPlan.schema.mof similarity index 90% rename from source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof rename to source/DSCResources/DSC_PowerPlan/DSC_PowerPlan.schema.mof index 41820d6f..f8f0a62b 100644 --- a/source/DSCResources/MSFT_PowerPlan/MSFT_PowerPlan.schema.mof +++ b/source/DSCResources/DSC_PowerPlan/DSC_PowerPlan.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("PowerPlan")] -class MSFT_PowerPlan : OMI_BaseResource +class DSC_PowerPlan : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'."), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Required, Description("The name or GUID of the power plan to activate.")] String Name; diff --git a/source/DSCResources/MSFT_PowerPlan/README.md b/source/DSCResources/DSC_PowerPlan/README.md similarity index 100% rename from source/DSCResources/MSFT_PowerPlan/README.md rename to source/DSCResources/DSC_PowerPlan/README.md diff --git a/source/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl b/source/DSCResources/DSC_PowerPlan/en-US/DSC_PowerPlan.schema.mfl similarity index 89% rename from source/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl rename to source/DSCResources/DSC_PowerPlan/en-US/DSC_PowerPlan.schema.mfl index 3b208b85..6cd3ff22 100644 --- a/source/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.schema.mfl +++ b/source/DSCResources/DSC_PowerPlan/en-US/DSC_PowerPlan.schema.mfl @@ -1,5 +1,5 @@ [Description("This resource is used to activate a power plan.") : Amended,AMENDMENT, LOCALE("MS_409")] -class MSFT_PowerPlan : OMI_BaseResource +class DSC_PowerPlan : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'.") : Amended] String IsSingleInstance; [Description("The name or GUID of the power plan to activate.") : Amended] String Name; diff --git a/source/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 b/source/DSCResources/DSC_PowerPlan/en-US/DSC_PowerPlan.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_PowerPlan/en-US/MSFT_PowerPlan.strings.psd1 rename to source/DSCResources/DSC_PowerPlan/en-US/DSC_PowerPlan.strings.psd1 diff --git a/source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 b/source/DSCResources/DSC_PowerShellExecutionPolicy/DSC_PowerShellExecutionPolicy.psm1 similarity index 97% rename from source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 rename to source/DSCResources/DSC_PowerShellExecutionPolicy/DSC_PowerShellExecutionPolicy.psm1 index 3dd45a19..1bbb6a8b 100644 --- a/source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.psm1 +++ b/source/DSCResources/DSC_PowerShellExecutionPolicy/DSC_PowerShellExecutionPolicy.psm1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_PowershellExecutionPolicy' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_PowershellExecutionPolicy' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof b/source/DSCResources/DSC_PowerShellExecutionPolicy/DSC_PowerShellExecutionPolicy.schema.mof similarity index 91% rename from source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof rename to source/DSCResources/DSC_PowerShellExecutionPolicy/DSC_PowerShellExecutionPolicy.schema.mof index 4c6c6d28..f0a9cef6 100644 --- a/source/DSCResources/MSFT_PowerShellExecutionPolicy/MSFT_PowerShellExecutionPolicy.schema.mof +++ b/source/DSCResources/DSC_PowerShellExecutionPolicy/DSC_PowerShellExecutionPolicy.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("PowerShellExecutionPolicy")] -class MSFT_PowerShellExecutionPolicy : OMI_BaseResource +class DSC_PowerShellExecutionPolicy : OMI_BaseResource { [Key, Description("Defines the scope for the preference of the Windows PowerShell execution policy."), ValueMap{"CurrentUser","LocalMachine","MachinePolicy","Process","UserPolicy"},Values{"CurrentUser","LocalMachine","MachinePolicy","Process","UserPolicy"}] String ExecutionPolicyScope; [Required, Description("Changes the preference for the Windows PowerShell execution policy."), ValueMap{"Bypass","Restricted","AllSigned","RemoteSigned","Unrestricted"}, Values{"Bypass","Restricted","AllSigned","RemoteSigned","Unrestricted"}] String ExecutionPolicy; diff --git a/source/DSCResources/MSFT_PowerShellExecutionPolicy/README.md b/source/DSCResources/DSC_PowerShellExecutionPolicy/README.md similarity index 100% rename from source/DSCResources/MSFT_PowerShellExecutionPolicy/README.md rename to source/DSCResources/DSC_PowerShellExecutionPolicy/README.md diff --git a/source/DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 b/source/DSCResources/DSC_PowerShellExecutionPolicy/en-US/DSC_PowerShellExecutionPolicy.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_PowerShellExecutionPolicy/en-US/MSFT_PowerShellExecutionPolicy.strings.psd1 rename to source/DSCResources/DSC_PowerShellExecutionPolicy/en-US/DSC_PowerShellExecutionPolicy.strings.psd1 diff --git a/source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.psm1 b/source/DSCResources/DSC_RemoteDesktopAdmin/DSC_RemoteDesktopAdmin.psm1 similarity index 98% rename from source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.psm1 rename to source/DSCResources/DSC_RemoteDesktopAdmin/DSC_RemoteDesktopAdmin.psm1 index 68214c58..078d6a27 100644 --- a/source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.psm1 +++ b/source/DSCResources/DSC_RemoteDesktopAdmin/DSC_RemoteDesktopAdmin.psm1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_RemoteDesktopAdmin' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_RemoteDesktopAdmin' $script:tSRegistryKey = 'HKLM:\System\CurrentControlSet\Control\Terminal Server' $script:winStationsRegistryKey = 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' diff --git a/source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.schema.mof b/source/DSCResources/DSC_RemoteDesktopAdmin/DSC_RemoteDesktopAdmin.schema.mof similarity index 93% rename from source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.schema.mof rename to source/DSCResources/DSC_RemoteDesktopAdmin/DSC_RemoteDesktopAdmin.schema.mof index d79c8eb1..6b2bac1e 100644 --- a/source/DSCResources/MSFT_RemoteDesktopAdmin/MSFT_RemoteDesktopAdmin.schema.mof +++ b/source/DSCResources/DSC_RemoteDesktopAdmin/DSC_RemoteDesktopAdmin.schema.mof @@ -1,6 +1,6 @@ [ClassVersion("1.0.0.0"), FriendlyName("RemoteDesktopAdmin")] -class MSFT_RemoteDesktopAdmin : OMI_BaseResource +class DSC_RemoteDesktopAdmin : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Write, Description("Determines whether or not the computer should accept remote desktop connections. Present sets the value to Enabled and Absent sets the value to Disabled."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; diff --git a/source/DSCResources/MSFT_RemoteDesktopAdmin/README.md b/source/DSCResources/DSC_RemoteDesktopAdmin/README.md similarity index 100% rename from source/DSCResources/MSFT_RemoteDesktopAdmin/README.md rename to source/DSCResources/DSC_RemoteDesktopAdmin/README.md diff --git a/source/DSCResources/MSFT_RemoteDesktopAdmin/en-US/MSFT_RemoteDesktopAdmin.strings.psd1 b/source/DSCResources/DSC_RemoteDesktopAdmin/en-US/DSC_RemoteDesktopAdmin.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_RemoteDesktopAdmin/en-US/MSFT_RemoteDesktopAdmin.strings.psd1 rename to source/DSCResources/DSC_RemoteDesktopAdmin/en-US/DSC_RemoteDesktopAdmin.strings.psd1 diff --git a/source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 b/source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.psm1 similarity index 99% rename from source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 rename to source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.psm1 index 290b69b5..60969b6b 100644 --- a/source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.psm1 +++ b/source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.psm1 @@ -22,7 +22,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ScheduledTask' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_ScheduledTask' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof b/source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.schema.mof similarity index 99% rename from source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof rename to source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.schema.mof index 1ae7465f..6583b6b9 100644 --- a/source/DSCResources/MSFT_ScheduledTask/MSFT_ScheduledTask.schema.mof +++ b/source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("ScheduledTask")] -class MSFT_ScheduledTask : OMI_BaseResource +class DSC_ScheduledTask : OMI_BaseResource { [Key, Description("The name of the task.")] string TaskName; [Write, Description("The path to the task - defaults to the root directory.")] string TaskPath; diff --git a/source/DSCResources/MSFT_ScheduledTask/README.md b/source/DSCResources/DSC_ScheduledTask/README.md similarity index 100% rename from source/DSCResources/MSFT_ScheduledTask/README.md rename to source/DSCResources/DSC_ScheduledTask/README.md diff --git a/source/DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 b/source/DSCResources/DSC_ScheduledTask/en-US/DSC_ScheduledTask.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_ScheduledTask/en-US/MSFT_ScheduledTask.strings.psd1 rename to source/DSCResources/DSC_ScheduledTask/en-US/DSC_ScheduledTask.strings.psd1 diff --git a/source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.data.psd1 b/source/DSCResources/DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.data.psd1 similarity index 100% rename from source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.data.psd1 rename to source/DSCResources/DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.data.psd1 diff --git a/source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.psm1 b/source/DSCResources/DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.psm1 similarity index 99% rename from source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.psm1 rename to source/DSCResources/DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.psm1 index baf64b12..824e8a85 100644 --- a/source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.psm1 +++ b/source/DSCResources/DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.psm1 @@ -11,11 +11,11 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SmbServerConfiguration' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SmbServerConfiguration' $resourceData = Import-LocalizedData ` -BaseDirectory $PSScriptRoot ` - -FileName 'MSFT_SmbServerConfiguration.data.psd1' + -FileName 'DSC_SmbServerConfiguration.data.psd1' $script:smbServerSettings = $resourceData.smbServerSettings diff --git a/source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.schema.mof b/source/DSCResources/DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.schema.mof similarity index 98% rename from source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.schema.mof rename to source/DSCResources/DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.schema.mof index 53e90b51..4c434584 100644 --- a/source/DSCResources/MSFT_SmbServerConfiguration/MSFT_SmbServerConfiguration.schema.mof +++ b/source/DSCResources/DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.schema.mof @@ -1,6 +1,6 @@ [ClassVersion("1.0.0.0"), FriendlyName("SmbServerConfiguration")] -class MSFT_SmbServerConfiguration : OMI_BaseResource +class DSC_SmbServerConfiguration : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Write, Description("Specifies the announce comment string.")] String AnnounceComment; diff --git a/source/DSCResources/MSFT_SmbServerConfiguration/README.md b/source/DSCResources/DSC_SmbServerConfiguration/README.md similarity index 100% rename from source/DSCResources/MSFT_SmbServerConfiguration/README.md rename to source/DSCResources/DSC_SmbServerConfiguration/README.md diff --git a/source/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.schema.mfl b/source/DSCResources/DSC_SmbServerConfiguration/en-US/DSC_SmbServerConfiguration.schema.mfl similarity index 98% rename from source/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.schema.mfl rename to source/DSCResources/DSC_SmbServerConfiguration/en-US/DSC_SmbServerConfiguration.schema.mfl index 053144f9..6b862f43 100644 --- a/source/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.schema.mfl +++ b/source/DSCResources/DSC_SmbServerConfiguration/en-US/DSC_SmbServerConfiguration.schema.mfl @@ -1,5 +1,5 @@ [Write, Description("This resource is used to configure SMB Server.")] -class MSFT_SmbServerConfiguration : OMI_BaseResource +class DSC_SmbServerConfiguration : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Write, Description("Specifies the announce comment string.")] String AnnounceComment; diff --git a/source/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.strings.psd1 b/source/DSCResources/DSC_SmbServerConfiguration/en-US/DSC_SmbServerConfiguration.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_SmbServerConfiguration/en-US/MSFT_SmbServerConfiguration.strings.psd1 rename to source/DSCResources/DSC_SmbServerConfiguration/en-US/DSC_SmbServerConfiguration.strings.psd1 diff --git a/source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.psm1 b/source/DSCResources/DSC_SmbShare/DSC_SmbShare.psm1 similarity index 99% rename from source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.psm1 rename to source/DSCResources/DSC_SmbShare/DSC_SmbShare.psm1 index 3a12940c..53ac25a2 100644 --- a/source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.psm1 +++ b/source/DSCResources/DSC_SmbShare/DSC_SmbShare.psm1 @@ -11,7 +11,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SmbShare' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SmbShare' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.schema.mof b/source/DSCResources/DSC_SmbShare/DSC_SmbShare.schema.mof similarity index 98% rename from source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.schema.mof rename to source/DSCResources/DSC_SmbShare/DSC_SmbShare.schema.mof index a1b01e36..2c00fff8 100644 --- a/source/DSCResources/MSFT_SmbShare/MSFT_SmbShare.schema.mof +++ b/source/DSCResources/DSC_SmbShare/DSC_SmbShare.schema.mof @@ -1,6 +1,6 @@ [ClassVersion("1.0.0.0"), FriendlyName("SmbShare")] -class MSFT_SmbShare : OMI_BaseResource +class DSC_SmbShare : OMI_BaseResource { [Key, Description("Specifies the name of the SMB share.")] String Name; [Required, Description("Specifies the path of the SMB share.")] String Path; diff --git a/source/DSCResources/MSFT_SmbShare/README.md b/source/DSCResources/DSC_SmbShare/README.md similarity index 100% rename from source/DSCResources/MSFT_SmbShare/README.md rename to source/DSCResources/DSC_SmbShare/README.md diff --git a/source/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.schema.mfl b/source/DSCResources/DSC_SmbShare/en-US/DSC_SmbShare.schema.mfl similarity index 98% rename from source/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.schema.mfl rename to source/DSCResources/DSC_SmbShare/en-US/DSC_SmbShare.schema.mfl index 9d2fd5ec..299a9d30 100644 --- a/source/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.schema.mfl +++ b/source/DSCResources/DSC_SmbShare/en-US/DSC_SmbShare.schema.mfl @@ -1,5 +1,5 @@ [Description("This resource is used to configure SMB shares.") : Amended,AMENDMENT, LOCALE("MS_409")] -class MSFT_SmbShare : OMI_BaseResource +class DSC_SmbShare : OMI_BaseResource { [Key, Description("Specifies the name of the SMB share.") : Amended] String Name; [Description("Specifies the path of the SMB share.") : Amended] String Path; diff --git a/source/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.strings.psd1 b/source/DSCResources/DSC_SmbShare/en-US/DSC_SmbShare.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_SmbShare/en-US/MSFT_SmbShare.strings.psd1 rename to source/DSCResources/DSC_SmbShare/en-US/DSC_SmbShare.strings.psd1 diff --git a/source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.psm1 b/source/DSCResources/DSC_SystemLocale/DSC_SystemLocale.psm1 similarity index 98% rename from source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.psm1 rename to source/DSCResources/DSC_SystemLocale/DSC_SystemLocale.psm1 index 572fc0f6..4c5a3890 100644 --- a/source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.psm1 +++ b/source/DSCResources/DSC_SystemLocale/DSC_SystemLocale.psm1 @@ -11,7 +11,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SystemLocale' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_SystemLocale' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.schema.mof b/source/DSCResources/DSC_SystemLocale/DSC_SystemLocale.schema.mof similarity index 87% rename from source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.schema.mof rename to source/DSCResources/DSC_SystemLocale/DSC_SystemLocale.schema.mof index 1272747a..caaf3eec 100644 --- a/source/DSCResources/MSFT_SystemLocale/MSFT_SystemLocale.schema.mof +++ b/source/DSCResources/DSC_SystemLocale/DSC_SystemLocale.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("SystemLocale")] -class MSFT_SystemLocale : OMI_BaseResource +class DSC_SystemLocale : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Required, Description("Specifies the System Locale.")] String SystemLocale; diff --git a/source/DSCResources/MSFT_SystemLocale/README.md b/source/DSCResources/DSC_SystemLocale/README.md similarity index 100% rename from source/DSCResources/MSFT_SystemLocale/README.md rename to source/DSCResources/DSC_SystemLocale/README.md diff --git a/source/DSCResources/MSFT_SystemLocale/en-US/MSFT_SystemLocale.strings.psd1 b/source/DSCResources/DSC_SystemLocale/en-US/DSC_SystemLocale.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_SystemLocale/en-US/MSFT_SystemLocale.strings.psd1 rename to source/DSCResources/DSC_SystemLocale/en-US/DSC_SystemLocale.strings.psd1 diff --git a/source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 b/source/DSCResources/DSC_TimeZone/DSC_TimeZone.psm1 similarity index 97% rename from source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 rename to source/DSCResources/DSC_TimeZone/DSC_TimeZone.psm1 index 2b77af99..b0ee6a90 100644 --- a/source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.psm1 +++ b/source/DSCResources/DSC_TimeZone/DSC_TimeZone.psm1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings. -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_TimeZone' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_TimeZone' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof b/source/DSCResources/DSC_TimeZone/DSC_TimeZone.schema.mof similarity index 87% rename from source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof rename to source/DSCResources/DSC_TimeZone/DSC_TimeZone.schema.mof index 98d971f0..e272ca82 100644 --- a/source/DSCResources/MSFT_TimeZone/MSFT_TimeZone.schema.mof +++ b/source/DSCResources/DSC_TimeZone/DSC_TimeZone.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0.0.0"), FriendlyName("TimeZone")] -class MSFT_TimeZone : OMI_BaseResource +class DSC_TimeZone : OMI_BaseResource { [Key, Description("Specifies the resource is a single instance, the value must be 'Yes'."), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance; [Required, Description("Specifies the TimeZone.")] String TimeZone; diff --git a/source/DSCResources/MSFT_TimeZone/README.md b/source/DSCResources/DSC_TimeZone/README.md similarity index 100% rename from source/DSCResources/MSFT_TimeZone/README.md rename to source/DSCResources/DSC_TimeZone/README.md diff --git a/source/DSCResources/MSFT_TimeZone/en-US/MSFT_TimeZone.strings.psd1 b/source/DSCResources/DSC_TimeZone/en-US/DSC_TimeZone.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_TimeZone/en-US/MSFT_TimeZone.strings.psd1 rename to source/DSCResources/DSC_TimeZone/en-US/DSC_TimeZone.strings.psd1 diff --git a/source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 b/source/DSCResources/DSC_VirtualMemory/DSC_VirtualMemory.psm1 similarity index 99% rename from source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 rename to source/DSCResources/DSC_VirtualMemory/DSC_VirtualMemory.psm1 index f678f36a..721852e3 100644 --- a/source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.psm1 +++ b/source/DSCResources/DSC_VirtualMemory/DSC_VirtualMemory.psm1 @@ -9,7 +9,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_VirtualMemory' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_VirtualMemory' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof b/source/DSCResources/DSC_VirtualMemory/DSC_VirtualMemory.schema.mof similarity index 94% rename from source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof rename to source/DSCResources/DSC_VirtualMemory/DSC_VirtualMemory.schema.mof index 9dc46109..11c4182f 100644 --- a/source/DSCResources/MSFT_VirtualMemory/MSFT_VirtualMemory.schema.mof +++ b/source/DSCResources/DSC_VirtualMemory/DSC_VirtualMemory.schema.mof @@ -1,6 +1,6 @@ [ClassVersion("1.0.0.0"), FriendlyName("VirtualMemory")] -class MSFT_VirtualMemory : OMI_BaseResource +class DSC_VirtualMemory : OMI_BaseResource { [Key, Description("The drive letter for which paging settings should be set. Can be letter only, letter and colon or letter with colon and trailing slash.")] String Drive; [Key, Description("The type of the paging setting to use. If set to AutoManagePagingFile, the drive letter will be ignored. If set to SystemManagedSize, the values for InitialSize and MaximumSize will be ignored"), ValueMap{"AutoManagePagingFile","CustomSize","SystemManagedSize","NoPagingFile"}, Values{"AutoManagePagingFile","CustomSize","SystemManagedSize","NoPagingFile"}] String Type; diff --git a/source/DSCResources/MSFT_VirtualMemory/README.md b/source/DSCResources/DSC_VirtualMemory/README.md similarity index 100% rename from source/DSCResources/MSFT_VirtualMemory/README.md rename to source/DSCResources/DSC_VirtualMemory/README.md diff --git a/source/DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 b/source/DSCResources/DSC_VirtualMemory/en-US/DSC_VirtualMemory.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_VirtualMemory/en-US/MSFT_VirtualMemory.strings.psd1 rename to source/DSCResources/DSC_VirtualMemory/en-US/DSC_VirtualMemory.strings.psd1 diff --git a/source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 similarity index 98% rename from source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.psm1 rename to source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index 0819b5bd..2ebc69c2 100644 --- a/source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_WindowsCapability' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_WindowsCapability' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.schema.mof b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof similarity index 93% rename from source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.schema.mof rename to source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof index d03ccf72..0b364422 100644 --- a/source/DSCResources/MSFT_WindowsCapability/MSFT_WindowsCapability.schema.mof +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof @@ -1,6 +1,6 @@ [ClassVersion("1.0.0.1"), FriendlyName("WindowsCapability")] -class MSFT_WindowsCapability : OMI_BaseResource +class DSC_WindowsCapability : OMI_BaseResource { [Key, Description("Specifies the given name of a Windows Capability")] String Name; [Write, Description("Specifies whether the Windows Capability should be installed or uninstalled. To install the Windows Capability, set this property to Present. To uninstall the Windows Capability, set the property to Absent."), ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}] String Ensure; diff --git a/source/DSCResources/MSFT_WindowsCapability/README.md b/source/DSCResources/DSC_WindowsCapability/README.md similarity index 100% rename from source/DSCResources/MSFT_WindowsCapability/README.md rename to source/DSCResources/DSC_WindowsCapability/README.md diff --git a/source/DSCResources/MSFT_WindowsCapability/en-US/MSFT_WindowsCapability.strings.psd1 b/source/DSCResources/DSC_WindowsCapability/en-US/DSC_WindowsCapability.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_WindowsCapability/en-US/MSFT_WindowsCapability.strings.psd1 rename to source/DSCResources/DSC_WindowsCapability/en-US/DSC_WindowsCapability.strings.psd1 diff --git a/source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 b/source/DSCResources/DSC_WindowsEventLog/DSC_WindowsEventLog.psm1 similarity index 99% rename from source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 rename to source/DSCResources/DSC_WindowsEventLog/DSC_WindowsEventLog.psm1 index b3a2516f..e5281517 100644 --- a/source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.psm1 +++ b/source/DSCResources/DSC_WindowsEventLog/DSC_WindowsEventLog.psm1 @@ -6,7 +6,7 @@ Import-Module -Name (Join-Path -Path $modulePath ` -ChildPath 'ComputerManagementDsc.Common.psm1')) # Import Localization Strings -$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_WindowsEventLog' +$script:localizedData = Get-LocalizedData -ResourceName 'DSC_WindowsEventLog' <# .SYNOPSIS diff --git a/source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof b/source/DSCResources/DSC_WindowsEventLog/DSC_WindowsEventLog.schema.mof similarity index 95% rename from source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof rename to source/DSCResources/DSC_WindowsEventLog/DSC_WindowsEventLog.schema.mof index 60cfc45d..379bfd77 100644 --- a/source/DSCResources/MSFT_WindowsEventLog/MSFT_WindowsEventLog.schema.mof +++ b/source/DSCResources/DSC_WindowsEventLog/DSC_WindowsEventLog.schema.mof @@ -1,6 +1,6 @@ [ClassVersion("1.0.0.1"), FriendlyName("WindowsEventLog")] -class MSFT_WindowsEventLog : OMI_BaseResource +class DSC_WindowsEventLog : OMI_BaseResource { [Key, Description("Specifies the given name of a Windows Event Log")] String LogName; [Write, Description("Specifies the given state of a Windows Event Log")] Boolean IsEnabled; diff --git a/source/DSCResources/MSFT_WindowsEventLog/README.md b/source/DSCResources/DSC_WindowsEventLog/README.md similarity index 100% rename from source/DSCResources/MSFT_WindowsEventLog/README.md rename to source/DSCResources/DSC_WindowsEventLog/README.md diff --git a/source/DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 b/source/DSCResources/DSC_WindowsEventLog/en-US/DSC_WindowsEventLog.strings.psd1 similarity index 100% rename from source/DSCResources/MSFT_WindowsEventLog/en-US/MSFT_WindowsEventLog.strings.psd1 rename to source/DSCResources/DSC_WindowsEventLog/en-US/DSC_WindowsEventLog.strings.psd1 diff --git a/source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 b/source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 index ebad769f..1399e679 100644 --- a/source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 +++ b/source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 @@ -6,9 +6,9 @@ .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 WindowsOptionalFeature: DSC_WindowsOptionalFeature + For Service: DSC_ServiceResource + For Registry: DSC_RegistryResource For Helper: SqlServerDscHelper .PARAMETER ScriptRoot diff --git a/tests/Integration/MSFT_PendingReboot.Config.ps1 b/tests/Integration/DSC_PendingReboot.Config.ps1 similarity index 93% rename from tests/Integration/MSFT_PendingReboot.Config.ps1 rename to tests/Integration/DSC_PendingReboot.Config.ps1 index 7e8d7c35..4468bb63 100644 --- a/tests/Integration/MSFT_PendingReboot.Config.ps1 +++ b/tests/Integration/DSC_PendingReboot.Config.ps1 @@ -1,5 +1,5 @@ # Integration Test Config Template Version: 1.0.0 -configuration MSFT_PendingReboot_config +configuration DSC_PendingReboot_config { Import-DscResource -ModuleName ComputerManagementDsc diff --git a/tests/Integration/MSFT_PendingReboot.Tests.ps1 b/tests/Integration/DSC_PendingReboot.Tests.ps1 similarity index 99% rename from tests/Integration/MSFT_PendingReboot.Tests.ps1 rename to tests/Integration/DSC_PendingReboot.Tests.ps1 index fc77d271..22247407 100644 --- a/tests/Integration/MSFT_PendingReboot.Tests.ps1 +++ b/tests/Integration/DSC_PendingReboot.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_PendingReboot' +$script:dscResourceName = 'DSC_PendingReboot' # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 b/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 similarity index 97% rename from tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 rename to tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 index 46671a70..730098f0 100644 --- a/tests/Integration/MSFT_PowerShellExecutionPolicy.Integration.Tests.ps1 +++ b/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_PowerShellExecutionPolicy' +$script:dscResourceName = 'DSC_PowerShellExecutionPolicy' # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/tests/Integration/MSFT_PowerShellExecutionPolicy.config.ps1 b/tests/Integration/DSC_PowerShellExecutionPolicy.config.ps1 similarity index 85% rename from tests/Integration/MSFT_PowerShellExecutionPolicy.config.ps1 rename to tests/Integration/DSC_PowerShellExecutionPolicy.config.ps1 index c1fd0292..7641c9fa 100644 --- a/tests/Integration/MSFT_PowerShellExecutionPolicy.config.ps1 +++ b/tests/Integration/DSC_PowerShellExecutionPolicy.config.ps1 @@ -1,5 +1,5 @@ # Integration Test Config Template Version: 1.0.0 -configuration MSFT_PowerShellExecutionPolicy_config +configuration DSC_PowerShellExecutionPolicy_config { Import-DscResource -ModuleName ComputerManagementDsc diff --git a/tests/Integration/MSFT_RemoteDesktopAdmin.Config.ps1 b/tests/Integration/DSC_RemoteDesktopAdmin.Config.ps1 similarity index 100% rename from tests/Integration/MSFT_RemoteDesktopAdmin.Config.ps1 rename to tests/Integration/DSC_RemoteDesktopAdmin.Config.ps1 diff --git a/tests/Integration/MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 b/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 similarity index 99% rename from tests/Integration/MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 rename to tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 index 53aadb2e..cc0796d0 100644 --- a/tests/Integration/MSFT_RemoteDesktopAdmin.Integration.Tests.ps1 +++ b/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_RemoteDesktopAdmin' +$script:dscResourceName = 'DSC_RemoteDesktopAdmin' # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/tests/Integration/MSFT_ScheduledTask.Config.ps1 b/tests/Integration/DSC_ScheduledTask.Config.ps1 similarity index 100% rename from tests/Integration/MSFT_ScheduledTask.Config.ps1 rename to tests/Integration/DSC_ScheduledTask.Config.ps1 diff --git a/tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 b/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 similarity index 99% rename from tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 rename to tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 index 2279c5f5..5a202661 100644 --- a/tests/Integration/MSFT_ScheduledTask.Integration.Tests.ps1 +++ b/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 @@ -1,7 +1,7 @@ #Requires -Version 5.0 #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_ScheduledTask' +$script:dscResourceName = 'DSC_ScheduledTask' # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/tests/Integration/MSFT_SmbServerConfiguration.Config.ps1 b/tests/Integration/DSC_SmbServerConfiguration.Config.ps1 similarity index 98% rename from tests/Integration/MSFT_SmbServerConfiguration.Config.ps1 rename to tests/Integration/DSC_SmbServerConfiguration.Config.ps1 index a5b689d3..4ba3202e 100644 --- a/tests/Integration/MSFT_SmbServerConfiguration.Config.ps1 +++ b/tests/Integration/DSC_SmbServerConfiguration.Config.ps1 @@ -1,5 +1,5 @@ # Integration Test Config Template Version: 1.0.0 -configuration MSFT_SmbServerConfiguration_config +configuration DSC_SmbServerConfiguration_config { Import-DscResource -ModuleName ComputerManagementDsc diff --git a/tests/Integration/MSFT_SmbServerConfiguration.Tests.ps1 b/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 similarity index 99% rename from tests/Integration/MSFT_SmbServerConfiguration.Tests.ps1 rename to tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 index 712789a9..35009228 100644 --- a/tests/Integration/MSFT_SmbServerConfiguration.Tests.ps1 +++ b/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_SmbServerConfiguration' +$script:dscResourceName = 'DSC_SmbServerConfiguration' # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/tests/Integration/MSFT_SmbShare.Integration.Tests.ps1 b/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 similarity index 99% rename from tests/Integration/MSFT_SmbShare.Integration.Tests.ps1 rename to tests/Integration/DSC_SmbShare.Integration.Tests.ps1 index c2ef5458..9fac9880 100644 --- a/tests/Integration/MSFT_SmbShare.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 @@ -6,7 +6,7 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceFriendlyName = 'SmbShare' -$script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" +$script:dscResourceName = "DSC_$($script:dscResourceFriendlyName)" # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) @@ -26,7 +26,7 @@ $TestEnvironment = Initialize-TestEnvironment ` #region HEADER $script:dscResourceFriendlyName = 'SmbShare' -$script:dcsResourceName = "MSFT_$($script:dscResourceFriendlyName)" +$script:dcsResourceName = "DSC_$($script:dscResourceFriendlyName)" #region Integration Tests $configurationFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dcsResourceName).config.ps1" diff --git a/tests/Integration/MSFT_SmbShare.config.ps1 b/tests/Integration/DSC_SmbShare.config.ps1 similarity index 94% rename from tests/Integration/MSFT_SmbShare.config.ps1 rename to tests/Integration/DSC_SmbShare.config.ps1 index a3a359ff..a9d2d571 100644 --- a/tests/Integration/MSFT_SmbShare.config.ps1 +++ b/tests/Integration/DSC_SmbShare.config.ps1 @@ -40,7 +40,7 @@ else Creates the prerequisites for the other tests. This creates a folder that will be shared. #> -Configuration MSFT_SmbShare_Prerequisites_Config +Configuration DSC_SmbShare_Prerequisites_Config { Import-DscResource -ModuleName 'PSDesiredStateConfiguration' @@ -114,7 +114,7 @@ Configuration MSFT_SmbShare_Prerequisites_Config .SYNOPSIS Create the SMB share with default values, and no permissions. #> -Configuration MSFT_SmbShare_CreateShare1_Config +Configuration DSC_SmbShare_CreateShare1_Config { Import-DscResource -ModuleName 'ComputerManagementDsc' @@ -132,7 +132,7 @@ Configuration MSFT_SmbShare_CreateShare1_Config .SYNOPSIS Create the SMB share with default values, and no permissions. #> -Configuration MSFT_SmbShare_CreateShare2_Config +Configuration DSC_SmbShare_CreateShare2_Config { Import-DscResource -ModuleName 'ComputerManagementDsc' @@ -166,7 +166,7 @@ Configuration MSFT_SmbShare_CreateShare2_Config existing file share as the file share is not a cluster share. #> -Configuration MSFT_SmbShare_UpdateProperties_Config +Configuration DSC_SmbShare_UpdateProperties_Config { Import-DscResource -ModuleName 'ComputerManagementDsc' @@ -194,7 +194,7 @@ Configuration MSFT_SmbShare_UpdateProperties_Config .SYNOPSIS Remove permission, and no other properties should be changed. #> -Configuration MSFT_SmbShare_RemovePermission_Config +Configuration DSC_SmbShare_RemovePermission_Config { Import-DscResource -ModuleName 'ComputerManagementDsc' @@ -216,7 +216,7 @@ Configuration MSFT_SmbShare_RemovePermission_Config .SYNOPSIS Drop and recreate share 1 on a new path. #> -Configuration MSFT_SmbShare_RecreateShare1_Config +Configuration DSC_SmbShare_RecreateShare1_Config { Import-DscResource -ModuleName 'ComputerManagementDsc' @@ -237,7 +237,7 @@ Configuration MSFT_SmbShare_RecreateShare1_Config .SYNOPSIS Remove the share 1. #> -Configuration MSFT_SmbShare_RemoveShare1_Config +Configuration DSC_SmbShare_RemoveShare1_Config { Import-DscResource -ModuleName 'ComputerManagementDsc' @@ -256,7 +256,7 @@ Configuration MSFT_SmbShare_RemoveShare1_Config .SYNOPSIS Remove the share 2. #> -Configuration MSFT_SmbShare_RemoveShare2_Config +Configuration DSC_SmbShare_RemoveShare2_Config { Import-DscResource -ModuleName 'ComputerManagementDsc' @@ -275,7 +275,7 @@ Configuration MSFT_SmbShare_RemoveShare2_Config .SYNOPSIS Clean up the prerequisites. #> -Configuration MSFT_SmbShare_Cleanup_Config +Configuration DSC_SmbShare_Cleanup_Config { Import-DscResource -ModuleName 'PSDesiredStateConfiguration' diff --git a/tests/Integration/MSFT_SystemLocale.Integration.Tests.ps1 b/tests/Integration/DSC_SystemLocale.Integration.Tests.ps1 similarity index 98% rename from tests/Integration/MSFT_SystemLocale.Integration.Tests.ps1 rename to tests/Integration/DSC_SystemLocale.Integration.Tests.ps1 index 852516cd..b0d2ea98 100644 --- a/tests/Integration/MSFT_SystemLocale.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SystemLocale.Integration.Tests.ps1 @@ -1,5 +1,5 @@ $script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_SystemLocale' +$script:DSCResourceName = 'DSC_SystemLocale' #region HEADER # Integration Test Template Version: 1.1.1 diff --git a/tests/Integration/MSFT_SystemLocale.config.ps1 b/tests/Integration/DSC_SystemLocale.config.ps1 similarity index 85% rename from tests/Integration/MSFT_SystemLocale.config.ps1 rename to tests/Integration/DSC_SystemLocale.config.ps1 index 2e861bf0..ed33d466 100644 --- a/tests/Integration/MSFT_SystemLocale.config.ps1 +++ b/tests/Integration/DSC_SystemLocale.config.ps1 @@ -1,4 +1,4 @@ -configuration MSFT_SystemLocale_Config { +configuration DSC_SystemLocale_Config { Import-DscResource -ModuleName ComputerManagementDsc node localhost { diff --git a/tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 b/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 similarity index 98% rename from tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 rename to tests/Integration/DSC_TimeZone.Integration.Tests.ps1 index 837da24b..863b0f3f 100644 --- a/tests/Integration/MSFT_TimeZone.Integration.Tests.ps1 +++ b/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_TimeZone' +$script:dscResourceName = 'DSC_TimeZone' # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/tests/Integration/MSFT_TimeZone.config.ps1 b/tests/Integration/DSC_TimeZone.config.ps1 similarity index 86% rename from tests/Integration/MSFT_TimeZone.config.ps1 rename to tests/Integration/DSC_TimeZone.config.ps1 index ff6d9bd0..fbdc33af 100644 --- a/tests/Integration/MSFT_TimeZone.config.ps1 +++ b/tests/Integration/DSC_TimeZone.config.ps1 @@ -1,4 +1,4 @@ -configuration MSFT_TimeZone_Config { +configuration DSC_TimeZone_Config { Import-DscResource -ModuleName ComputerManagementDsc node localhost { diff --git a/tests/Integration/MSFT_VirtualMemory.Config.ps1 b/tests/Integration/DSC_VirtualMemory.Config.ps1 similarity index 100% rename from tests/Integration/MSFT_VirtualMemory.Config.ps1 rename to tests/Integration/DSC_VirtualMemory.Config.ps1 diff --git a/tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 b/tests/Integration/DSC_VirtualMemory.Integration.Tests.ps1 similarity index 99% rename from tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 rename to tests/Integration/DSC_VirtualMemory.Integration.Tests.ps1 index 49f7d2f5..7682314e 100644 --- a/tests/Integration/MSFT_VirtualMemory.Integration.Tests.ps1 +++ b/tests/Integration/DSC_VirtualMemory.Integration.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_VirtualMemory' +$script:dscResourceName = 'DSC_VirtualMemory' # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/tests/Integration/MSFT_WindowsCapability.Config.ps1 b/tests/Integration/DSC_WindowsCapability.Config.ps1 similarity index 89% rename from tests/Integration/MSFT_WindowsCapability.Config.ps1 rename to tests/Integration/DSC_WindowsCapability.Config.ps1 index 1e04ef4e..9f3dd265 100644 --- a/tests/Integration/MSFT_WindowsCapability.Config.ps1 +++ b/tests/Integration/DSC_WindowsCapability.Config.ps1 @@ -1,5 +1,5 @@ # Integration Test Config Template Version: 1.0.0 -configuration MSFT_WindowsCapability_Config +configuration DSC_WindowsCapability_Config { Import-DscResource -ModuleName ComputerManagementDsc diff --git a/tests/Integration/MSFT_WindowsCapability.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 similarity index 99% rename from tests/Integration/MSFT_WindowsCapability.Integration.Tests.ps1 rename to tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 index 70cb29f5..c91c9019 100644 --- a/tests/Integration/MSFT_WindowsCapability.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_WindowsCapability' +$script:dscResourceName = 'DSC_WindowsCapability' # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) diff --git a/tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsEventLog.Integration.Tests.ps1 similarity index 94% rename from tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 rename to tests/Integration/DSC_WindowsEventLog.Integration.Tests.ps1 index 54a62372..aefe2f80 100644 --- a/tests/Integration/MSFT_WindowsEventLog.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsEventLog.Integration.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_WindowsEventLog' +$script:dscResourceName = 'DSC_WindowsEventLog' # Integration Test Template Version: 1.3.3 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) @@ -26,7 +26,7 @@ try Describe "$($script:dscResourceName)_Integration" { Context 'Set Windows Event Log to Logmode Retain' { - $CurrentConfig = 'MSFT_WindowsEventLog_RetainSize' + $CurrentConfig = 'DSC_WindowsEventLog_RetainSize' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') @@ -52,7 +52,7 @@ try } Context 'Set Windows Event Log to Logmode AutoBackup with LogRetentionDays of 30 days' { - $CurrentConfig = 'MSFT_WindowsEventLog_AutobackupLogRetention' + $CurrentConfig = 'DSC_WindowsEventLog_AutobackupLogRetention' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') @@ -78,7 +78,7 @@ try } Context 'Set Windows Event Log to Logmode Circular, MaximumSizeInBytes 20971520, LogFilePath C:\temp\Application.evtx' { - $CurrentConfig = 'MSFT_WindowsEventLog_CircularLogPath' + $CurrentConfig = 'DSC_WindowsEventLog_CircularLogPath' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') @@ -104,7 +104,7 @@ try } Context 'Set Windows Event Log to Default' { - $CurrentConfig = 'MSFT_WindowsEventLog_Default' + $CurrentConfig = 'DSC_WindowsEventLog_Default' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') @@ -130,7 +130,7 @@ try } Context 'Enable a Logfile other than Application Eventlog' { - $CurrentConfig = 'MSFT_WindowsEventLog_EnableLog' + $CurrentConfig = 'DSC_WindowsEventLog_EnableLog' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') @@ -156,7 +156,7 @@ try } Context 'Disable a Logfile other than Application Windows Event Log' { - $CurrentConfig = 'MSFT_WindowsEventLog_DisableLog' + $CurrentConfig = 'DSC_WindowsEventLog_DisableLog' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') @@ -182,7 +182,7 @@ try } Context 'Set Eventlog to Logmode Circular with a SecurityDescriptor' { - $CurrentConfig = 'MSFT_WindowsEventLog_CircularSecurityDescriptor' + $CurrentConfig = 'DSC_WindowsEventLog_CircularSecurityDescriptor' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') @@ -208,7 +208,7 @@ try } Context 'Enable a Logfile other than Application Windows Event Log with Retention' { - $CurrentConfig = 'MSFT_WindowsEventLog_EnableBackupLog' + $CurrentConfig = 'DSC_WindowsEventLog_EnableBackupLog' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') @@ -234,7 +234,7 @@ try } Context 'Disable a Logfile other than Application Eventlog with retention' { - $CurrentConfig = 'MSFT_WindowsEventLog_DisableBackupLog' + $CurrentConfig = 'DSC_WindowsEventLog_DisableBackupLog' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') @@ -260,7 +260,7 @@ try } Context 'Set Windows Event Log back to the default configuration' { - $CurrentConfig = 'MSFT_WindowsEventLog_Default' + $CurrentConfig = 'DSC_WindowsEventLog_Default' $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') diff --git a/tests/Integration/MSFT_WindowsEventLog.config.ps1 b/tests/Integration/DSC_WindowsEventLog.config.ps1 similarity index 88% rename from tests/Integration/MSFT_WindowsEventLog.config.ps1 rename to tests/Integration/DSC_WindowsEventLog.config.ps1 index 82c19df0..50b53f8b 100644 --- a/tests/Integration/MSFT_WindowsEventLog.config.ps1 +++ b/tests/Integration/DSC_WindowsEventLog.config.ps1 @@ -1,5 +1,5 @@ # Integration Test Config Template Version: 1.0.0 -configuration MSFT_WindowsEventLog_Default +configuration DSC_WindowsEventLog_Default { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -16,7 +16,7 @@ configuration MSFT_WindowsEventLog_Default } } -configuration MSFT_WindowsEventLog_RetainSize +configuration DSC_WindowsEventLog_RetainSize { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -31,7 +31,7 @@ configuration MSFT_WindowsEventLog_RetainSize } } -configuration MSFT_WindowsEventLog_AutobackupLogRetention +configuration DSC_WindowsEventLog_AutobackupLogRetention { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -46,7 +46,7 @@ configuration MSFT_WindowsEventLog_AutobackupLogRetention } } -configuration MSFT_WindowsEventLog_CircularLogPath +configuration DSC_WindowsEventLog_CircularLogPath { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -62,7 +62,7 @@ configuration MSFT_WindowsEventLog_CircularLogPath } } -configuration MSFT_WindowsEventLog_EnableLog +configuration DSC_WindowsEventLog_EnableLog { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -77,7 +77,7 @@ configuration MSFT_WindowsEventLog_EnableLog } } -configuration MSFT_WindowsEventLog_DisableLog +configuration DSC_WindowsEventLog_DisableLog { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -90,7 +90,7 @@ configuration MSFT_WindowsEventLog_DisableLog } } -configuration MSFT_WindowsEventLog_CircularSecurityDescriptor +configuration DSC_WindowsEventLog_CircularSecurityDescriptor { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -106,7 +106,7 @@ configuration MSFT_WindowsEventLog_CircularSecurityDescriptor } } -configuration MSFT_WindowsEventLog_EnableBackupLog +configuration DSC_WindowsEventLog_EnableBackupLog { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -121,7 +121,7 @@ configuration MSFT_WindowsEventLog_EnableBackupLog } } -configuration MSFT_WindowsEventLog_DisableBackupLog +configuration DSC_WindowsEventLog_DisableBackupLog { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' diff --git a/tests/Unit/ComputerManagementDsc.Common.Tests.ps1 b/tests/Unit/ComputerManagementDsc.Common.Tests.ps1 index 144b3f50..d2d2538f 100644 --- a/tests/Unit/ComputerManagementDsc.Common.Tests.ps1 +++ b/tests/Unit/ComputerManagementDsc.Common.Tests.ps1 @@ -1,78 +1,93 @@ #region HEADER -$script:ModuleName = 'ComputerManagementDsc.Common' +$script:projectPath = "$PSScriptRoot\..\.." | Convert-Path +$script:projectName = (Get-ChildItem -Path "$script:projectPath\*\*.psd1" | Where-Object -FilterScript { + ($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and + $(try + { Test-ModuleManifest -Path $_.FullName -ErrorAction Stop + } + catch + { $false + }) + }).BaseName -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +$script:parentModule = Get-Module -Name $script:projectName -ListAvailable | Select-Object -First 1 +$script:subModulesFolder = Join-Path -Path $script:parentModule.ModuleBase -ChildPath 'Modules' +Remove-Module -Name $script:parentModule -Force -ErrorAction 'SilentlyContinue' -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) -} +$script:subModuleName = (Split-Path -Path $PSCommandPath -Leaf) -replace '\.Tests.ps1' +$script:subModuleFile = Join-Path -Path $script:subModulesFolder -ChildPath "$($script:subModuleName)/$($script:subModuleName).psm1" -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -Import-Module (Join-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'Modules' -ChildPath $script:ModuleName)) -ChildPath "$script:ModuleName.psm1") -Force +Import-Module $script:subModuleFile -Force -ErrorAction Stop #endregion HEADER -# Begin Testing -try -{ - InModuleScope $script:ModuleName { - Describe 'ComputerManagementDsc.Common\Remove-CommonParameter' { - $removeCommonParameter = @{ - Parameter1 = 'value1' - Parameter2 = 'value2' - Verbose = $true - Debug = $true - ErrorAction = 'Stop' - WarningAction = 'Stop' - InformationAction = 'Stop' - ErrorVariable = 'errorVariable' - WarningVariable = 'warningVariable' - OutVariable = 'outVariable' - OutBuffer = 'outBuffer' - PipelineVariable = 'pipelineVariable' - InformationVariable = 'informationVariable' - WhatIf = $true - Confirm = $true - UseTransaction = $true - } - - Context 'Hashtable contains all common parameters' { - It 'Should not throw exception' { - { $script:result = Remove-CommonParameter -Hashtable $removeCommonParameter -Verbose } | Should -Not -Throw - } +InModuleScope $script:subModuleName { + Describe 'ComputerManagementDsc.Common\Remove-CommonParameter' { + $removeCommonParameter = @{ + Parameter1 = 'value1' + Parameter2 = 'value2' + Verbose = $true + Debug = $true + ErrorAction = 'Stop' + WarningAction = 'Stop' + InformationAction = 'Stop' + ErrorVariable = 'errorVariable' + WarningVariable = 'warningVariable' + OutVariable = 'outVariable' + OutBuffer = 'outBuffer' + PipelineVariable = 'pipelineVariable' + InformationVariable = 'informationVariable' + WhatIf = $true + Confirm = $true + UseTransaction = $true + } - It 'Should have retained parameters in the hashtable' { - $script:result.Contains('Parameter1') | Should -BeTrue - $script:result.Contains('Parameter2') | Should -BeTrue - } + Context 'Hashtable contains all common parameters' { + It 'Should not throw exception' { + { $script:result = Remove-CommonParameter -Hashtable $removeCommonParameter -Verbose } | Should -Not -Throw + } - It 'Should have removed the common parameters from the hashtable' { - $script:result.Contains('Verbose') | Should -BeFalse - $script:result.Contains('Debug') | Should -BeFalse - $script:result.Contains('ErrorAction') | Should -BeFalse - $script:result.Contains('WarningAction') | Should -BeFalse - $script:result.Contains('InformationAction') | Should -BeFalse - $script:result.Contains('ErrorVariable') | Should -BeFalse - $script:result.Contains('WarningVariable') | Should -BeFalse - $script:result.Contains('OutVariable') | Should -BeFalse - $script:result.Contains('OutBuffer') | Should -BeFalse - $script:result.Contains('PipelineVariable') | Should -BeFalse - $script:result.Contains('InformationVariable') | Should -BeFalse - $script:result.Contains('WhatIf') | Should -BeFalse - $script:result.Contains('Confirm') | Should -BeFalse - $script:result.Contains('UseTransaction') | Should -BeFalse - } + It 'Should have retained parameters in the hashtable' { + $script:result.Contains('Parameter1') | Should -BeTrue + $script:result.Contains('Parameter2') | Should -BeTrue + } + + It 'Should have removed the common parameters from the hashtable' { + $script:result.Contains('Verbose') | Should -BeFalse + $script:result.Contains('Debug') | Should -BeFalse + $script:result.Contains('ErrorAction') | Should -BeFalse + $script:result.Contains('WarningAction') | Should -BeFalse + $script:result.Contains('InformationAction') | Should -BeFalse + $script:result.Contains('ErrorVariable') | Should -BeFalse + $script:result.Contains('WarningVariable') | Should -BeFalse + $script:result.Contains('OutVariable') | Should -BeFalse + $script:result.Contains('OutBuffer') | Should -BeFalse + $script:result.Contains('PipelineVariable') | Should -BeFalse + $script:result.Contains('InformationVariable') | Should -BeFalse + $script:result.Contains('WhatIf') | Should -BeFalse + $script:result.Contains('Confirm') | Should -BeFalse + $script:result.Contains('UseTransaction') | Should -BeFalse } } + } - Describe 'ComputerManagementDsc.Common\Test-DscParameterState' { - $verbose = $true + Describe 'ComputerManagementDsc.Common\Test-DscParameterState' { + $verbose = $true - Context 'When testing single values' { - $currentValues = @{ + Context 'When testing single values' { + $currentValues = @{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3' + } + } + + Context 'When all values match' { + $desiredValues = [PSObject] @{ String = 'a string' Bool = $true Int = 99 @@ -84,376 +99,376 @@ try } } - Context 'When all values match' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3' - } - } - - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $true' { + $script:result | Should -Be $true } + } - Context 'When a string is mismatched' { - $desiredValues = [PSObject] @{ - String = 'different string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3' - } + Context 'When a string is mismatched' { + $desiredValues = [PSObject] @{ + String = 'different string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3' } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When a boolean is mismatched' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $false - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3' - } + Context 'When a boolean is mismatched' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $false + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3' } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When an int is mismatched' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = 1 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3' - } + Context 'When an int is mismatched' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $true + Int = 1 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3' } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When a type is mismatched' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = '99' - Array = 'a', 'b', 'c' - } + Context 'When a type is mismatched' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $true + Int = '99' + Array = 'a', 'b', 'c' + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When a type is mismatched but TurnOffTypeChecking is used' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = '99' - Array = 'a', 'b', 'c' - } + Context 'When a type is mismatched but TurnOffTypeChecking is used' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $true + Int = '99' + Array = 'a', 'b', 'c' + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -TurnOffTypeChecking ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -TurnOffTypeChecking ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $true' { + $script:result | Should -Be $true } + } - Context 'When a value is mismatched but valuesToCheck is used to exclude them' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $false - Int = 1 - Array = @( 'a', 'b' ) - } + Context 'When a value is mismatched but valuesToCheck is used to exclude them' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $false + Int = 1 + Array = @( 'a', 'b' ) + } - $valuesToCheck = @( - 'String' - ) + $valuesToCheck = @( + 'String' + ) - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -ValuesToCheck $valuesToCheck ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -ValuesToCheck $valuesToCheck ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $true' { + $script:result | Should -Be $true } } + } - Context 'When testing array values' { - BeforeAll { - $currentValues = @{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c', 1 - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3' - } + Context 'When testing array values' { + BeforeAll { + $currentValues = @{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c', 1 + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3' } } + } - Context 'When array is missing a value' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 1 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3' - } + Context 'When array is missing a value' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 1 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3' } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When array has an additional value' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = 1 - Array = 'a', 'b', 'c', 1, 2 - } + Context 'When array has an additional value' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $true + Int = 1 + Array = 'a', 'b', 'c', 1, 2 + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When array has a different value' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = 1 - Array = 'a', 'x', 'c', 1 - } + Context 'When array has a different value' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $true + Int = 1 + Array = 'a', 'x', 'c', 1 + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When array has different order' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = 1 - Array = 'c', 'b', 'a', 1 - } + Context 'When array has different order' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $true + Int = 1 + Array = 'c', 'b', 'a', 1 + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When array has different order but SortArrayValues is used' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = 1 - Array = 'c', 'b', 'a', 1 - } + Context 'When array has different order but SortArrayValues is used' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $true + Int = 1 + Array = 'c', 'b', 'a', 1 + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -SortArrayValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -SortArrayValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When array has a value with a different type' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c', '1' - } + Context 'When array has a value with a different type' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c', '1' + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When array has a value with a different type but TurnOffTypeChecking is used' { - $desiredValues = [PSObject] @{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c', '1' - } + Context 'When array has a value with a different type but TurnOffTypeChecking is used' { + $desiredValues = [PSObject] @{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c', '1' + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -TurnOffTypeChecking ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -TurnOffTypeChecking ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $true' { + $script:result | Should -Be $true } + } - Context 'When both arrays are empty' { - $currentValues = @{ - String = 'a string' - Bool = $true - Int = 99 - Array = @() - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = @() - } + Context 'When both arrays are empty' { + $currentValues = @{ + String = 'a string' + Bool = $true + Int = 99 + Array = @() + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = @() } + } - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = @() - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = @() - } + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = @() + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = @() } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $true' { + $script:result | Should -Be $true + } + } + } + + Context 'When testing hashtables' { + $currentValues = @{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', 99 } } - Context 'When testing hashtables' { - $currentValues = @{ + Context 'When hashtable is missing a value' { + $desiredValues = [PSObject]@{ String = 'a string' Bool = $true Int = 99 @@ -461,191 +476,197 @@ try Hashtable = @{ k1 = 'Test' k2 = 123 - k3 = 'v1', 'v2', 'v3', 99 + k3 = 'v1', 'v2', 'v3' } } - Context 'When hashtable is missing a value' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3' - } - } - - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When hashtable has an additional value' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', 99, 100 - } + Context 'When hashtable has an additional value' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', 99, 100 } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When hashtable has a different value' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'xx', 'v2', 'v3', 99 - } + Context 'When hashtable has a different value' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'xx', 'v2', 'v3', 99 } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When an array in hashtable has different order' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v3', 'v2', 'v1', 99 - } + Context 'When an array in hashtable has different order' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v3', 'v2', 'v1', 99 } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When an array in hashtable has different order but SortArrayValues is used' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v3', 'v2', 'v1', 99 - } + Context 'When an array in hashtable has different order but SortArrayValues is used' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v3', 'v2', 'v1', 99 } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -SortArrayValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -SortArrayValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $true' { + $script:result | Should -Be $true } + } - Context 'When hashtable has a value with a different type' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', '99' - } + Context 'When hashtable has a value with a different type' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', '99' } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When hashtable has a value with a different type but TurnOffTypeChecking is used' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', 99 - } + Context 'When hashtable has a value with a different type but TurnOffTypeChecking is used' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', 99 } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -TurnOffTypeChecking ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -TurnOffTypeChecking ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $true' { + $script:result | Should -Be $true } } + } - Context 'When testing CimInstances / hashtables' { - $currentValues = @{ + Context 'When testing CimInstances / hashtables' { + $currentValues = @{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', 99 + } + CimInstances = [CimInstance[]](ConvertTo-CimInstance -Hashtable @{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a, b, c' + }) + } + + Context 'When everything matches' { + $desiredValues = [PSObject]@{ String = 'a string' Bool = $true Int = 99 @@ -663,324 +684,234 @@ try }) } - Context 'When everything matches' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', 99 - } - CimInstances = [CimInstance[]](ConvertTo-CimInstance -Hashtable @{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a, b, c' - }) - } - - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } - - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw } - Context 'When CimInstances missing a value in the desired state (not recognized)' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', 99 - } - CimInstances = @{ - String = 'a string' - Bool = $true - Array = 'a, b, c' - } - } - - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } - - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $true' { + $script:result | Should -Be $true } + } - Context 'When CimInstances missing a value in the desired state (recognized using ReverseCheck)' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', 99 - } - CimInstances = @{ - String = 'a string' - Bool = $true - Array = 'a, b, c' - } - } - - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -ReverseCheck ` - -Verbose:$verbose } | Should -Not -Throw + Context 'When CimInstances missing a value in the desired state (not recognized)' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', 99 } - - It 'Should return $false' { - $script:result | Should -Be $false + CimInstances = @{ + String = 'a string' + Bool = $true + Array = 'a, b, c' } } - Context 'When CimInstances have an additional value' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', 99 - } - CimInstances = @{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a, b, c' - Test = 'Some string' - } - } - - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $true' { + $script:result | Should -Be $true } + } - Context 'When CimInstances have a different value' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', 99 - } - CimInstances = @{ - String = 'some other string' - Bool = $true - Int = 99 - Array = 'a, b, c' - } + Context 'When CimInstances missing a value in the desired state (recognized using ReverseCheck)' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', 99 } - - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw + CimInstances = @{ + String = 'a string' + Bool = $true + Array = 'a, b, c' } + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -ReverseCheck ` + -Verbose:$verbose } | Should -Not -Throw } - Context 'When CimInstances have a value with a different type' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', 99 - } - CimInstances = @{ - String = 'a string' - Bool = $true - Int = '99' - Array = 'a, b, c' - } - } + It 'Should return $false' { + $script:result | Should -Be $false + } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw + Context 'When CimInstances have an additional value' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', 99 } - - It 'Should return $false' { - $script:result | Should -Be $false + CimInstances = @{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a, b, c' + Test = 'Some string' } } - Context 'When CimInstances have a value with a different type but TurnOffTypeChecking is used' { - $desiredValues = [PSObject]@{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c' - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3', 99 - } - CimInstances = @{ - String = 'a string' - Bool = $true - Int = '99' - Array = 'a, b, c' - } - } - - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -TurnOffTypeChecking ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $false' { + $script:result | Should -Be $false } } - Context 'When reverse checking' { - $currentValues = @{ - String = 'a string' - Bool = $true - Int = 99 - Array = 'a', 'b', 'c', 1 - Hashtable = @{ + Context 'When CimInstances have a different value' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ k1 = 'Test' k2 = 123 - k3 = 'v1', 'v2', 'v3' + k3 = 'v1', 'v2', 'v3', 99 } - } - - Context 'When even if missing property in the desired state' { - $desiredValues = [PSObject] @{ - Array = 'a', 'b', 'c', 1 - Hashtable = @{ - k1 = 'Test' - k2 = 123 - k3 = 'v1', 'v2', 'v3' - } + CimInstances = @{ + String = 'some other string' + Bool = $true + Int = 99 + Array = 'a, b, c' } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $true' { - $script:result | Should -Be $true - } + It 'Should return $false' { + $script:result | Should -Be $false } + } - Context 'When missing property in the desired state' { - $currentValues = @{ - String = 'a string' - Bool = $true + Context 'When CimInstances have a value with a different type' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', 99 } - - $desiredValues = [PSObject] @{ + CimInstances = @{ String = 'a string' + Bool = $true + Int = '99' + Array = 'a, b, c' } + } - It 'Should not throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -ReverseCheck ` - -Verbose:$verbose } | Should -Not -Throw - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should return $false' { - $script:result | Should -Be $false - } + It 'Should return $false' { + $script:result | Should -Be $false } } - Context 'When testing parameter types' { - Context 'When desired value is of the wrong type' { - $currentValues = @{ - String = 'a string' + Context 'When CimInstances have a value with a different type but TurnOffTypeChecking is used' { + $desiredValues = [PSObject]@{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c' + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3', 99 } - - $desiredValues = 1, 2, 3 - - It 'Should throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Throw + CimInstances = @{ + String = 'a string' + Bool = $true + Int = '99' + Array = 'a, b, c' } } - Context 'When current value is of the wrong type' { - $currentValues = 1, 2, 3 - - $desiredValues = @{ - String = 'a string' - } + It 'Should not throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -TurnOffTypeChecking ` + -Verbose:$verbose } | Should -Not -Throw + } - It 'Should throw exception' { - { $script:result = Test-DscParameterState ` - -CurrentValues $currentValues ` - -DesiredValues $desiredValues ` - -Verbose:$verbose } | Should -Throw - } + It 'Should return $true' { + $script:result | Should -Be $true } } } - Describe 'ComputerManagementDsc.Common\Test-DscObjectHasProperty' { - # Use the Get-Verb cmdlet to just get a simple object fast - $testDscObject = (Get-Verb)[0] + Context 'When reverse checking' { + $currentValues = @{ + String = 'a string' + Bool = $true + Int = 99 + Array = 'a', 'b', 'c', 1 + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3' + } + } + + Context 'When even if missing property in the desired state' { + $desiredValues = [PSObject] @{ + Array = 'a', 'b', 'c', 1 + Hashtable = @{ + k1 = 'Test' + k2 = 123 + k3 = 'v1', 'v2', 'v3' + } + } - Context 'When the object contains the expected property' { It 'Should not throw exception' { - { $script:result = Test-DscObjectHasProperty -Object $testDscObject -PropertyName 'Verb' -Verbose } | Should -Not -Throw + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Not -Throw } It 'Should return $true' { @@ -988,9 +919,22 @@ try } } - Context 'When the object does not contain the expected property' { + Context 'When missing property in the desired state' { + $currentValues = @{ + String = 'a string' + Bool = $true + } + + $desiredValues = [PSObject] @{ + String = 'a string' + } + It 'Should not throw exception' { - { $script:result = Test-DscObjectHasProperty -Object $testDscObject -PropertyName 'Missing' -Verbose } | Should -Not -Throw + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -ReverseCheck ` + -Verbose:$verbose } | Should -Not -Throw } It 'Should return $false' { @@ -999,619 +943,708 @@ try } } - Describe 'ComputerManagementDsc.Common\ConvertTo-CimInstance' { - $hashtable = @{ - k1 = 'v1' - k2 = 100 - k3 = 1, 2, 3 - } - - Context 'When the array contains the expected record count' { - It 'Should not throw exception' { - { $script:result = [CimInstance[]]($hashtable | ConvertTo-CimInstance) } | Should -Not -Throw + Context 'When testing parameter types' { + Context 'When desired value is of the wrong type' { + $currentValues = @{ + String = 'a string' } - It "Should record count should be $($hashTable.Count)" { - $script:result.Count | Should -Be $hashtable.Count - } + $desiredValues = 1, 2, 3 - It 'Should return result of type CimInstance[]' { - $script:result.GetType().Name | Should -Be 'CimInstance[]' + It 'Should throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Throw } + } - It 'Should return value "k1" in the CimInstance array should be "v1"' { - ($script:result | Where-Object Key -eq k1).Value | Should -Be 'v1' - } + Context 'When current value is of the wrong type' { + $currentValues = 1, 2, 3 - It 'Should return value "k2" in the CimInstance array should be "100"' { - ($script:result | Where-Object Key -eq k2).Value | Should -Be 100 + $desiredValues = @{ + String = 'a string' } - It 'Should return value "k3" in the CimInstance array should be "1,2,3"' { - ($script:result | Where-Object Key -eq k3).Value | Should -Be '1,2,3' + It 'Should throw exception' { + { $script:result = Test-DscParameterState ` + -CurrentValues $currentValues ` + -DesiredValues $desiredValues ` + -Verbose:$verbose } | Should -Throw } } } + } + + Describe 'ComputerManagementDsc.Common\Test-DscObjectHasProperty' { + # Use the Get-Verb cmdlet to just get a simple object fast + $testDscObject = (Get-Verb)[0] + + Context 'When the object contains the expected property' { + It 'Should not throw exception' { + { $script:result = Test-DscObjectHasProperty -Object $testDscObject -PropertyName 'Verb' -Verbose } | Should -Not -Throw + } + + It 'Should return $true' { + $script:result | Should -Be $true + } + } - Describe 'ComputerManagementDsc.Common\ConvertTo-HashTable' { - [CimInstance[]]$cimInstances = ConvertTo-CimInstance -Hashtable @{ - k1 = 'v1' - k2 = 100 - k3 = 1, 2, 3 + Context 'When the object does not contain the expected property' { + It 'Should not throw exception' { + { $script:result = Test-DscObjectHasProperty -Object $testDscObject -PropertyName 'Missing' -Verbose } | Should -Not -Throw } - Context 'When the array contains the expected record count' { - It 'Should not throw exception' { - { $script:result = $cimInstances | ConvertTo-HashTable } | Should -Not -Throw - } + It 'Should return $false' { + $script:result | Should -Be $false + } + } + } - It "Should return record count of $($cimInstances.Count)" { - $script:result.Count | Should -Be $cimInstances.Count - } + Describe 'ComputerManagementDsc.Common\ConvertTo-CimInstance' { + $hashtable = @{ + k1 = 'v1' + k2 = 100 + k3 = 1, 2, 3 + } - It 'Should return result of type [System.Collections.Hashtable]' { - $script:result | Should -BeOfType [System.Collections.Hashtable] - } + Context 'When the array contains the expected record count' { + It 'Should not throw exception' { + { $script:result = [CimInstance[]]($hashtable | ConvertTo-CimInstance) } | Should -Not -Throw + } - It 'Should return value "k1" in the hashtable should be "v1"' { - $script:result.k1 | Should -Be 'v1' - } + It "Should record count should be $($hashTable.Count)" { + $script:result.Count | Should -Be $hashtable.Count + } - It 'Should return value "k2" in the hashtable should be "100"' { - $script:result.k2 | Should -Be 100 + It 'Should return result of type CimInstance[]' { + $script:result.GetType().Name | Should -Be 'CimInstance[]' + } + + It 'Should return value "k1" in the CimInstance array should be "v1"' { + ($script:result | Where-Object Key -eq k1).Value | Should -Be 'v1' + } + + It 'Should return value "k2" in the CimInstance array should be "100"' { + ($script:result | Where-Object Key -eq k2).Value | Should -Be 100 + } + + It 'Should return value "k3" in the CimInstance array should be "1,2,3"' { + ($script:result | Where-Object Key -eq k3).Value | Should -Be '1,2,3' + } + } + } + + Describe 'ComputerManagementDsc.Common\ConvertTo-HashTable' { + [CimInstance[]]$cimInstances = ConvertTo-CimInstance -Hashtable @{ + k1 = 'v1' + k2 = 100 + k3 = 1, 2, 3 + } + + Context 'When the array contains the expected record count' { + It 'Should not throw exception' { + { $script:result = $cimInstances | ConvertTo-HashTable } | Should -Not -Throw + } + + It "Should return record count of $($cimInstances.Count)" { + $script:result.Count | Should -Be $cimInstances.Count + } + + It 'Should return result of type [System.Collections.Hashtable]' { + $script:result | Should -BeOfType [System.Collections.Hashtable] + } + + It 'Should return value "k1" in the hashtable should be "v1"' { + $script:result.k1 | Should -Be 'v1' + } + + It 'Should return value "k2" in the hashtable should be "100"' { + $script:result.k2 | Should -Be 100 + } + + It 'Should return value "k3" in the hashtable should be "1,2,3"' { + $script:result.k3 | Should -Be '1,2,3' + } + } + } + + Describe 'ComputerManagementDsc.Common\Get-TimeZoneId' { + Context '"Get-TimeZone" not available and current timezone is set to "Pacific Standard Time"' { + Mock ` + -CommandName Get-Command ` + -ParameterFilter { + $Name -eq 'Get-TimeZone' } - It 'Should return value "k3" in the hashtable should be "1,2,3"' { - $script:result.k3 | Should -Be '1,2,3' + Mock -CommandName Get-CimInstance -MockWith { + @{ + StandardName = 'Pacific Standard Time' } } - } - Describe 'ComputerManagementDsc.Common\Get-TimeZoneId' { - Context '"Get-TimeZone" not available and current timezone is set to "Pacific Standard Time"' { - Mock ` + It 'Returns "Pacific Standard Time"' { + Get-TimeZoneId | Should -Be 'Pacific Standard Time' + } + + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { $Name -eq 'Get-TimeZone' - } + } -Exactly -Times 1 - Mock -CommandName Get-CimInstance -MockWith { - @{ - StandardName = 'Pacific Standard Time' - } - } + Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 + } + } - It 'Returns "Pacific Standard Time"' { - Get-TimeZoneId | Should -Be 'Pacific Standard Time' + Context '"Get-TimeZone" not available and current timezone is set to "Russia TZ 11 Standard Time"' { + Mock ` + -CommandName Get-Command ` + -ParameterFilter { + $Name -eq 'Get-TimeZone' } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-Command ` - -ParameterFilter { - $Name -eq 'Get-TimeZone' - } -Exactly -Times 1 - - Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 + Mock -CommandName Get-CimInstance -MockWith { + @{ + StandardName = 'Russia TZ 11 Standard Time' } } - Context '"Get-TimeZone" not available and current timezone is set to "Russia TZ 11 Standard Time"' { - Mock ` + It 'Returns "Russia Time Zone 11"' { + Get-TimeZoneId | Should -Be 'Russia Time Zone 11' + } + + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { $Name -eq 'Get-TimeZone' - } + } -Exactly -Times 1 - Mock -CommandName Get-CimInstance -MockWith { - @{ - StandardName = 'Russia TZ 11 Standard Time' - } - } - - It 'Returns "Russia Time Zone 11"' { - Get-TimeZoneId | Should -Be 'Russia Time Zone 11' - } + Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-Command ` - -ParameterFilter { - $Name -eq 'Get-TimeZone' - } -Exactly -Times 1 + Context '"Get-TimeZone" available and current timezone is set to "Pacific Standard Time"' { + function Get-TimeZone + { + } - Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 + Mock ` + -CommandName Get-Command ` + -ParameterFilter { + $Name -eq 'Get-TimeZone' + } -MockWith { + 'Get-TimeZone' } - } - Context '"Get-TimeZone" available and current timezone is set to "Pacific Standard Time"' { - function Get-TimeZone - { + Mock ` + -CommandName Get-TimeZone ` + -MockWith { + @{ + StandardName = 'Pacific Standard Time' + } } - Mock ` + It 'Returns "Pacific Standard Time"' { + Get-TimeZoneId | Should -Be 'Pacific Standard Time' + } + + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { $Name -eq 'Get-TimeZone' - } -MockWith { - 'Get-TimeZone' - } - - Mock ` - -CommandName Get-TimeZone ` - -MockWith { - @{ - StandardName = 'Pacific Standard Time' - } - } + } -Exactly -Times 1 - It 'Returns "Pacific Standard Time"' { - Get-TimeZoneId | Should -Be 'Pacific Standard Time' - } + Assert-MockCalled -CommandName Get-TimeZone -Exactly -Times 1 + } + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-Command ` - -ParameterFilter { - $Name -eq 'Get-TimeZone' - } -Exactly -Times 1 + Describe 'ComputerManagementDsc.Common\Test-TimezoneId' { + Mock -CommandName Get-TimeZoneId -MockWith { + 'Russia Time Zone 11' + } - Assert-MockCalled -CommandName Get-TimeZone -Exactly -Times 1 - } + Context 'current timezone matches desired timezone' { + It 'Should return $true' { + Test-TimezoneId -TimeZoneId 'Russia Time Zone 11' | Should -BeTrue } } - Describe 'ComputerManagementDsc.Common\Test-TimezoneId' { - Mock -CommandName Get-TimeZoneId -MockWith { - 'Russia Time Zone 11' + Context 'current timezone does not match desired timezone' { + It 'Should return $false' { + Test-TimezoneId -TimeZoneId 'GMT Standard Time' | Should -BeFalse } + } + } - Context 'current timezone matches desired timezone' { - It 'Should return $true' { - Test-TimezoneId -TimeZoneId 'Russia Time Zone 11' | Should -BeTrue + Describe 'ComputerManagementDsc.Common\Set-TimeZoneId' { + Context '"Set-TimeZone" and "Add-Type" is not available, Tzutil Returns 0' { + Mock ` + -CommandName Get-Command ` + -ParameterFilter { + $Name -eq 'Add-Type' } - } - Context 'current timezone does not match desired timezone' { - It 'Should return $false' { - Test-TimezoneId -TimeZoneId 'GMT Standard Time' | Should -BeFalse + Mock ` + -CommandName Get-Command ` + -ParameterFilter { + $Name -eq 'Set-TimeZone' } + + Mock -CommandName 'TzUtil.exe' -MockWith { + $global:LASTEXITCODE = 0 + return 'OK' + } + + Mock -CommandName Add-Type + + It 'Should not throw an exception' { + { Set-TimeZoneId -TimezoneId 'Eastern Standard Time' } | Should -Not -Throw } - } - Describe 'ComputerManagementDsc.Common\Set-TimeZoneId' { - Context '"Set-TimeZone" and "Add-Type" is not available, Tzutil Returns 0' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { $Name -eq 'Add-Type' - } + } -Exactly -Times 1 - Mock ` + Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { $Name -eq 'Set-TimeZone' - } + } -Exactly -Times 1 - Mock -CommandName 'TzUtil.exe' -MockWith { - $global:LASTEXITCODE = 0 - return 'OK' - } + Assert-MockCalled -CommandName TzUtil.exe -Exactly -Times 1 + Assert-MockCalled -CommandName Add-Type -Exactly -Times 0 + } + } - Mock -CommandName Add-Type + Context '"Set-TimeZone" is not available but "Add-Type" is available' { + Mock ` + -CommandName Get-Command ` + -ParameterFilter { + $Name -eq 'Add-Type' + } -MockWith { + 'Add-Type' + } - It 'Should not throw an exception' { - { Set-TimeZoneId -TimezoneId 'Eastern Standard Time' } | Should -Not -Throw + Mock ` + -CommandName Get-Command ` + -ParameterFilter { + $Name -eq 'Set-TimeZone' } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-Command ` - -ParameterFilter { - $Name -eq 'Add-Type' - } -Exactly -Times 1 + Mock -CommandName 'TzUtil.exe' -MockWith { + $global:LASTEXITCODE = 0 + return 'OK' + } - Assert-MockCalled ` - -CommandName Get-Command ` - -ParameterFilter { - $Name -eq 'Set-TimeZone' - } -Exactly -Times 1 + Mock -CommandName Add-Type + Mock -CommandName Set-TimeZoneUsingDotNet - Assert-MockCalled -CommandName TzUtil.exe -Exactly -Times 1 - Assert-MockCalled -CommandName Add-Type -Exactly -Times 0 - } + It 'Should not throw an exception' { + { Set-TimeZoneId -TimezoneId 'Eastern Standard Time' } | Should -Not -Throw } - Context '"Set-TimeZone" is not available but "Add-Type" is available' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { $Name -eq 'Add-Type' - } -MockWith { - 'Add-Type' - } + } -Exactly -Times 1 - Mock ` + Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { $Name -eq 'Set-TimeZone' - } + } -Exactly -Times 1 - Mock -CommandName 'TzUtil.exe' -MockWith { - $global:LASTEXITCODE = 0 - return 'OK' - } + Assert-MockCalled -CommandName TzUtil.exe -Exactly -Times 0 + Assert-MockCalled -CommandName Add-Type -Exactly -Times 0 + Assert-MockCalled -CommandName Set-TimeZoneUsingDotNet -Exactly -Times 1 + } + } - Mock -CommandName Add-Type - Mock -CommandName Set-TimeZoneUsingDotNet + Context '"Set-TimeZone" is available' { + function Set-TimeZone + { + param + ( + [System.String] + $id + ) + } - It 'Should not throw an exception' { - { Set-TimeZoneId -TimezoneId 'Eastern Standard Time' } | Should -Not -Throw + Mock ` + -CommandName Get-Command ` + -ParameterFilter { + $Name -eq 'Add-Type' } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-Command ` - -ParameterFilter { - $Name -eq 'Add-Type' - } -Exactly -Times 1 + Mock ` + -CommandName Get-Command ` + -ParameterFilter { + $Name -eq 'Set-TimeZone' + } -MockWith { + 'Set-TimeZone' + } - Assert-MockCalled ` - -CommandName Get-Command ` - -ParameterFilter { - $Name -eq 'Set-TimeZone' - } -Exactly -Times 1 + Mock -CommandName Set-TimeZone - Assert-MockCalled -CommandName TzUtil.exe -Exactly -Times 0 - Assert-MockCalled -CommandName Add-Type -Exactly -Times 0 - Assert-MockCalled -CommandName Set-TimeZoneUsingDotNet -Exactly -Times 1 - } + It 'Should not throw an exception' { + { Set-TimeZoneId -TimezoneId 'Eastern Standard Time' } | Should -Not -Throw } - Context '"Set-TimeZone" is available' { - function Set-TimeZone - { - param - ( - [System.String] - $id - ) - } - - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { $Name -eq 'Add-Type' - } + } -Exactly -Times 0 - Mock ` + Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { $Name -eq 'Set-TimeZone' - } -MockWith { - 'Set-TimeZone' - } + } -Exactly -Times 1 - Mock -CommandName Set-TimeZone + Assert-MockCalled -CommandName Set-TimeZone -Exactly -Times 1 + } + } + } - It 'Should not throw an exception' { - { Set-TimeZoneId -TimezoneId 'Eastern Standard Time' } | Should -Not -Throw - } + Describe 'ComputerManagementDsc.Common\Get-PowerPlan' { + $mockBalancedPowerPlan = @{ + FriendlyName = 'Balanced' + Guid = [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-Command ` - -ParameterFilter { - $Name -eq 'Add-Type' - } -Exactly -Times 0 + $mockHighPerformancePowerPlan = @{ + 'FriendlyName' = 'High performance' + 'Guid' = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } - Assert-MockCalled ` - -CommandName Get-Command ` - -ParameterFilter { - $Name -eq 'Set-TimeZone' - } -Exactly -Times 1 + $mockPowerSaverPowerPlan = @{ + 'FriendlyName' = 'Power saver' + 'Guid' = [System.Guid]'a1841308-3541-4fab-bc81-f71556f20b4a' + } - Assert-MockCalled -CommandName Set-TimeZone -Exactly -Times 1 + Context 'Only one power plan is available and "PowerPlan" parameter is not specified' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return $mockBalancedPowerPlan } - } - } - Describe 'ComputerManagementDsc.Common\Get-PowerPlan' { - $mockBalancedPowerPlan = @{ - FriendlyName = 'Balanced' - Guid = [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' + It 'Should not throw an exception' { + { Get-PowerPlan } | Should -Not -Throw } - $mockHighPerformancePowerPlan = @{ - 'FriendlyName' = 'High performance' - 'Guid' = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-PowerPlanUsingPInvoke ` + -Exactly -Times 1 } - $mockPowerSaverPowerPlan = @{ - 'FriendlyName' = 'Power saver' - 'Guid' = [System.Guid]'a1841308-3541-4fab-bc81-f71556f20b4a' + It 'Should return exactly one hashtable' { + $result = Get-PowerPlan + $result | Should -BeOfType [System.Collections.Hashtable] + $result | Should -HaveCount 1 } - Context 'Only one power plan is available and "PowerPlan" parameter is not specified' { - Mock ` - -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return $mockBalancedPowerPlan - } - - It 'Should not throw an exception' { - { Get-PowerPlan } | Should -Not -Throw - } - - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 - } + } - It 'Should return exactly one hashtable' { - $result = Get-PowerPlan - $result | Should -BeOfType [System.Collections.Hashtable] - $result | Should -HaveCount 1 + Context 'Only one power plan is available and "PowerPlan" parameter is specified as Guid of the available plan' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return $mockBalancedPowerPlan } + It 'Should not throw an exception' { + { Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e' } | Should -Not -Throw } - Context 'Only one power plan is available and "PowerPlan" parameter is specified as Guid of the available plan' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return $mockBalancedPowerPlan - } + -Exactly -Times 1 + } - It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e' } | Should -Not -Throw - } + It 'Should return a hashtable with the name and guid fo the power plan' { + $result = Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e' + $result | Should -BeOfType [System.Collections.Hashtable] + $result | Should -HaveCount 1 + $result.FriendlyName | Should -Be 'Balanced' + $result.guid | Should -Be '381b4222-f694-41f0-9685-ff5bb260df2e' + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 + Context 'Only one power plan is available and "PowerPlan" parameter is specified as Guid of a not available plan' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return $mockBalancedPowerPlan } - It 'Should return a hashtable with the name and guid fo the power plan' { - $result = Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e' - $result | Should -BeOfType [System.Collections.Hashtable] - $result | Should -HaveCount 1 - $result.FriendlyName | Should -Be 'Balanced' - $result.guid | Should -Be '381b4222-f694-41f0-9685-ff5bb260df2e' - } + It 'Should not throw an exception' { + { Get-PowerPlan -PowerPlan '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } | Should -Not -Throw } - Context 'Only one power plan is available and "PowerPlan" parameter is specified as Guid of a not available plan' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return $mockBalancedPowerPlan - } + -Exactly -Times 1 + } - It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } | Should -Not -Throw - } + It 'Should return nothing' { + $result = Get-PowerPlan -PowerPlan '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + $result | Should -BeNullOrEmpty + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 + Context 'Only one power plan is available and "PowerPlan" parameter is specified as name of the available plan' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return $mockBalancedPowerPlan } - It 'Should return nothing' { - $result = Get-PowerPlan -PowerPlan '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - $result | Should -BeNullOrEmpty - } + It 'Should not throw an exception' { + { Get-PowerPlan -PowerPlan 'Balanced' } | Should -Not -Throw } - Context 'Only one power plan is available and "PowerPlan" parameter is specified as name of the available plan' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return $mockBalancedPowerPlan - } + -Exactly -Times 1 + } - It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan 'Balanced' } | Should -Not -Throw - } + It 'Should return a hashtable with the name and guid fo the power plan' { + $result = Get-PowerPlan -PowerPlan 'Balanced' + $result | Should -BeOfType [System.Collections.Hashtable] + $result | Should -HaveCount 1 + $result.FriendlyName | Should -Be 'Balanced' + $result.guid | Should -Be '381b4222-f694-41f0-9685-ff5bb260df2e' + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 + Context 'Only one power plan is available and "PowerPlan" parameter is specified as name of a not available plan' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return $mockBalancedPowerPlan } - It 'Should return a hashtable with the name and guid fo the power plan' { - $result = Get-PowerPlan -PowerPlan 'Balanced' - $result | Should -BeOfType [System.Collections.Hashtable] - $result | Should -HaveCount 1 - $result.FriendlyName | Should -Be 'Balanced' - $result.guid | Should -Be '381b4222-f694-41f0-9685-ff5bb260df2e' - } + It 'Should not throw an exception' { + { Get-PowerPlan -PowerPlan 'High performance' } | Should -Not -Throw } - Context 'Only one power plan is available and "PowerPlan" parameter is specified as name of a not available plan' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return $mockBalancedPowerPlan - } + -Exactly -Times 1 + } - It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan 'High performance' } | Should -Not -Throw - } + It 'Should return nothing' { + $result = Get-PowerPlan -PowerPlan 'High performance' + $result | Should -BeNullOrEmpty + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 + Context 'Multiple power plans are available and "PowerPlan" parameter is not specified' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) } - It 'Should return nothing' { - $result = Get-PowerPlan -PowerPlan 'High performance' - $result | Should -BeNullOrEmpty - } + It 'Should not throw an exception' { + { Get-PowerPlan } | Should -Not -Throw } - Context 'Multiple power plans are available and "PowerPlan" parameter is not specified' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + -Exactly -Times 1 + } - It 'Should not throw an exception' { - { Get-PowerPlan } | Should -Not -Throw - } + It 'Should return an array with all available plans' { + $result = Get-PowerPlan + $result | Should -HaveCount 3 + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 + Context 'Multiple power plans are available and "PowerPlan" parameter is specified as Guid of an available plan' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) } - It 'Should return an array with all available plans' { - $result = Get-PowerPlan - $result | Should -HaveCount 3 - } + It 'Should not throw an exception' { + { Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e'} | Should -Not -Throw } - Context 'Multiple power plans are available and "PowerPlan" parameter is specified as Guid of an available plan' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + -Exactly -Times 1 + } - It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e'} | Should -Not -Throw - } + It 'Should return a hashtable with the name and guid fo the power plan' { + $result = Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e' + $result | Should -BeOfType [System.Collections.Hashtable] + $result | Should -HaveCount 1 + $result.FriendlyName | Should -Be 'Balanced' + $result.guid | Should -Be '381b4222-f694-41f0-9685-ff5bb260df2e' + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 + Context 'Multiple power plans are available and "PowerPlan" parameter is specified as Guid of a not available plan' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) } - It 'Should return a hashtable with the name and guid fo the power plan' { - $result = Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e' - $result | Should -BeOfType [System.Collections.Hashtable] - $result | Should -HaveCount 1 - $result.FriendlyName | Should -Be 'Balanced' - $result.guid | Should -Be '381b4222-f694-41f0-9685-ff5bb260df2e' - } + It 'Should not throw an exception' { + { Get-PowerPlan -PowerPlan '9c5e7fda-e8bf-4a96-9a85-a7e23a8c635c'} | Should -Not -Throw } - Context 'Multiple power plans are available and "PowerPlan" parameter is specified as Guid of a not available plan' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + -Exactly -Times 1 + } - It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan '9c5e7fda-e8bf-4a96-9a85-a7e23a8c635c'} | Should -Not -Throw - } + It 'Should return nothing' { + $result = Get-PowerPlan -PowerPlan '9c5e7fda-e8bf-4a96-9a85-a7e23a8c635c' + $result | Should -BeNullOrEmpty + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 + Context 'Multiple power plans are available and "PowerPlan" parameter is specified as name of an available plan' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) } - It 'Should return nothing' { - $result = Get-PowerPlan -PowerPlan '9c5e7fda-e8bf-4a96-9a85-a7e23a8c635c' - $result | Should -BeNullOrEmpty - } + It 'Should not throw an exception' { + { Get-PowerPlan -PowerPlan 'High performance'} | Should -Not -Throw } - Context 'Multiple power plans are available and "PowerPlan" parameter is specified as name of an available plan' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + -Exactly -Times 1 + } - It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan 'High performance'} | Should -Not -Throw - } + It 'Should return a hashtable with the name and guid fo the power plan' { + $result = Get-PowerPlan -PowerPlan 'High performance' + $result | Should -BeOfType [System.Collections.Hashtable] + $result | Should -HaveCount 1 + $result.FriendlyName | Should -Be 'High performance' + $result.guid | Should -Be '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 + Context 'Multiple power plans are available and "PowerPlan" parameter is specified as name of a not available plan' { + Mock ` + -CommandName Get-PowerPlanUsingPInvoke ` + -MockWith { + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) } - It 'Should return a hashtable with the name and guid fo the power plan' { - $result = Get-PowerPlan -PowerPlan 'High performance' - $result | Should -BeOfType [System.Collections.Hashtable] - $result | Should -HaveCount 1 - $result.FriendlyName | Should -Be 'High performance' - $result.guid | Should -Be '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } + It 'Should not throw an exception' { + { Get-PowerPlan -PowerPlan 'Some unavailable plan'} | Should -Not -Throw } - Context 'Multiple power plans are available and "PowerPlan" parameter is specified as name of a not available plan' { - Mock ` + It 'Should call expected mocks' { + Assert-MockCalled ` -CommandName Get-PowerPlanUsingPInvoke ` - -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + -Exactly -Times 1 + } - It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan 'Some unavailable plan'} | Should -Not -Throw - } + It 'Should return nothing' { + $result = Get-PowerPlan -PowerPlan 'Some unavailable plan' + $result | Should -BeNullOrEmpty + } + } + } - It 'Should call expected mocks' { - Assert-MockCalled ` - -CommandName Get-PowerPlanUsingPInvoke ` - -Exactly -Times 1 - } + Describe 'DscResource.LocalizationHelper\Get-LocalizedData' { + $mockTestPath = { + return $mockTestPathReturnValue + } - It 'Should return nothing' { - $result = Get-PowerPlan -PowerPlan 'Some unavailable plan' - $result | Should -BeNullOrEmpty - } - } + $mockImportLocalizedData = { + $BaseDirectory | Should -Be $mockExpectedLanguagePath } - Describe 'DscResource.LocalizationHelper\Get-LocalizedData' { - $mockTestPath = { - return $mockTestPathReturnValue - } + BeforeEach { + Mock -CommandName Test-Path -MockWith $mockTestPath -Verifiable + Mock -CommandName Import-LocalizedData -MockWith $mockImportLocalizedData -Verifiable + } - $mockImportLocalizedData = { - $BaseDirectory | Should -Be $mockExpectedLanguagePath + Context 'When loading localized data for Swedish' { + $mockExpectedLanguagePath = 'sv-SE' + $mockTestPathReturnValue = $true + + It 'Should call Import-LocalizedData with sv-SE language' { + Mock -CommandName Join-Path -MockWith { + return 'sv-SE' + } -Verifiable + + { Get-LocalizedData -ResourceName 'DummyResource' } | Should -Not -Throw + + Assert-MockCalled -CommandName Join-Path -Exactly -Times 3 -Scope It + Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It + Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It } - BeforeEach { - Mock -CommandName Test-Path -MockWith $mockTestPath -Verifiable - Mock -CommandName Import-LocalizedData -MockWith $mockImportLocalizedData -Verifiable + $mockExpectedLanguagePath = 'en-US' + $mockTestPathReturnValue = $false + + It 'Should call Import-LocalizedData and fallback to en-US if sv-SE language does not exist' { + Mock -CommandName Join-Path -MockWith { + return $ChildPath + } -Verifiable + + { Get-LocalizedData -ResourceName 'DummyResource' } | Should -Not -Throw + + Assert-MockCalled -CommandName Join-Path -Exactly -Times 4 -Scope It + Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It + Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It } - Context 'When loading localized data for Swedish' { + Context 'When $ScriptRoot is set to a path' { $mockExpectedLanguagePath = 'sv-SE' $mockTestPathReturnValue = $true @@ -1620,9 +1653,9 @@ try return 'sv-SE' } -Verifiable - { Get-LocalizedData -ResourceName 'DummyResource' } | Should -Not -Throw + { Get-LocalizedData -ResourceName 'DummyResource' -ScriptRoot '.' } | Should -Not -Throw - Assert-MockCalled -CommandName Join-Path -Exactly -Times 3 -Scope It + Assert-MockCalled -CommandName Join-Path -Exactly -Times 1 -Scope It Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It } @@ -1635,148 +1668,111 @@ try return $ChildPath } -Verifiable - { Get-LocalizedData -ResourceName 'DummyResource' } | Should -Not -Throw + { Get-LocalizedData -ResourceName 'DummyResource' -ScriptRoot '.' } | Should -Not -Throw - Assert-MockCalled -CommandName Join-Path -Exactly -Times 4 -Scope It + Assert-MockCalled -CommandName Join-Path -Exactly -Times 2 -Scope It Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It } + } + } - Context 'When $ScriptRoot is set to a path' { - $mockExpectedLanguagePath = 'sv-SE' - $mockTestPathReturnValue = $true - - It 'Should call Import-LocalizedData with sv-SE language' { - Mock -CommandName Join-Path -MockWith { - return 'sv-SE' - } -Verifiable - - { Get-LocalizedData -ResourceName 'DummyResource' -ScriptRoot '.' } | Should -Not -Throw - - Assert-MockCalled -CommandName Join-Path -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It - } - - $mockExpectedLanguagePath = 'en-US' - $mockTestPathReturnValue = $false - - It 'Should call Import-LocalizedData and fallback to en-US if sv-SE language does not exist' { - Mock -CommandName Join-Path -MockWith { - return $ChildPath - } -Verifiable + Context 'When loading localized data for English' { + Mock -CommandName Join-Path -MockWith { + return 'en-US' + } -Verifiable - { Get-LocalizedData -ResourceName 'DummyResource' -ScriptRoot '.' } | Should -Not -Throw + $mockExpectedLanguagePath = 'en-US' + $mockTestPathReturnValue = $true - Assert-MockCalled -CommandName Join-Path -Exactly -Times 2 -Scope It - Assert-MockCalled -CommandName Test-Path -Exactly -Times 1 -Scope It - Assert-MockCalled -CommandName Import-LocalizedData -Exactly -Times 1 -Scope It - } - } + It 'Should call Import-LocalizedData with en-US language' { + { Get-LocalizedData -ResourceName 'DummyResource' } | Should -Not -Throw } + } - Context 'When loading localized data for English' { - Mock -CommandName Join-Path -MockWith { - return 'en-US' - } -Verifiable + Assert-VerifiableMock + } - $mockExpectedLanguagePath = 'en-US' - $mockTestPathReturnValue = $true + Describe 'DscResource.LocalizationHelper\New-InvalidOperationException' { + Context 'When calling with Message parameter only' { + It 'Should throw the correct error' { + $mockErrorMessage = 'Mocked error' - It 'Should call Import-LocalizedData with en-US language' { - { Get-LocalizedData -ResourceName 'DummyResource' } | Should -Not -Throw - } + { New-InvalidOperationException -Message $mockErrorMessage } | Should -Throw $mockErrorMessage } - - Assert-VerifiableMock } - Describe 'DscResource.LocalizationHelper\New-InvalidOperationException' { - Context 'When calling with Message parameter only' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' + Context 'When calling with both the Message and ErrorRecord parameter' { + It 'Should throw the correct error' { + $mockErrorMessage = 'Mocked error' + $mockExceptionErrorMessage = 'Mocked exception error message' - { New-InvalidOperationException -Message $mockErrorMessage } | Should -Throw $mockErrorMessage - } + $mockException = New-Object -TypeName System.Exception -ArgumentList $mockExceptionErrorMessage + $mockErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList $mockException, $null, 'InvalidResult', $null + + { New-InvalidOperationException -Message $mockErrorMessage -ErrorRecord $mockErrorRecord } | Should -Throw ('System.InvalidOperationException: {0} ---> System.Exception: {1}' -f $mockErrorMessage, $mockExceptionErrorMessage) } + } - Context 'When calling with both the Message and ErrorRecord parameter' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - $mockExceptionErrorMessage = 'Mocked exception error message' + Assert-VerifiableMock + } - $mockException = New-Object -TypeName System.Exception -ArgumentList $mockExceptionErrorMessage - $mockErrorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord -ArgumentList $mockException, $null, 'InvalidResult', $null + Describe 'DscResource.LocalizationHelper\New-InvalidArgumentException' { + Context 'When calling with both the Message and ArgumentName parameter' { + It 'Should throw the correct error' { + $mockErrorMessage = 'Mocked error' + $mockArgumentName = 'MockArgument' - { New-InvalidOperationException -Message $mockErrorMessage -ErrorRecord $mockErrorRecord } | Should -Throw ('System.InvalidOperationException: {0} ---> System.Exception: {1}' -f $mockErrorMessage, $mockExceptionErrorMessage) - } + { New-InvalidArgumentException -Message $mockErrorMessage -ArgumentName $mockArgumentName } | Should -Throw ('Parameter name: {0}' -f $mockArgumentName) } - - Assert-VerifiableMock } - Describe 'DscResource.LocalizationHelper\New-InvalidArgumentException' { - Context 'When calling with both the Message and ArgumentName parameter' { - It 'Should throw the correct error' { - $mockErrorMessage = 'Mocked error' - $mockArgumentName = 'MockArgument' + Assert-VerifiableMock + } - { New-InvalidArgumentException -Message $mockErrorMessage -ArgumentName $mockArgumentName } | Should -Throw ('Parameter name: {0}' -f $mockArgumentName) + Describe 'DscResource.LocalizationHelper\Test-IsNanoServer' { + Context 'When the cmdlet Get-ComputerInfo does not exist' { + BeforeAll { + Mock -CommandName Test-Command { + return $false } } - Assert-VerifiableMock + Test-IsNanoServer | Should -BeFalse } - Describe 'DscResource.LocalizationHelper\Test-IsNanoServer' { - Context 'When the cmdlet Get-ComputerInfo does not exist' { - BeforeAll { - Mock -CommandName Test-Command { - return $false - } + Context 'When the current computer is a Nano server' { + BeforeAll { + Mock -CommandName Test-Command { + return $true } - Test-IsNanoServer | Should -BeFalse - } - - Context 'When the current computer is a Nano server' { - BeforeAll { - Mock -CommandName Test-Command { - return $true - } - - Mock -CommandName Get-ComputerInfo { - return @{ - OsProductType = 'Server' - OsServerLevel = 'NanoServer' - } + Mock -CommandName Get-ComputerInfo { + return @{ + OsProductType = 'Server' + OsServerLevel = 'NanoServer' } } - - Test-IsNanoServer | Should -BeTrue } - Context 'When the current computer is not a Nano server' { - BeforeAll { - Mock -CommandName Test-Command { - return $true - } + Test-IsNanoServer | Should -BeTrue + } - Mock -CommandName Get-ComputerInfo { - return @{ - OsProductType = 'Server' - OsServerLevel = 'FullServer' - } - } + Context 'When the current computer is not a Nano server' { + BeforeAll { + Mock -CommandName Test-Command { + return $true } - Test-IsNanoServer | Should -BeFalse + Mock -CommandName Get-ComputerInfo { + return @{ + OsProductType = 'Server' + OsServerLevel = 'FullServer' + } + } } + + Test-IsNanoServer | Should -BeFalse } } } -finally -{ - #region FOOTER - #endregion -} diff --git a/tests/Unit/MSFT_Computer.Tests.ps1 b/tests/Unit/DSC_Computer.Tests.ps1 similarity index 99% rename from tests/Unit/MSFT_Computer.Tests.ps1 rename to tests/Unit/DSC_Computer.Tests.ps1 index aac5566e..834d4eae 100644 --- a/tests/Unit/MSFT_Computer.Tests.ps1 +++ b/tests/Unit/DSC_Computer.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_Computer' +$script:dscResourceName = 'DSC_Computer' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -27,7 +27,7 @@ try #region Pester Tests InModuleScope $script:dscResourceName { - $script:dscResourceName = 'MSFT_Computer' + $script:dscResourceName = 'DSC_Computer' Describe $script:dscResourceName { # A real password isn't needed here - use this next line to avoid triggering PSSA rule diff --git a/tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 b/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 similarity index 98% rename from tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 rename to tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 index a241c79d..0f53badf 100644 --- a/tests/Unit/MSFT_OfflineDomainJoin.Tests.ps1 +++ b/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_OfflineDomainJoin' +$script:dscResourceName = 'DSC_OfflineDomainJoin' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -26,7 +26,7 @@ try { #region Pester Tests InModuleScope $script:dscResourceName { - $script:dscResourceName = 'MSFT_OfflineDomainJoin' + $script:dscResourceName = 'DSC_OfflineDomainJoin' $testOfflineDomainJoin = @{ IsSingleInstance = 'Yes' diff --git a/tests/Unit/MSFT_PendingReboot.Tests.ps1 b/tests/Unit/DSC_PendingReboot.Tests.ps1 similarity index 94% rename from tests/Unit/MSFT_PendingReboot.Tests.ps1 rename to tests/Unit/DSC_PendingReboot.Tests.ps1 index 99fc6801..9c99100b 100644 --- a/tests/Unit/MSFT_PendingReboot.Tests.ps1 +++ b/tests/Unit/DSC_PendingReboot.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_PendingReboot' +$script:dscResourceName = 'DSC_PendingReboot' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -72,11 +72,11 @@ try } } - Describe 'MSFT_PendingReboot\Get-TargetResource' { + Describe 'DSC_PendingReboot\Get-TargetResource' { Context 'When all reboots are required' { Mock -CommandName Get-PendingRebootState ` -MockWith $getPendingRebootStateAllRebootsTrue ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable It 'Should not throw an exception' { @@ -108,7 +108,7 @@ try Context 'When no reboots are required' { Mock -CommandName Get-PendingRebootState ` -MockWith $getPendingRebootStateAllRebootsFalse ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable It 'Should not throw an exception' { @@ -138,13 +138,13 @@ try } } - Describe 'MSFT_PendingReboot\Set-TargetResource' { + Describe 'DSC_PendingReboot\Set-TargetResource' { Context 'When a reboot is not required' { $global:DSCMachineStatus = 0 Mock -CommandName Get-PendingRebootState ` -MockWith $getPendingRebootStateAllRebootsTrue ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable It 'Should not throw an exception' { @@ -163,7 +163,7 @@ try Mock -CommandName Get-PendingRebootState ` -MockWith $getPendingRebootStateAllRebootsFalse ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable It 'Should not throw an exception' { @@ -178,11 +178,11 @@ try } } - Describe 'MSFT_PendingReboot\Test-TargetResource' { + Describe 'DSC_PendingReboot\Test-TargetResource' { Context 'When a reboot is required' { Mock -CommandName Get-PendingRebootState ` -MockWith $getPendingRebootStateAllRebootsTrue ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable It 'Should not throw an exception' { @@ -201,7 +201,7 @@ try Mock -CommandName Get-PendingRebootState ` -MockWith $getPendingRebootStateAllRebootsFalse ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable It 'Should not throw an exception' { @@ -216,7 +216,7 @@ try } } - Describe 'MSFT_PendingReboot\Get-PendingRebootHashTable' { + Describe 'DSC_PendingReboot\Get-PendingRebootHashTable' { BeforeAll { $getChildItemComponentBasedServicingMock = { @{ @@ -285,36 +285,36 @@ try Mock -CommandName Get-ChildItem ` -MockWith $getChildItemComponentBasedServicingMock ` -ParameterFilter $getChildItemComponentBasedServicingParameterFilter ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Get-ChildItem ` -MockWith $getChildItemAutoUpdateMock ` -ParameterFilter $getChildItemAutoUpdateParameterFilter ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Get-ItemProperty ` -MockWith $getItemPropertyFileRenameMock ` -ParameterFilter $getItemPropertyFileRenameParameterFilter ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Get-ItemProperty ` -MockWith $getItemPropertyActiveComputerNameMock ` -ParameterFilter $getItemPropertyActiveComputerNameFilter ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Get-ItemProperty ` -MockWith $getItemPropertyComputerNameMock ` -ParameterFilter $getItemPropertyComputerNameFilter ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Invoke-CimMethod ` -MockWith $invokeCimMethodRebootPendingMock ` - -ModuleName 'MSFT_PendingReboot' + -ModuleName 'DSC_PendingReboot' } Context 'When SkipCcmClientSdk is set to False' { @@ -378,12 +378,12 @@ try BeforeAll { Mock -CommandName Get-ChildItem ` -ParameterFilter $getChildItemComponentBasedServicingParameterFilter ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Get-ChildItem ` -ParameterFilter $getChildItemAutoUpdateParameterFilter ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Get-ItemProperty ` @@ -392,7 +392,7 @@ try PendingFileRenameOperations = @() } } ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Get-ItemProperty ` @@ -400,7 +400,7 @@ try @{ } } ` -ParameterFilter $getItemPropertyActiveComputerNameFilter ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Get-ItemProperty ` @@ -408,12 +408,12 @@ try @{ } } ` -ParameterFilter $getItemPropertyComputerNameFilter ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable Mock -CommandName Invoke-CimMethod ` -MockWith $invokeCimMethodRebootNotPendingMock ` - -ModuleName 'MSFT_PendingReboot' + -ModuleName 'DSC_PendingReboot' } Context 'When SkipCcmClientSdk is set to False' { @@ -472,7 +472,7 @@ try } } - Describe 'MSFT_PendingReboot\Get-PendingRebootState' { + Describe 'DSC_PendingReboot\Get-PendingRebootState' { $getPendingRebootStateObject = @{ Name = $script:testResourceName SkipComponentBasedServicing = $false @@ -512,7 +512,7 @@ try -MockWith { $getPendingRebootStateMock } ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable } @@ -545,7 +545,7 @@ try -MockWith { $getPendingRebootStateMock } ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable } @@ -575,7 +575,7 @@ try -MockWith { $getPendingRebootStateMock } ` - -ModuleName 'MSFT_PendingReboot' ` + -ModuleName 'DSC_PendingReboot' ` -Verifiable } diff --git a/tests/Unit/MSFT_PowerPlan.Tests.ps1 b/tests/Unit/DSC_PowerPlan.Tests.ps1 similarity index 99% rename from tests/Unit/MSFT_PowerPlan.Tests.ps1 rename to tests/Unit/DSC_PowerPlan.Tests.ps1 index fba0fa0e..37e94800 100644 --- a/tests/Unit/MSFT_PowerPlan.Tests.ps1 +++ b/tests/Unit/DSC_PowerPlan.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_PowerPlan' +$script:dscResourceName = 'DSC_PowerPlan' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global diff --git a/tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 b/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 similarity index 98% rename from tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 rename to tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 index f3c16ca3..c5b72ea8 100644 --- a/tests/Unit/MSFT_PowerShellExecutionpolicy.Tests.ps1 +++ b/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_PowershellExecutionPolicy' +$script:dscResourceName = 'DSC_PowershellExecutionPolicy' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -43,7 +43,7 @@ try (non-exported) code of a Script Module. #> InModuleScope $script:dscResourceName { - $script:dscResourceName = 'MSFT_PowershellExecutionPolicy' + $script:dscResourceName = 'DSC_PowershellExecutionPolicy' #region Function Get-TargetResource Describe "$($script:dscResourceName)\Get-TargetResource" { diff --git a/tests/Unit/MSFT_RemoteDesktopAdmin.Tests.ps1 b/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 similarity index 97% rename from tests/Unit/MSFT_RemoteDesktopAdmin.Tests.ps1 rename to tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 index 14aa5776..cb44c5cf 100644 --- a/tests/Unit/MSFT_RemoteDesktopAdmin.Tests.ps1 +++ b/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_RemoteDesktopAdmin' +$script:dscResourceName = 'DSC_RemoteDesktopAdmin' # Unit Test Template Version: 1.2.4 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) @@ -54,7 +54,7 @@ try UserAuthentication = 'NonSecure' } - Describe 'MSFT_RemoteDesktopAdmin\Get-TargetResource' { + Describe 'DSC_RemoteDesktopAdmin\Get-TargetResource' { Context 'When Remote Desktop Admin settings exist' { It 'Should return the correct values when Ensure is Present' { Mock -CommandName Get-ItemProperty ` @@ -110,7 +110,7 @@ try } } - Describe 'MSFT_RemoteDesktopAdmin\Test-TargetResource' { + Describe 'DSC_RemoteDesktopAdmin\Test-TargetResource' { Context 'When the system is in the desired state' { It 'Should return true when Ensure is present' { Mock -CommandName Get-TargetResource ` @@ -184,7 +184,7 @@ try } } - Describe 'MSFT_RemoteDesktopAdmin\Set-TargetResource' { + Describe 'DSC_RemoteDesktopAdmin\Set-TargetResource' { Context 'When the state needs to be changed' { BeforeEach { Mock -CommandName Set-ItemProperty diff --git a/tests/Unit/MSFT_ScheduledTask.Tests.ps1 b/tests/Unit/DSC_ScheduledTask.Tests.ps1 similarity index 99% rename from tests/Unit/MSFT_ScheduledTask.Tests.ps1 rename to tests/Unit/DSC_ScheduledTask.Tests.ps1 index 4ab23467..63229bf3 100644 --- a/tests/Unit/MSFT_ScheduledTask.Tests.ps1 +++ b/tests/Unit/DSC_ScheduledTask.Tests.ps1 @@ -5,7 +5,7 @@ param #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_ScheduledTask' +$script:dscResourceName = 'DSC_ScheduledTask' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -35,7 +35,7 @@ try #region Pester Tests InModuleScope $script:dscResourceName { - $script:dscResourceName = 'MSFT_ScheduledTask' + $script:dscResourceName = 'DSC_ScheduledTask' # Function to allow mocking pipeline input function Register-ScheduledTask @@ -2174,7 +2174,7 @@ try } } - Describe 'MSFT_ScheduledTask\Test-DateStringContainsTimeZone' { + Describe 'DSC_ScheduledTask\Test-DateStringContainsTimeZone' { Context 'When the date string contains a date without a timezone' { It 'Should return $false' { Test-DateStringContainsTimeZone -DateString '2018-10-01T01:00:00' | Should -BeFalse diff --git a/tests/Unit/MSFT_SmbServerConfiguration.Tests.ps1 b/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 similarity index 98% rename from tests/Unit/MSFT_SmbServerConfiguration.Tests.ps1 rename to tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 index 572ca376..758f55a0 100644 --- a/tests/Unit/MSFT_SmbServerConfiguration.Tests.ps1 +++ b/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_SmbServerConfiguration' +$script:dscResourceName = 'DSC_SmbServerConfiguration' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -300,7 +300,7 @@ try ValidateTargetName = $true } - Describe 'MSFT_SmbServerConfiguration\Get-TargetResource' -Tag 'Get' { + Describe 'DSC_SmbServerConfiguration\Get-TargetResource' -Tag 'Get' { Context 'When getting the Target Resource information' { It 'Should get the current SMB server configuration state' { $SmbServerConfiguration = Get-TargetResource -IsSingleInstance Yes @@ -351,7 +351,7 @@ try } } - Describe 'MSFT_SmbServerConfiguration\Test-TargetResource' -Tag 'Test' { + Describe 'DSC_SmbServerConfiguration\Test-TargetResource' -Tag 'Test' { Context 'When the SMB Server is in the desired state' { It 'Test-TargetResource should return true' { Mock -CommandName Get-SmbServerConfiguration { return $mocks.DefaultSettings } @@ -378,7 +378,7 @@ try } } - Describe 'MSFT_SmbServerConfiguration\Set-TargetResource' -Tag 'Set' { + Describe 'DSC_SmbServerConfiguration\Set-TargetResource' -Tag 'Set' { Context 'When configuration is required' { It 'Runs the Set-SmbServerConfiguration cmdlet when the needs to be changed' -TestCases $testCases { param ($smbSetting, $newValue) diff --git a/tests/Unit/MSFT_SmbShare.Tests.ps1 b/tests/Unit/DSC_SmbShare.Tests.ps1 similarity index 99% rename from tests/Unit/MSFT_SmbShare.Tests.ps1 rename to tests/Unit/DSC_SmbShare.Tests.ps1 index e1df49fb..fb359195 100644 --- a/tests/Unit/MSFT_SmbShare.Tests.ps1 +++ b/tests/Unit/DSC_SmbShare.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_SmbShare' +$script:dscResourceName = 'DSC_SmbShare' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -103,7 +103,7 @@ try ) ) - Describe 'MSFT_SmbShare\Get-TargetResource' -Tag 'Get' { + Describe 'DSC_SmbShare\Get-TargetResource' -Tag 'Get' { Context 'When the system is in the desired state' { BeforeAll { Mock -CommandName Get-SmbShare -MockWith { @@ -179,7 +179,7 @@ try } } - Describe 'MSFT_SmbShare\Set-TargetResource' -Tag 'Set' { + Describe 'DSC_SmbShare\Set-TargetResource' -Tag 'Set' { Context 'When the system is not in the desired state' { BeforeAll { Mock -CommandName New-SmbShare @@ -439,7 +439,7 @@ try } } - Describe 'MSFT_SmbShare\Test-TargetResource' -Tag 'Test' { + Describe 'DSC_SmbShare\Test-TargetResource' -Tag 'Test' { Context 'When the system is not in the desired state' { Context 'When no member are provided in any of the access permission collections' { BeforeAll { @@ -731,7 +731,7 @@ try } } - Describe 'MSFT_SmbShare\Add-SmbShareAccessPermission' -Tag 'Helper' { + Describe 'DSC_SmbShare\Add-SmbShareAccessPermission' -Tag 'Helper' { BeforeAll { Mock -CommandName Grant-SmbShareAccess Mock -CommandName Block-SmbShareAccess @@ -914,7 +914,7 @@ try } } - Describe 'MSFT_SmbShare\Remove-SmbShareAccessPermission' -Tag 'Helper' { + Describe 'DSC_SmbShare\Remove-SmbShareAccessPermission' -Tag 'Helper' { BeforeAll { Mock -CommandName Revoke-SmbShareAccess Mock -CommandName Unblock-SmbShareAccess @@ -1120,7 +1120,7 @@ try } } - Describe 'MSFT_SmbShare\Assert-AccessPermissionParameters' -Tag 'Helper' { + Describe 'DSC_SmbShare\Assert-AccessPermissionParameters' -Tag 'Helper' { Context 'When asserting correct provided access permissions parameters' { Context 'When providing at least one member in one of the access permission collections' { BeforeAll { diff --git a/tests/Unit/MSFT_SystemLocale.Tests.ps1 b/tests/Unit/DSC_SystemLocale.Tests.ps1 similarity index 94% rename from tests/Unit/MSFT_SystemLocale.Tests.ps1 rename to tests/Unit/DSC_SystemLocale.Tests.ps1 index 22997225..873560bd 100644 --- a/tests/Unit/MSFT_SystemLocale.Tests.ps1 +++ b/tests/Unit/DSC_SystemLocale.Tests.ps1 @@ -1,5 +1,5 @@ $script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'MSFT_SystemLocale' +$script:DSCResourceName = 'DSC_SystemLocale' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -27,7 +27,7 @@ try $script:testAltSystemLocale = 'en-AU' $script:badSystemLocale = 'zzz-ZZZ' - Describe 'MSFT_SystemLocale\Get-TargetResource' { + Describe 'DSC_SystemLocale\Get-TargetResource' { Mock -CommandName Get-WinSystemLocale ` -MockWith { @{ LCID = '1033' @@ -50,7 +50,7 @@ try } } - Describe 'MSFT_SystemLocale\Set-TargetResource' { + Describe 'DSC_SystemLocale\Set-TargetResource' { Mock -CommandName Get-WinSystemLocale ` -MockWith { @{ LCID = '1033' @@ -93,7 +93,7 @@ try } } - Describe 'MSFT_SystemLocale\Test-TargetResource' { + Describe 'DSC_SystemLocale\Test-TargetResource' { Mock -CommandName Get-WinSystemLocale ` -MockWith { @{ LCID = '1033' @@ -123,7 +123,7 @@ try -IsSingleInstance 'Yes' | Should -BeFalse } - Describe 'MSFT_SystemLocale\Test-SystemLocaleValue' { + Describe 'DSC_SystemLocale\Test-SystemLocaleValue' { It 'Should return true when a valid System Locale is passed' { Test-SystemLocaleValue ` -SystemLocale $script:testSystemLocale | Should -BeTrue diff --git a/tests/Unit/MSFT_TimeZone.Tests.ps1 b/tests/Unit/DSC_TimeZone.Tests.ps1 similarity index 98% rename from tests/Unit/MSFT_TimeZone.Tests.ps1 rename to tests/Unit/DSC_TimeZone.Tests.ps1 index b8b2d13d..f5cdec14 100644 --- a/tests/Unit/MSFT_TimeZone.Tests.ps1 +++ b/tests/Unit/DSC_TimeZone.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_TimeZone' +$script:dscResourceName = 'DSC_TimeZone' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -26,7 +26,7 @@ try { #region Pester Tests InModuleScope $script:dscResourceName { - $script:dscResourceName = 'MSFT_TimeZone' + $script:dscResourceName = 'DSC_TimeZone' Describe "$($script:dscResourceName) MOF single instance schema" { It 'Should have mandatory IsSingleInstance parameter and one other parameter' { diff --git a/tests/Unit/MSFT_VirtualMemory.Tests.ps1 b/tests/Unit/DSC_VirtualMemory.Tests.ps1 similarity index 98% rename from tests/Unit/MSFT_VirtualMemory.Tests.ps1 rename to tests/Unit/DSC_VirtualMemory.Tests.ps1 index 137ef40d..4b707065 100644 --- a/tests/Unit/MSFT_VirtualMemory.Tests.ps1 +++ b/tests/Unit/DSC_VirtualMemory.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_VirtualMemory' +$script:dscResourceName = 'DSC_VirtualMemory' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -35,7 +35,7 @@ try { Invoke-TestSetup - InModuleScope 'MSFT_VirtualMemory' { + InModuleScope 'DSC_VirtualMemory' { <# Remove-CimInstance overridden to enable PSObject to be passed to mocked version. @@ -119,7 +119,7 @@ try $Filter -eq "SettingID='pagefile.sys @ $testDrive'" } - Describe 'MSFT_VirtualMemory\Get-TargetResource' { + Describe 'DSC_VirtualMemory\Get-TargetResource' { BeforeEach { $testParameters = @{ Drive = $testDrive @@ -248,7 +248,7 @@ try } } - Describe 'MSFT_VirtualMemory\Set-TargetResource' { + Describe 'DSC_VirtualMemory\Set-TargetResource' { BeforeEach { <# These mocks are to handle when disk drive @@ -680,7 +680,7 @@ try } } - Describe 'MSFT_VirtualMemory\Test-TargetResource' { + Describe 'DSC_VirtualMemory\Test-TargetResource' { Context 'In desired state' { Context 'When automatic managed page file is enabled' { Mock ` @@ -1033,7 +1033,7 @@ try } } - Describe 'MSFT_VirtualMemory\Get-PageFileSetting' { + Describe 'DSC_VirtualMemory\Get-PageFileSetting' { Context "Page file defined on drive $testDrive" { Mock ` -CommandName Get-CimInstance ` @@ -1062,7 +1062,7 @@ try } } - Describe 'MSFT_VirtualMemory\Set-PageFileSetting' { + Describe 'DSC_VirtualMemory\Set-PageFileSetting' { Context "Set page file settings on drive $testDrive" { Mock ` -CommandName Set-CimInstance ` @@ -1087,7 +1087,7 @@ try } } - Describe 'MSFT_VirtualMemory\Set-AutoManagePaging' { + Describe 'DSC_VirtualMemory\Set-AutoManagePaging' { Context "Enable auto managed page file" { Mock ` -CommandName Set-CimInstance ` @@ -1123,7 +1123,7 @@ try } } - Describe 'MSFT_VirtualMemory\New-PageFile' { + Describe 'DSC_VirtualMemory\New-PageFile' { Context "Create a new page file" { Mock ` -CommandName New-CimInstance ` diff --git a/tests/Unit/MSFT_WindowsCapability.Tests.ps1 b/tests/Unit/DSC_WindowsCapability.Tests.ps1 similarity index 93% rename from tests/Unit/MSFT_WindowsCapability.Tests.ps1 rename to tests/Unit/DSC_WindowsCapability.Tests.ps1 index 5f5a1183..51cbb73f 100644 --- a/tests/Unit/MSFT_WindowsCapability.Tests.ps1 +++ b/tests/Unit/DSC_WindowsCapability.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_WindowsCapability' +$script:dscResourceName = 'DSC_WindowsCapability' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -98,11 +98,11 @@ try ) } - Describe "MSFT_WindowsCapability\Get-TargetResource" { + Describe "DSC_WindowsCapability\Get-TargetResource" { Context 'When a Windows Capability is enabled and it should' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsInstalled ` - -ModuleName 'MSFT_WindowsCapability' ` + -ModuleName 'DSC_WindowsCapability' ` -Verifiable It 'Should not throw an exception' { @@ -124,7 +124,7 @@ try Context 'When a Windows Capability is not enabled' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsNotInstalled ` - -ModuleName 'MSFT_WindowsCapability' ` + -ModuleName 'DSC_WindowsCapability' ` -Verifiable It 'Should not throw an exception' { @@ -144,11 +144,11 @@ try } } - Describe "MSFT_WindowsCapability\Test-TargetResource" { + Describe "DSC_WindowsCapability\Test-TargetResource" { Context 'When a Windows Capability is enabled' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsInstalled ` - -ModuleName 'MSFT_WindowsCapability' ` + -ModuleName 'DSC_WindowsCapability' ` -Verifiable It 'Should not throw an exception' { @@ -169,7 +169,7 @@ try Context 'When a Windows Capability is not enabled' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsNotInstalled ` - -ModuleName 'MSFT_WindowsCapability' ` + -ModuleName 'DSC_WindowsCapability' ` -Verifiable It 'Should not throw an exception' { @@ -188,12 +188,12 @@ try } } - Describe "MSFT_WindowsCapability\Set-TargetResource" { + Describe "DSC_WindowsCapability\Set-TargetResource" { Context 'When a Windows Capability is not enabled' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsNotInstalled ` - -ModuleName 'MSFT_WindowsCapability' ` + -ModuleName 'DSC_WindowsCapability' ` -Verifiable Mock -CommandName Add-WindowsCapability -MockWith {} @@ -220,7 +220,7 @@ try Context 'When a Windows Capability is already enabled' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsInstalled ` - -ModuleName 'MSFT_WindowsCapability' ` + -ModuleName 'DSC_WindowsCapability' ` -Verifiable Mock -CommandName Add-WindowsCapability -MockWith {} @@ -245,7 +245,7 @@ try Context 'When a Windows Capability is already disabled' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsNotInstalled ` - -ModuleName 'MSFT_WindowsCapability' ` + -ModuleName 'DSC_WindowsCapability' ` -Verifiable Mock -CommandName Remove-WindowsCapability -MockWith {} @@ -272,7 +272,7 @@ try Context 'When a Windows Capability is enabled and should not be' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsInstalled ` - -ModuleName 'MSFT_WindowsCapability' ` + -ModuleName 'DSC_WindowsCapability' ` -Verifiable Mock -CommandName Remove-WindowsCapability -MockWith {} diff --git a/tests/Unit/MSFT_WindowsEventLog.Tests.ps1 b/tests/Unit/DSC_WindowsEventLog.Tests.ps1 similarity index 99% rename from tests/Unit/MSFT_WindowsEventLog.Tests.ps1 rename to tests/Unit/DSC_WindowsEventLog.Tests.ps1 index 4149d044..3de87913 100644 --- a/tests/Unit/MSFT_WindowsEventLog.Tests.ps1 +++ b/tests/Unit/DSC_WindowsEventLog.Tests.ps1 @@ -1,6 +1,6 @@ #region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'MSFT_WindowsEventLog' +$script:dscResourceName = 'DSC_WindowsEventLog' Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global @@ -25,7 +25,7 @@ $TestEnvironment = Initialize-TestEnvironment ` try { InModuleScope $script:dscResourceName { - $script:dscResourceName = 'MSFT_WindowsEventLog' + $script:dscResourceName = 'DSC_WindowsEventLog' Describe "$($script:dscResourceName)\Get-TargetResource" -Tag 'Get' { From cf138a0fec8f242c581f06b5fbfedc224f936955 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 20:44:33 +1300 Subject: [PATCH 04/30] Fix unit tests --- tests/Unit/DSC_Computer.Tests.ps1 | 60 +- tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 | 55 +- tests/Unit/DSC_PendingReboot.Tests.ps1 | 45 +- tests/Unit/DSC_PowerPlan.Tests.ps1 | 470 +++++++-------- .../DSC_PowerShellExecutionpolicy.Tests.ps1 | 72 +-- tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 | 40 +- tests/Unit/DSC_ScheduledTask.Tests.ps1 | 53 +- .../Unit/DSC_SmbServerConfiguration.Tests.ps1 | 42 +- tests/Unit/DSC_SmbShare.Tests.ps1 | 43 +- tests/Unit/DSC_SystemLocale.Tests.ps1 | 47 +- tests/Unit/DSC_TimeZone.Tests.ps1 | 55 +- tests/Unit/DSC_VirtualMemory.Tests.ps1 | 42 +- tests/Unit/DSC_WindowsCapability.Tests.ps1 | 74 +-- tests/Unit/DSC_WindowsEventLog.Tests.ps1 | 561 +++++++++--------- 14 files changed, 829 insertions(+), 830 deletions(-) diff --git a/tests/Unit/DSC_Computer.Tests.ps1 b/tests/Unit/DSC_Computer.Tests.ps1 index 834d4eae..daf37bac 100644 --- a/tests/Unit/DSC_Computer.Tests.ps1 +++ b/tests/Unit/DSC_Computer.Tests.ps1 @@ -1,35 +1,38 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_Computer' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try { - #region Pester Tests - InModuleScope $script:dscResourceName { - $script:dscResourceName = 'DSC_Computer' - - Describe $script:dscResourceName { + Describe 'DSC_Computer' { # A real password isn't needed here - use this next line to avoid triggering PSSA rule $securePassword = New-Object -Type SecureString $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'USER', $securePassword @@ -42,7 +45,7 @@ try 'name' } - Context "$($script:dscResourceName)\Test-TargetResource" { + Context 'DSC_Computer\Test-TargetResource' { Mock -CommandName Get-WMIObject -MockWith { [PSCustomObject] @{ DomainName = 'ContosoLtd' @@ -444,7 +447,7 @@ try } } - Context "$($script:dscResourceName)\Get-TargetResource" { + Context 'DSC_Computer\Get-TargetResource' { It 'should not throw' { { Get-TargetResource ` @@ -479,7 +482,7 @@ try } } - Context "$($script:dscResourceName)\Set-TargetResource" { + Context 'DSC_Computer\Set-TargetResource' { Mock -CommandName Rename-Computer Mock -CommandName Set-CimInstance @@ -1089,7 +1092,7 @@ try } } - Context "$($script:dscResourceName)\Get-ComputerDomain" { + Context 'DSC_Computer\Get-ComputerDomain' { It 'Returns domain netbios or DNS name if domain member' { Mock -CommandName Get-CimInstance -ParameterFilter { $ClassName -eq 'Win32_ComputerSystem' } -MockWith { [PSCustomObject] @{ @@ -1171,18 +1174,15 @@ try } } - Context "$($script:dscResourceName)\Get-LogonServer" { + Context 'DSC_Computer\Get-LogonServer' { It 'Should return a non-empty string' { Get-LogonServer | Should -Not -BeNullOrEmpty } } } - } #end InModuleScope $DSCResourceName - #endregion + } } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 b/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 index 0f53badf..c7b71106 100644 --- a/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 +++ b/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 @@ -1,40 +1,44 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_OfflineDomainJoin' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try { - #region Pester Tests InModuleScope $script:dscResourceName { - $script:dscResourceName = 'DSC_OfflineDomainJoin' - $testOfflineDomainJoin = @{ IsSingleInstance = 'Yes' RequestFile = 'C:\ODJRequest.txt' Verbose = $true } - Describe "$($script:dscResourceName)\Get-TargetResource" { + Describe 'DSC_OfflineDomainJoin\Get-TargetResource' { It 'Should return the correct values' { $result = Get-TargetResource ` @TestOfflineDomainJoin @@ -44,7 +48,7 @@ try } } - Describe "$($script:dscResourceName)\Set-TargetResource" { + Describe 'DSC_OfflineDomainJoin\Set-TargetResource' { Context 'Domain is not joined' { Mock -CommandName Test-Path -MockWith { return $true @@ -84,7 +88,7 @@ try } } - Describe "$($script:dscResourceName)\Test-TargetResource" { + Describe 'DSC_OfflineDomainJoin\Test-TargetResource' { Context 'Domain is not joined' { Mock -CommandName Test-Path -MockWith { return $true @@ -147,7 +151,7 @@ try } } - Describe "$($script:dscResourceName)\Join-Domain" { + Describe 'DSC_OfflineDomainJoin\Join-Domain' { Context 'Domain Join successful' { Mock -CommandName djoin.exe -MockWith { $script:LASTEXITCODE = 0 @@ -181,12 +185,9 @@ try } } } - } #end InModuleScope $DSCResourceName - #endregion + } } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/tests/Unit/DSC_PendingReboot.Tests.ps1 b/tests/Unit/DSC_PendingReboot.Tests.ps1 index 9c99100b..f18649ac 100644 --- a/tests/Unit/DSC_PendingReboot.Tests.ps1 +++ b/tests/Unit/DSC_PendingReboot.Tests.ps1 @@ -1,30 +1,36 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_PendingReboot' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try { - #region Pester Tests InModuleScope $script:dscResourceName { $script:testResourceName = 'Test' @@ -600,12 +606,9 @@ try } } } - } #end InModuleScope $DSCResourceName - #endregion + } } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/tests/Unit/DSC_PowerPlan.Tests.ps1 b/tests/Unit/DSC_PowerPlan.Tests.ps1 index 37e94800..60380ac1 100644 --- a/tests/Unit/DSC_PowerPlan.Tests.ps1 +++ b/tests/Unit/DSC_PowerPlan.Tests.ps1 @@ -1,230 +1,152 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_PowerPlan' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) -} + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +} function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } +Invoke-TestSetup + # Begin Testing try { - # Assign the localized data from the module into a local variable - $LocalizedData = InModuleScope $script:dscResourceName { - $LocalizedData - } - - $testCases =@( - # Power plan as name specified - @{ - Type = 'Name' - Name = 'High performance' - }, - - # Power plan as Guid specified - @{ - Type = 'Guid' - Name = '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - ) - - Describe "$($script:dscResourceName)\Get-TargetResource" { - Context 'When the system is in the desired present state' { - BeforeEach { - Mock ` - -CommandName Get-PowerPlan ` - -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` - -ModuleName $script:dscResourceName ` - -Verifiable - - Mock ` - -CommandName Get-ActivePowerPlan ` - -MockWith { - return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } ` - -ModuleName $script:dscResourceName ` - -Verifiable - } - - It 'Should return the same values as passed as parameters (power plan specified as )' -TestCases $testCases { - param - ( - [System.String] - $Name - ) - - $result = Get-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose - $result.IsSingleInstance | Should -Be 'Yes' - $result.Name | Should -Be $Name - $result.IsActive | Should -BeTrue - } - } - - Context 'When the system is not in the desired present state' { - BeforeEach { - Mock ` - -CommandName Get-PowerPlan ` - -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` - -ModuleName $script:dscResourceName ` - -Verifiable - - Mock ` - -CommandName Get-ActivePowerPlan ` - -MockWith { - return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' - } ` - -ModuleName $script:dscResourceName ` - -Verifiable - } - - It 'Should return an inactive plan (power plan specified as )' -TestCases $testCases { - - param - ( - [System.String] - $Name - ) - - $result = Get-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose - $result.IsSingleInstance | Should -Be 'Yes' - $result.Name | Should -Be $Name - $result.IsActive | Should -BeFalse + InModuleScope $script:dscResourceName { + $testCases = @( + # Power plan as name specified + @{ + Type = 'Name' + Name = 'High performance' + }, + + # Power plan as Guid specified + @{ + Type = 'Guid' + Name = '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } - } - - Context 'When the preferred plan does not exist' { - BeforeEach { - Mock ` - -CommandName Get-PowerPlan ` - -ModuleName $script:dscResourceName ` - -Verifiable - } - - It 'Should throw the expected error (power plan specified as )' -TestCases $testCases { - - param - ( - [System.String] - $Name - ) - - $errorRecord = Get-InvalidOperationRecord ` - -Message ($LocalizedData.PowerPlanNotFound -f $Name) + ) + + Describe 'DSC_PowerPlan\Get-TargetResource' { + Context 'When the system is in the desired present state' { + BeforeEach { + Mock ` + -CommandName Get-PowerPlan ` + -MockWith { + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` + -ModuleName $script:dscResourceName ` + -Verifiable - { Get-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose } | Should -Throw $errorRecord + Mock ` + -CommandName Get-ActivePowerPlan ` + -MockWith { + return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } ` + -ModuleName $script:dscResourceName ` + -Verifiable + } + + It 'Should return the same values as passed as parameters (power plan specified as )' -TestCases $testCases { + param + ( + [System.String] + $Name + ) + + $result = Get-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose + $result.IsSingleInstance | Should -Be 'Yes' + $result.Name | Should -Be $Name + $result.IsActive | Should -BeTrue + } } - Assert-VerifiableMock - } - } - - Describe "$($script:dscResourceName)\Set-TargetReource" { - BeforeEach { - Mock ` - -CommandName Get-PowerPlan ` - -MockWith { - return @{ + Context 'When the system is not in the desired present state' { + BeforeEach { + Mock ` + -CommandName Get-PowerPlan ` + -MockWith { + return @{ FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } - } ` - -ModuleName $script:dscResourceName ` - -Verifiable - - Mock ` - -CommandName Set-ActivePowerPlan ` - -ModuleName $script:dscResourceName ` - -Verifiable - } - - Context 'When the system is not in the desired present state' { - It 'Should call Get-PowerPlan once (power plan specified as )' -TestCases $testCases { - param - ( - [System.String] - $Name - ) - - Set-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose + } ` + -ModuleName $script:dscResourceName ` + -Verifiable - Assert-MockCalled -CommandName Get-PowerPlan -Exactly -Times 1 -Scope It -ModuleName $script:dscResourceName + Mock ` + -CommandName Get-ActivePowerPlan ` + -MockWith { + return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' + } ` + -ModuleName $script:dscResourceName ` + -Verifiable + } + + It 'Should return an inactive plan (power plan specified as )' -TestCases $testCases { + + param + ( + [System.String] + $Name + ) + + $result = Get-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose + $result.IsSingleInstance | Should -Be 'Yes' + $result.Name | Should -Be $Name + $result.IsActive | Should -BeFalse + } } - It 'Should call Set-ActivePowerPlan once (power plan specified as )' -TestCases $testCases { - param - ( - [System.String] - $Name - ) + Context 'When the preferred plan does not exist' { + BeforeEach { + Mock ` + -CommandName Get-PowerPlan ` + -ModuleName $script:dscResourceName ` + -Verifiable + } - Set-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose + It 'Should throw the expected error (power plan specified as )' -TestCases $testCases { - Assert-MockCalled ` - -CommandName Set-ActivePowerPlan ` - -Exactly ` - -Times 1 ` - -Scope It ` - -ModuleName $script:dscResourceName ` - -ParameterFilter {$PowerPlanGuid -eq '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'} - } - } + param + ( + [System.String] + $Name + ) - Context 'When the preferred plan does not exist' { - BeforeEach { - Mock ` - -CommandName Get-PowerPlan ` - -ModuleName $script:dscResourceName ` - -Verifiable - } - - It 'Should throw the expected error (power plan specified as )' -TestCases $testCases { - param - ( - [System.String] - $Name - ) + $errorRecord = Get-InvalidOperationRecord ` + -Message ($script:localizedData.PowerPlanNotFound -f $Name) - $errorRecord = Get-InvalidOperationRecord ` - -Message ($LocalizedData.PowerPlanNotFound -f $Name) + { Get-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose } | Should -Throw $errorRecord + } - { Set-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose } | Should -Throw $errorRecord + Assert-VerifiableMock } } - Assert-VerifiableMock - } - Describe "$($script:dscResourceName)\Test-TargetResource" { - Context 'When the system is in the desired present state' { + Describe 'DSC_PowerPlan\Set-TargetReource' { BeforeEach { Mock ` -CommandName Get-PowerPlan ` @@ -238,60 +160,138 @@ try -Verifiable Mock ` - -CommandName Get-ActivePowerPlan ` - -MockWith { - return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } ` + -CommandName Set-ActivePowerPlan ` -ModuleName $script:dscResourceName ` -Verifiable } - - It 'Should return the the state as present ($true) (power plan specified as )' -TestCases $testCases { - param - ( - [System.String] - $Name - ) - - Test-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose | Should -BeTrue + Context 'When the system is not in the desired present state' { + It 'Should call Get-PowerPlan once (power plan specified as )' -TestCases $testCases { + param + ( + [System.String] + $Name + ) + + Set-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose + + Assert-MockCalled -CommandName Get-PowerPlan -Exactly -Times 1 -Scope It -ModuleName $script:dscResourceName + } + + It 'Should call Set-ActivePowerPlan once (power plan specified as )' -TestCases $testCases { + param + ( + [System.String] + $Name + ) + + Set-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose + + Assert-MockCalled ` + -CommandName Set-ActivePowerPlan ` + -Exactly ` + -Times 1 ` + -Scope It ` + -ModuleName $script:dscResourceName ` + -ParameterFilter {$PowerPlanGuid -eq '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'} + } } - } - Context 'When the system is not in the desired state' { - BeforeEach { - Mock ` + Context 'When the preferred plan does not exist' { + BeforeEach { + Mock ` -CommandName Get-PowerPlan ` - -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` -ModuleName $script:dscResourceName ` -Verifiable + } - Mock ` - -CommandName Get-ActivePowerPlan ` - -MockWith { - return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' - } ` - -ModuleName $script:dscResourceName ` - -Verifiable - } + It 'Should throw the expected error (power plan specified as )' -TestCases $testCases { + param + ( + [System.String] + $Name + ) - It 'Should return the the state as absent ($false) (power plan specified as )' -TestCases $testCases { - param - ( - [System.String] - $Name - ) + $errorRecord = Get-InvalidOperationRecord ` + -Message ($script:localizedData.PowerPlanNotFound -f $Name) - Test-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose | Should -BeFalse + { Set-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose } | Should -Throw $errorRecord + } } + + Assert-VerifiableMock } - Assert-VerifiableMock + Describe 'DSC_PowerPlan\Test-TargetResource' { + Context 'When the system is in the desired present state' { + BeforeEach { + Mock ` + -CommandName Get-PowerPlan ` + -MockWith { + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` + -ModuleName $script:dscResourceName ` + -Verifiable + + Mock ` + -CommandName Get-ActivePowerPlan ` + -MockWith { + return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } ` + -ModuleName $script:dscResourceName ` + -Verifiable + } + + + It 'Should return the the state as present ($true) (power plan specified as )' -TestCases $testCases { + param + ( + [System.String] + $Name + ) + + Test-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose | Should -BeTrue + } + } + + Context 'When the system is not in the desired state' { + BeforeEach { + Mock ` + -CommandName Get-PowerPlan ` + -MockWith { + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` + -ModuleName $script:dscResourceName ` + -Verifiable + + Mock ` + -CommandName Get-ActivePowerPlan ` + -MockWith { + return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' + } ` + -ModuleName $script:dscResourceName ` + -Verifiable + } + + It 'Should return the the state as absent ($false) (power plan specified as )' -TestCases $testCases { + param + ( + [System.String] + $Name + ) + + Test-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose | Should -BeFalse + } + } + + Assert-VerifiableMock + } } } finally diff --git a/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 b/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 index c5b72ea8..c56d5753 100644 --- a/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 +++ b/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 @@ -1,53 +1,52 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_PowershellExecutionPolicy' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup -$Script:invalidPolicyThrowMessage = @" +# Begin Testing +try +{ + InModuleScope $script:dscResourceName { + $Script:invalidPolicyThrowMessage = @" Cannot validate argument on parameter 'ExecutionPolicy'. The argument `"badParam`" does not belong to the set `"Bypass,Restricted,AllSigned,RemoteSigned,Unrestricted`" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again. "@ -$Script:invalidPolicyExecutionPolicyScopeThrowMessage = @" + $Script:invalidPolicyExecutionPolicyScopeThrowMessage = @" Cannot validate argument on parameter 'ExecutionPolicyScope'. The argument `"badParam`" does not belong to the set `"CurrentUser,LocalMachine,MachinePolicy,Process,UserPolicy`" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again. "@ -# Begin Testing -try -{ - <# - The InModuleScope command allows you to perform white-box unit testing on the internal - (non-exported) code of a Script Module. - #> - InModuleScope $script:dscResourceName { - $script:dscResourceName = 'DSC_PowershellExecutionPolicy' - - #region Function Get-TargetResource - Describe "$($script:dscResourceName)\Get-TargetResource" { - + Describe 'DSC_PowershellExecutionPolicy\Get-TargetResource' { It 'Throws when passed an invalid execution policy' { { Get-TargetResource -ExecutionPolicy 'badParam' -Scope 'LocalMachine' } | Should -Throw $Script:invalidPolicyThrowMessage } @@ -68,11 +67,8 @@ try $result.ExecutionPolicyScope | Should -Be 'LocalMachine' } } - #endregion - - #region Function Test-TargetResource - Describe "$($script:dscResourceName)\Test-TargetResource" { + Describe 'DSC_PowershellExecutionPolicy\Test-TargetResource' { It 'Throws when passed an invalid execution policy' { { Test-TargetResource -ExecutionPolicy 'badParam' -Scope 'LocalMachine' } | Should -Throw $Script:invalidPolicyThrowMessage } @@ -100,11 +96,8 @@ try Test-TargetResource -ExecutionPolicy 'Bypass' -ExecutionPolicyScope 'LocalMachine' | Should -BeFalse } } - #endregion - - #region Function Set-TargetResource - Describe "$script:dscResourceName\Set-TargetResource" { + Describe 'DSC_PowershellExecutionPolicy\Set-TargetResource' { It 'Throws when passed an invalid execution policy' { { Set-TargetResource -ExecutionPolicy 'badParam' -Scope 'LocalMachine' } | Should -Throw $Script:invalidPolicyThrowMessage } @@ -136,10 +129,9 @@ try Assert-MockCalled -CommandName Set-ExecutionPolicy -Exactly 1 -Scope It } } - #endregion } } finally { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Invoke-TestCleanup } diff --git a/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 b/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 index cb44c5cf..18a4508f 100644 --- a/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 +++ b/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 @@ -1,41 +1,37 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_RemoteDesktopAdmin' -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force - -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } +Invoke-TestSetup + # Begin Testing try { - Invoke-TestSetup - InModuleScope $script:dscResourceName { - $mockGetTargetResourcePresentSecure = @{ IsSingleInstance = 'Yes' Ensure = 'Present' diff --git a/tests/Unit/DSC_ScheduledTask.Tests.ps1 b/tests/Unit/DSC_ScheduledTask.Tests.ps1 index 63229bf3..ee474602 100644 --- a/tests/Unit/DSC_ScheduledTask.Tests.ps1 +++ b/tests/Unit/DSC_ScheduledTask.Tests.ps1 @@ -3,39 +3,41 @@ param ( ) -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_ScheduledTask' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) -} + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +} -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup -$VerbosePreference = 'Continue' # Begin Testing try { - #region Pester Tests - - InModuleScope $script:dscResourceName { - $script:dscResourceName = 'DSC_ScheduledTask' + InModuleScope $script:DSCResourceName { + $VerbosePreference = 'Continue' # Function to allow mocking pipeline input function Register-ScheduledTask @@ -89,7 +91,7 @@ try ) } - Describe $script:dscResourceName { + Describe 'DSC_ScheduledTask' { BeforeAll { Mock -CommandName Register-ScheduledTask Mock -CommandName Set-ScheduledTask @@ -2188,11 +2190,8 @@ try } } } - #endregion } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 b/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 index 758f55a0..04eec0c6 100644 --- a/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 +++ b/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 @@ -1,41 +1,37 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_SmbServerConfiguration' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } +Invoke-TestSetup + +# Begin Testing try { - Invoke-TestSetup - InModuleScope $script:DSCResourceName { - $testCases = @( @{ smbSetting = 'AnnounceComment' diff --git a/tests/Unit/DSC_SmbShare.Tests.ps1 b/tests/Unit/DSC_SmbShare.Tests.ps1 index fb359195..922dae46 100644 --- a/tests/Unit/DSC_SmbShare.Tests.ps1 +++ b/tests/Unit/DSC_SmbShare.Tests.ps1 @@ -1,40 +1,37 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_SmbShare' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } +Invoke-TestSetup + +# Begin Testing try { - Invoke-TestSetup - - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { $mockShareName = 'TestShare' $mockChangePermissionUserName = @('User1') $mockReadPermissionUserName = @('User2') diff --git a/tests/Unit/DSC_SystemLocale.Tests.ps1 b/tests/Unit/DSC_SystemLocale.Tests.ps1 index 873560bd..b4736c76 100644 --- a/tests/Unit/DSC_SystemLocale.Tests.ps1 +++ b/tests/Unit/DSC_SystemLocale.Tests.ps1 @@ -1,28 +1,37 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'DSC_SystemLocale' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'DSC_SystemLocale' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +function Invoke-TestSetup +{ + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +} -#region HEADER -# Unit Test Template Version: 1.1.0 -[String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) -if ( (-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestCleanup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $moduleRoot -ChildPath '\DSCResource.Tests\')) + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } -Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:DSCModuleName ` - -DSCResourceName $script:DSCResourceName ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try { - InModuleScope $script:DSCResourceName { + InModuleScope $script:dscResourceName { $script:testSystemLocale = 'en-US' $script:testAltSystemLocale = 'en-AU' $script:badSystemLocale = 'zzz-ZZZ' @@ -135,11 +144,9 @@ try } } } - } #end InModuleScope $DSCResourceName + } } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/tests/Unit/DSC_TimeZone.Tests.ps1 b/tests/Unit/DSC_TimeZone.Tests.ps1 index f5cdec14..2ab309b4 100644 --- a/tests/Unit/DSC_TimeZone.Tests.ps1 +++ b/tests/Unit/DSC_TimeZone.Tests.ps1 @@ -1,34 +1,38 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_TimeZone' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try { - #region Pester Tests InModuleScope $script:dscResourceName { - $script:dscResourceName = 'DSC_TimeZone' - - Describe "$($script:dscResourceName) MOF single instance schema" { + Describe 'DSC_TimeZone MOF single instance schema' { It 'Should have mandatory IsSingleInstance parameter and one other parameter' { $timeZoneResource = Get-DscResource -Name TimeZone @@ -42,7 +46,7 @@ try } } - Describe "$($script:dscResourceName)\Get-TargetResource" { + Describe 'DSC_TimeZone\Get-TargetResource' { Mock ` -CommandName Get-TimeZoneId ` -MockWith { 'Pacific Standard Time' } @@ -61,7 +65,7 @@ try } } - Describe "$($script:dscResourceName)\Set-TargetResource" { + Describe 'DSC_TimeZone\Set-TargetResource' { Mock ` -CommandName Set-TimeZoneId @@ -98,7 +102,7 @@ try } } - Describe "$($script:dscResourceName)\Test-TargetResource" { + Describe 'DSC_TimeZone\Test-TargetResource' { Mock ` -ModuleName ComputerManagementDsc.Common ` -CommandName Get-TimeZoneId ` @@ -118,12 +122,9 @@ try -Verbose | Should -BeFalse } } - } #end InModuleScope $DSCResourceName - #endregion + } } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Invoke-TestCleanup } diff --git a/tests/Unit/DSC_VirtualMemory.Tests.ps1 b/tests/Unit/DSC_VirtualMemory.Tests.ps1 index 4b707065..2dcbd138 100644 --- a/tests/Unit/DSC_VirtualMemory.Tests.ps1 +++ b/tests/Unit/DSC_VirtualMemory.Tests.ps1 @@ -1,41 +1,37 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_VirtualMemory' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) -} - -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' -function Invoke-TestSetup -{ + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } function Invoke-TestCleanup { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } +Invoke-TestSetup + # Begin Testing try { - Invoke-TestSetup - - InModuleScope 'DSC_VirtualMemory' { + InModuleScope $script:dscResourceName { <# Remove-CimInstance overridden to enable PSObject to be passed to mocked version. diff --git a/tests/Unit/DSC_WindowsCapability.Tests.ps1 b/tests/Unit/DSC_WindowsCapability.Tests.ps1 index 51cbb73f..2eece8f4 100644 --- a/tests/Unit/DSC_WindowsCapability.Tests.ps1 +++ b/tests/Unit/DSC_WindowsCapability.Tests.ps1 @@ -1,25 +1,32 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_WindowsCapability' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try @@ -28,28 +35,28 @@ try $script:testResourceName = 'Test' $script:testAndSetTargetResourceParametersPresent = @{ - Name = $script:testResourceName - Ensure = 'Present' + Name = $script:testResourceName + Ensure = 'Present' } $script:testAndSetTargetResourceParametersAbsent = @{ - Name = $script:testResourceName - Ensure = 'Absent' + Name = $script:testResourceName + Ensure = 'Absent' } $getWindowsCapabilityIsInstalled = { @{ - Name = 'Test' - State = 'Installed' - Ensure = 'Present' + Name = 'Test' + State = 'Installed' + Ensure = 'Present' } } $getWindowsCapabilityIsNotInstalled = { @{ - Name = 'Test' - State = 'NotPresent' - Ensure = 'Absent' + Name = 'Test' + State = 'NotPresent' + Ensure = 'Absent' } } @@ -98,7 +105,7 @@ try ) } - Describe "DSC_WindowsCapability\Get-TargetResource" { + Describe 'DSC_WindowsCapability\Get-TargetResource' { Context 'When a Windows Capability is enabled and it should' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsInstalled ` @@ -144,7 +151,7 @@ try } } - Describe "DSC_WindowsCapability\Test-TargetResource" { + Describe 'DSC_WindowsCapability\Test-TargetResource' { Context 'When a Windows Capability is enabled' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsInstalled ` @@ -188,15 +195,14 @@ try } } - Describe "DSC_WindowsCapability\Set-TargetResource" { - + Describe 'DSC_WindowsCapability\Set-TargetResource' { Context 'When a Windows Capability is not enabled' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsNotInstalled ` -ModuleName 'DSC_WindowsCapability' ` -Verifiable - Mock -CommandName Add-WindowsCapability -MockWith {} + Mock -CommandName Add-WindowsCapability -MockWith { } It 'Should not throw an exception' { { @@ -223,7 +229,7 @@ try -ModuleName 'DSC_WindowsCapability' ` -Verifiable - Mock -CommandName Add-WindowsCapability -MockWith {} + Mock -CommandName Add-WindowsCapability -MockWith { } It 'Should not throw an exception' { { @@ -248,7 +254,7 @@ try -ModuleName 'DSC_WindowsCapability' ` -Verifiable - Mock -CommandName Remove-WindowsCapability -MockWith {} + Mock -CommandName Remove-WindowsCapability -MockWith { } It 'Should not throw an exception' { { @@ -275,7 +281,7 @@ try -ModuleName 'DSC_WindowsCapability' ` -Verifiable - Mock -CommandName Remove-WindowsCapability -MockWith {} + Mock -CommandName Remove-WindowsCapability -MockWith { } It 'Should not throw an exception' { { @@ -298,5 +304,5 @@ try } finally { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Invoke-TestCleanup } diff --git a/tests/Unit/DSC_WindowsEventLog.Tests.ps1 b/tests/Unit/DSC_WindowsEventLog.Tests.ps1 index 3de87913..ddcf4b64 100644 --- a/tests/Unit/DSC_WindowsEventLog.Tests.ps1 +++ b/tests/Unit/DSC_WindowsEventLog.Tests.ps1 @@ -1,385 +1,390 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_WindowsEventLog' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +function Invoke-TestSetup { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType Unit -#endregion HEADER +Invoke-TestSetup # Begin Testing try { InModuleScope $script:dscResourceName { - $script:dscResourceName = 'DSC_WindowsEventLog' - - Describe "$($script:dscResourceName)\Get-TargetResource" -Tag 'Get' { + Describe 'DSC_WindowsEventLog\Get-TargetResource' -Tag 'Get' { - Mock -CommandName Get-WindowsEventLog -MockWith { - $properties = @{ - MaximumSizeInBytes = 4096kb - IsEnabled = $true - LogMode = 'Circular' - LogFilePath = '%SystemRoot%\System32\Winevt\Logs\Application.evtx' - SecurityDescriptor = 'TestDescriptor' - LogRetentionDays = '0' - LogName = 'Application' - } - - return (New-Object -TypeName PSObject -Property $properties) + Mock -CommandName Get-WindowsEventLog -MockWith { + $properties = @{ + MaximumSizeInBytes = 4096kb + IsEnabled = $true + LogMode = 'Circular' + LogFilePath = '%SystemRoot%\System32\Winevt\Logs\Application.evtx' + SecurityDescriptor = 'TestDescriptor' + LogRetentionDays = '0' + LogName = 'Application' } - $results = Get-TargetResource -LogName 'Application' -IsEnabled $true + return (New-Object -TypeName PSObject -Property $properties) + } - It 'Should return an hashtable' { - $results.GetType().Name | Should -Be 'Hashtable' - } + $results = Get-TargetResource -LogName 'Application' -IsEnabled $true - It 'Should return a Logname Application' { - $results.LogName = 'Application' - } + It 'Should return an hashtable' { + $results.GetType().Name | Should -Be 'Hashtable' + } - It 'Should return a MaximumSizeInBytes of 4096kb' { - $results.MaximumSizeInBytes | Should -Be 4096kb - } + It 'Should return a Logname Application' { + $results.LogName = 'Application' + } - It 'Should return IsEnabled is true' { - $results.IsEnabled | Should -BeTrue - } + It 'Should return a MaximumSizeInBytes of 4096kb' { + $results.MaximumSizeInBytes | Should -Be 4096kb + } - It 'Should return a LogMode is Circular' { - $results.LogMode | Should -Be 'Circular' - } + It 'Should return IsEnabled is true' { + $results.IsEnabled | Should -BeTrue + } - It 'Should return a LogRetentionDays of 0' { - $results.LogRetentionDays | Should -Be 0 - } + It 'Should return a LogMode is Circular' { + $results.LogMode | Should -Be 'Circular' + } - It 'Should return a LogFilePath of %SystemRoot%\System32\Winevt\Logs\Application.evtx' { - $results.LogFilePath | Should -Be "%SystemRoot%\System32\Winevt\Logs\Application.evtx" - } + It 'Should return a LogRetentionDays of 0' { + $results.LogRetentionDays | Should -Be 0 + } - It 'Should return SecurityDescriptor with a value TestDescriptor' { - $results.SecurityDescriptor | Should -Be 'TestDescriptor' - } + It 'Should return a LogFilePath of %SystemRoot%\System32\Winevt\Logs\Application.evtx' { + $results.LogFilePath | Should -Be "%SystemRoot%\System32\Winevt\Logs\Application.evtx" } - Describe "$($script:dscResourceName)\Test-TargetResource" -Tag 'Test' { + It 'Should return SecurityDescriptor with a value TestDescriptor' { + $results.SecurityDescriptor | Should -Be 'TestDescriptor' + } + } - Mock -CommandName Get-WindowsEventLog -MockWith { - $properties = @{ - MaximumSizeInBytes = 1028kb - IsEnabled = $true - LogMode = 'Circular' - LogFilePath = '%SystemRoot%\System32\Winevt\Logs\Application.evtx' - SecurityDescriptor = 'TestDescriptor' - LogRetentionDays = '7' - LogName = 'Application' - } + Describe 'DSC_WindowsEventLog\Test-TargetResource' -Tag 'Test' { - return (New-Object -TypeName PSObject -Property $properties) + Mock -CommandName Get-WindowsEventLog -MockWith { + $properties = @{ + MaximumSizeInBytes = 1028kb + IsEnabled = $true + LogMode = 'Circular' + LogFilePath = '%SystemRoot%\System32\Winevt\Logs\Application.evtx' + SecurityDescriptor = 'TestDescriptor' + LogRetentionDays = '7' + LogName = 'Application' } - Mock -CommandName Get-EventLog -MockWith { - $params = @{ - MinimumRetentionDays = '7' - Log = 'Application' - } + return (New-Object -TypeName PSObject -Property $properties) + } - return (New-Object -TypeName PSObject -Property $params) + Mock -CommandName Get-EventLog -MockWith { + $params = @{ + MinimumRetentionDays = '7' + Log = 'Application' } - It 'Should not throw when passed an valid Logname' { - { Test-TargetResource -LogName 'Application' -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw - } + return (New-Object -TypeName PSObject -Property $params) + } - It 'Should throw when passed an invalid LogMode' { - { Test-TargetResource -LogName 'Application' -LogMode 'BadLogmode' -IsEnabled $true -ErrorAction Stop } | Should -Throw - } + It 'Should not throw when passed an valid Logname' { + { Test-TargetResource -LogName 'Application' -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw + } - It 'Should not throw when passed an valid LogMode' { - { Test-TargetResource -LogName 'Application' -LogMode 'Circular' -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw - } + It 'Should throw when passed an invalid LogMode' { + { Test-TargetResource -LogName 'Application' -LogMode 'BadLogmode' -IsEnabled $true -ErrorAction Stop } | Should -Throw + } - It 'Should return $true if Logmode is in desired state' { - Test-TargetResource -LogName 'Application' -LogMode 'Circular' -IsEnabled $true | Should -BeTrue - } + It 'Should not throw when passed an valid LogMode' { + { Test-TargetResource -LogName 'Application' -LogMode 'Circular' -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw + } - It 'Should return $false if Logmode is not in desired state' { - Test-TargetResource -LogName 'Application' -LogMode 'AutoBackup' -IsEnabled $false | Should -BeFalse - } + It 'Should return $true if Logmode is in desired state' { + Test-TargetResource -LogName 'Application' -LogMode 'Circular' -IsEnabled $true | Should -BeTrue + } - It 'Should throw when passed an invalid MaximumSizeInBytes below 1028kb' { - { Test-TargetResource -LogName 'Application' -LogMode 'Circular' -IsEnabled $true -MaximumSizeInBytes 1027kb -ErrorAction Stop } | Should -Throw - } + It 'Should return $false if Logmode is not in desired state' { + Test-TargetResource -LogName 'Application' -LogMode 'AutoBackup' -IsEnabled $false | Should -BeFalse + } - It 'Shoudl throw when passed an invalid MaximumSizeInBytes above 18014398509481983kb' { - { Test-TargetResource -LogName 'Application' -LogMode 'Circular' -IsEnabled $true -MaximumSizeInBytes 18014398509481983kb -ErrorAction Stop } | Should -Throw - } + It 'Should throw when passed an invalid MaximumSizeInBytes below 1028kb' { + { Test-TargetResource -LogName 'Application' -LogMode 'Circular' -IsEnabled $true -MaximumSizeInBytes 1027kb -ErrorAction Stop } | Should -Throw + } - It 'Should return $true if MaximumSizeInBytes is in desired state' { - Test-TargetResource -MaximumSizeInBytes 1028kb -LogName 'Application' -IsEnabled $true | Should -BeTrue - } + It 'Shoudl throw when passed an invalid MaximumSizeInBytes above 18014398509481983kb' { + { Test-TargetResource -LogName 'Application' -LogMode 'Circular' -IsEnabled $true -MaximumSizeInBytes 18014398509481983kb -ErrorAction Stop } | Should -Throw + } - It 'Should return $false if MaximumSizeInBytes is not in desired state' { - Test-TargetResource -MaximumSizeInBytes 2048kb -LogName 'Application' -IsEnabled $true | Should -BeFalse - } + It 'Should return $true if MaximumSizeInBytes is in desired state' { + Test-TargetResource -MaximumSizeInBytes 1028kb -LogName 'Application' -IsEnabled $true | Should -BeTrue + } - It 'Should not throw when passed an valid MaximumSizeInBytes' { - { Test-TargetResource -LogName 'Application' -MaximumSizeInBytes 1028kb -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw - } + It 'Should return $false if MaximumSizeInBytes is not in desired state' { + Test-TargetResource -MaximumSizeInBytes 2048kb -LogName 'Application' -IsEnabled $true | Should -BeFalse + } - It 'Should throw when passed an invalid LogRetentionDays below 1 day' { - { Test-TargetResource -LogName 'Application' -LogMode 'AutoBackup' -IsEnabled $true -LogRetentionDays 0 -ErrorAction Stop } | Should -Throw - } + It 'Should not throw when passed an valid MaximumSizeInBytes' { + { Test-TargetResource -LogName 'Application' -MaximumSizeInBytes 1028kb -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw + } - It 'Should throw when passed an invalid LogRetentionDays above 365 days' { - { Test-TargetResource -LogName 'Application' -LogMode 'AutoBackup' -IsEnabled $true -LogRetentionDays 366 -ErrorAction Stop } | Should -Throw - } + It 'Should throw when passed an invalid LogRetentionDays below 1 day' { + { Test-TargetResource -LogName 'Application' -LogMode 'AutoBackup' -IsEnabled $true -LogRetentionDays 0 -ErrorAction Stop } | Should -Throw + } - It 'Should not throw when passed an valid LogRetentionDays' { - { Test-TargetResource -LogName 'Application' -LogMode 'AutoBackup' -LogRetentionDays 30 -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw - } + It 'Should throw when passed an invalid LogRetentionDays above 365 days' { + { Test-TargetResource -LogName 'Application' -LogMode 'AutoBackup' -IsEnabled $true -LogRetentionDays 366 -ErrorAction Stop } | Should -Throw + } - It 'Should return $false if LogRetentionDays is not in desired state' { - Test-TargetResource -LogName 'Application' -IsEnabled $true -LogRetentionDays 13 -LogMode 'AutoBackup' | Should -BeFalse - } + It 'Should not throw when passed an valid LogRetentionDays' { + { Test-TargetResource -LogName 'Application' -LogMode 'AutoBackup' -LogRetentionDays 30 -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should return $false if LogRetentionDays is not in desired state' { + Test-TargetResource -LogName 'Application' -IsEnabled $true -LogRetentionDays 13 -LogMode 'AutoBackup' | Should -BeFalse + } - It 'Should return $true if LogRetentionDays is in desired state' { - Mock -CommandName Get-WindowsEventLog -MockWith { - $properties = @{ - MaximumSizeInBytes = 1028kb - IsEnabled = $true - LogMode = 'AutoBackup' - LogFilePath = '%SystemRoot%\System32\Winevt\Logs\Application.evtx' - SecurityDescriptor = 'TestDescriptor' - LogRetentionDays = '7' - LogName = 'Application' - } - - return (New-Object -TypeName PSObject -Property $properties) + It 'Should return $true if LogRetentionDays is in desired state' { + Mock -CommandName Get-WindowsEventLog -MockWith { + $properties = @{ + MaximumSizeInBytes = 1028kb + IsEnabled = $true + LogMode = 'AutoBackup' + LogFilePath = '%SystemRoot%\System32\Winevt\Logs\Application.evtx' + SecurityDescriptor = 'TestDescriptor' + LogRetentionDays = '7' + LogName = 'Application' } - Test-TargetResource -LogName 'Application' -IsEnabled $true -LogRetentionDays 7 -LogMode 'AutoBackup' | Should -BeTrue + return (New-Object -TypeName PSObject -Property $properties) } - It 'Should not throw when passed an invalid LogRetentionDays' { - { Test-TargetResource -LogName 'WrongLog' -LogMode 'AutoBackup' -LogRetentionDays 30 -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw - } + Test-TargetResource -LogName 'Application' -IsEnabled $true -LogRetentionDays 7 -LogMode 'AutoBackup' | Should -BeTrue + } - It 'Should not throw when passed an invalid LogMode with LogRetention' { - { Test-TargetResource -LogName 'Application' -LogMode 'Circular' -LogRetentionDays 30 -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw - } + It 'Should not throw when passed an invalid LogRetentionDays' { + { Test-TargetResource -LogName 'WrongLog' -LogMode 'AutoBackup' -LogRetentionDays 30 -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw + } - It 'Should not throw when passed an valid LogFilePath' { - { Test-TargetResource -LogName 'Application' -IsEnabled $true -LogFilePath '%SystemRoot%\System32\Winevt\Logs\Application.evtx' -ErrorAction Stop } | Should -Not -Throw - } + It 'Should not throw when passed an invalid LogMode with LogRetention' { + { Test-TargetResource -LogName 'Application' -LogMode 'Circular' -LogRetentionDays 30 -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw + } - It 'Should return $true if LogFilePath is in desired state' { - Test-TargetResource -LogName 'Application' -LogFilePath '%SystemRoot%\System32\Winevt\Logs\Application.evtx' -IsEnabled $true | Should -BeTrue - } + It 'Should not throw when passed an valid LogFilePath' { + { Test-TargetResource -LogName 'Application' -IsEnabled $true -LogFilePath '%SystemRoot%\System32\Winevt\Logs\Application.evtx' -ErrorAction Stop } | Should -Not -Throw + } - It 'Should return $false if LogFilePath is not in desired state' { - Test-TargetResource -LogName 'Application' -LogFilePath '%SystemRoot%\System32\Winevt\OtherLogs\Application.evtx' -IsEnabled $true | Should -BeFalse - } + It 'Should return $true if LogFilePath is in desired state' { + Test-TargetResource -LogName 'Application' -LogFilePath '%SystemRoot%\System32\Winevt\Logs\Application.evtx' -IsEnabled $true | Should -BeTrue + } - It 'Should not throw when passed an valid SecurityDescriptor' { - { Test-TargetResource -LogName 'Application' -SecurityDescriptor 'TestDescriptor' -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw - } + It 'Should return $false if LogFilePath is not in desired state' { + Test-TargetResource -LogName 'Application' -LogFilePath '%SystemRoot%\System32\Winevt\OtherLogs\Application.evtx' -IsEnabled $true | Should -BeFalse + } - It 'Should return $true if SecurityDescriptor is in desired state' { - Test-TargetResource -LogName 'Application' -SecurityDescriptor 'TestDescriptor' -IsEnabled $true | Should -BeTrue - } + It 'Should not throw when passed an valid SecurityDescriptor' { + { Test-TargetResource -LogName 'Application' -SecurityDescriptor 'TestDescriptor' -IsEnabled $true -ErrorAction Stop } | Should -Not -Throw + } - It 'Should return $false if SecurityDescriptor is not in desired state' { - Test-TargetResource -LogName 'Application' -SecurityDescriptor 'TestTestDescriptor' -IsEnabled $true | Should -BeFalse - } + It 'Should return $true if SecurityDescriptor is in desired state' { + Test-TargetResource -LogName 'Application' -SecurityDescriptor 'TestDescriptor' -IsEnabled $true | Should -BeTrue + } - It 'Should return $true if IsEnabled is in desired state' { - Test-TargetResource -LogName 'Application' -IsEnabled $true | Should -BeTrue - } + It 'Should return $false if SecurityDescriptor is not in desired state' { + Test-TargetResource -LogName 'Application' -SecurityDescriptor 'TestTestDescriptor' -IsEnabled $true | Should -BeFalse + } - It 'Should return $false if IsEnabled is not in desired state' { - Test-TargetResource -LogName 'Application' -IsEnabled $false | Should -BeFalse - } + It 'Should return $true if IsEnabled is in desired state' { + Test-TargetResource -LogName 'Application' -IsEnabled $true | Should -BeTrue + } - It 'Should return $false if IsEnabled is not in desired state' { - Mock -CommandName Get-WindowsEventLog -MockWith { - $properties = @{ - MaximumSizeInBytes = 1028kb - IsEnabled = $false - LogName = 'Application' - } + It 'Should return $false if IsEnabled is not in desired state' { + Test-TargetResource -LogName 'Application' -IsEnabled $false | Should -BeFalse + } - return (New-Object -TypeName PSObject -Property $properties) + It 'Should return $false if IsEnabled is not in desired state' { + Mock -CommandName Get-WindowsEventLog -MockWith { + $properties = @{ + MaximumSizeInBytes = 1028kb + IsEnabled = $false + LogName = 'Application' } - Test-TargetResource -LogName 'Application' -IsEnabled $true | Should -BeFalse + return (New-Object -TypeName PSObject -Property $properties) } - It 'Should return $true if IsEnabled is not in desired state' { - Mock -CommandName Get-WindowsEventLog -MockWith { - $properties = @{ - MaximumSizeInBytes = 1028kb - IsEnabled = $true - LogName = 'Application' - } - - return (New-Object -TypeName PSObject -Property $properties) - } - - Test-TargetResource -LogName 'Application' -IsEnabled $true | Should -BeTrue - } + Test-TargetResource -LogName 'Application' -IsEnabled $true | Should -BeFalse } - Describe "$($script:dscResourceName)\Set-TargetResource" -Tag 'Set' { + It 'Should return $true if IsEnabled is not in desired state' { Mock -CommandName Get-WindowsEventLog -MockWith { $properties = @{ - MaximumSizeInBytes = 5000kb + MaximumSizeInBytes = 1028kb IsEnabled = $true - LogMode = 'AutoBackup' - LogFilePath = 'c:\logs\test.evtx' - SecurityDescriptor = 'TestDescriptor' - LogRetentionDays = '7' - LogName = 'TestLog' + LogName = 'Application' } return (New-Object -TypeName PSObject -Property $properties) } - Mock -CommandName Get-EventLog -MockWith { - $params = @{ - MinimumRetentionDays = '7' - Log = 'TestLog' - } + Test-TargetResource -LogName 'Application' -IsEnabled $true | Should -BeTrue + } + } - return (New-Object -TypeName PSObject -Property $params) + Describe 'DSC_WindowsEventLog\Set-TargetResource' -Tag 'Set' { + Mock -CommandName Get-WindowsEventLog -MockWith { + $properties = @{ + MaximumSizeInBytes = 5000kb + IsEnabled = $true + LogMode = 'AutoBackup' + LogFilePath = 'c:\logs\test.evtx' + SecurityDescriptor = 'TestDescriptor' + LogRetentionDays = '7' + LogName = 'TestLog' } - It 'Should set MaximumSizeInBytes to 1028kb' { - Mock -CommandName Save-LogFile - Set-TargetResource -MaximumSizeInBytes 1028kb -IsEnabled $true -LogName 'TestLog' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It - } + return (New-Object -TypeName PSObject -Property $properties) + } - It 'MaximumSizeInBytes is in desired state' { - Mock -CommandName Save-LogFile - Set-TargetResource -MaximumSizeInBytes 5000kb -IsEnabled $true -LogName 'TestLog' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 0 -Scope It + Mock -CommandName Get-EventLog -MockWith { + $params = @{ + MinimumRetentionDays = '7' + Log = 'TestLog' } - It 'Should set SecurityDescriptor to OtherTestDescriptor' { - Mock -CommandName Save-LogFile - Set-TargetResource -IsEnabled $true -LogName 'TestLog' -SecurityDescriptor 'OtherTestDescriptor' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It - } + return (New-Object -TypeName PSObject -Property $params) + } - It 'SecurityDescriptor is in desired state' { - Mock -CommandName Save-LogFile - Set-TargetResource -IsEnabled $true -LogName 'TestLog' -SecurityDescriptor 'TestDescriptor' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 0 -Scope It - } + It 'Should set MaximumSizeInBytes to 1028kb' { + Mock -CommandName Save-LogFile + Set-TargetResource -MaximumSizeInBytes 1028kb -IsEnabled $true -LogName 'TestLog' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It + } - It 'Should set LogFilePath to default path' { - Mock -CommandName Save-LogFile - Set-TargetResource -IsEnabled $true -LogName 'TestLog' -LogFilePath '%SystemRoot%\System32\Winevt\Logs\Application.evtx' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It - } + It 'MaximumSizeInBytes is in desired state' { + Mock -CommandName Save-LogFile + Set-TargetResource -MaximumSizeInBytes 5000kb -IsEnabled $true -LogName 'TestLog' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 0 -Scope It + } - It 'LogFilePath is in desired state' { - Mock -CommandName Save-LogFile - Set-TargetResource -IsEnabled $true -LogName 'TestLog' -LogFilePath 'c:\logs\test.evtx' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 0 -Scope It - } + It 'Should set SecurityDescriptor to OtherTestDescriptor' { + Mock -CommandName Save-LogFile + Set-TargetResource -IsEnabled $true -LogName 'TestLog' -SecurityDescriptor 'OtherTestDescriptor' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It + } - It 'Should set LogRetentionDays to 14 days' { - Mock -CommandName Set-LogRetentionDays - Set-TargetResource -LogRetentionDays '14' -IsEnabled $true -LogName 'TestLog' -LogMode 'Autobackup' - Assert-MockCalled -CommandName Set-LogRetentionDays -Exactly -Times 1 -Scope It - } + It 'SecurityDescriptor is in desired state' { + Mock -CommandName Save-LogFile + Set-TargetResource -IsEnabled $true -LogName 'TestLog' -SecurityDescriptor 'TestDescriptor' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 0 -Scope It + } - It 'Should set LogRetentionDays to 32 days, wrong Logmode' { - Mock -CommandName Set-LogRetentionDays - Set-TargetResource -LogRetentionDays '32' -IsEnabled $true -LogName 'TestLog' -LogMode 'Circular' - Assert-MockCalled -CommandName Set-LogRetentionDays -Exactly -Times 0 -Scope It - } + It 'Should set LogFilePath to default path' { + Mock -CommandName Save-LogFile + Set-TargetResource -IsEnabled $true -LogName 'TestLog' -LogFilePath '%SystemRoot%\System32\Winevt\Logs\Application.evtx' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It + } - It 'Should set LogRetentionDays is in desired state' { - Mock -CommandName Set-LogRetentionDays - Set-TargetResource -LogRetentionDays '7' -IsEnabled $true -LogName 'TestLog' -LogMode 'Autobackup' - Assert-MockCalled -CommandName Set-LogRetentionDays -Exactly -Times 0 -Scope It - } + It 'LogFilePath is in desired state' { + Mock -CommandName Save-LogFile + Set-TargetResource -IsEnabled $true -LogName 'TestLog' -LogFilePath 'c:\logs\test.evtx' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 0 -Scope It + } - It 'Should set IsEnabled to false' { - Mock -CommandName Save-LogFile - Set-TargetResource -IsEnabled $false -LogName 'TestLog' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It - } + It 'Should set LogRetentionDays to 14 days' { + Mock -CommandName Set-LogRetentionDays + Set-TargetResource -LogRetentionDays '14' -IsEnabled $true -LogName 'TestLog' -LogMode 'Autobackup' + Assert-MockCalled -CommandName Set-LogRetentionDays -Exactly -Times 1 -Scope It + } - It 'IsEnabled is in desired state' { - Mock -CommandName Save-LogFile - Set-TargetResource -IsEnabled $true -LogName 'TestLog' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 0 -Scope It - } + It 'Should set LogRetentionDays to 32 days, wrong Logmode' { + Mock -CommandName Set-LogRetentionDays + Set-TargetResource -LogRetentionDays '32' -IsEnabled $true -LogName 'TestLog' -LogMode 'Circular' + Assert-MockCalled -CommandName Set-LogRetentionDays -Exactly -Times 0 -Scope It + } - It 'IsEnabled is not in desired state' { - Mock -CommandName Save-LogFile - Set-TargetResource -IsEnabled $false -LogName 'TestLog' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It - } + It 'Should set LogRetentionDays is in desired state' { + Mock -CommandName Set-LogRetentionDays + Set-TargetResource -LogRetentionDays '7' -IsEnabled $true -LogName 'TestLog' -LogMode 'Autobackup' + Assert-MockCalled -CommandName Set-LogRetentionDays -Exactly -Times 0 -Scope It + } - It 'Should throw if IsEnabled is not in desired state' { - Mock -CommandName Save-LogFile - Mock -CommandName Get-WindowsEventLog -MockWith { throw } - { Set-TargetResource -LogName 'SomeLog' -IsEnabled $false } | Should -Throw - } + It 'Should set IsEnabled to false' { + Mock -CommandName Save-LogFile + Set-TargetResource -IsEnabled $false -LogName 'TestLog' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It + } + + It 'IsEnabled is in desired state' { + Mock -CommandName Save-LogFile + Set-TargetResource -IsEnabled $true -LogName 'TestLog' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 0 -Scope It + } - It 'IsEnabled is not in desired state' { - Mock -CommandName Get-WindowsEventLog -MockWith { - $properties = @{ - MaximumSizeInBytes = 5000kb - IsEnabled = $false - LogMode = 'AutoBackup' - LogFilePath = 'c:\logs\test.evtx' - SecurityDescriptor = 'TestDescriptor' - LogRetentionDays = '7' - LogName = 'TestLog' - } - - return (New-Object -TypeName PSObject -Property $properties) + It 'IsEnabled is not in desired state' { + Mock -CommandName Save-LogFile + Set-TargetResource -IsEnabled $false -LogName 'TestLog' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It + } + + It 'Should throw if IsEnabled is not in desired state' { + Mock -CommandName Save-LogFile + Mock -CommandName Get-WindowsEventLog -MockWith { throw } + { Set-TargetResource -LogName 'SomeLog' -IsEnabled $false } | Should -Throw + } + + It 'IsEnabled is not in desired state' { + Mock -CommandName Get-WindowsEventLog -MockWith { + $properties = @{ + MaximumSizeInBytes = 5000kb + IsEnabled = $false + LogMode = 'AutoBackup' + LogFilePath = 'c:\logs\test.evtx' + SecurityDescriptor = 'TestDescriptor' + LogRetentionDays = '7' + LogName = 'TestLog' } - Set-TargetResource -IsEnabled $true -LogName 'TestLog' - Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It + return (New-Object -TypeName PSObject -Property $properties) } - Describe "$($script:dscResourceName)\Save-LogFile" -Tag 'Helper' { + Set-TargetResource -IsEnabled $true -LogName 'TestLog' + Assert-MockCalled -CommandName Save-LogFile -Exactly -Times 1 -Scope It + } + + Describe 'DSC_WindowsEventLog\Save-LogFile' -Tag 'Helper' { Mock -CommandName Limit-Eventlog -MockWith { throw } It 'Should throw if we are unable to get a log' { - { Limit-Eventlog -LogName 'Application' -OverflowAction 'OverwriteOlder' -RetentionDays 30 } | Should -Throw + { Limit-Eventlog -LogName 'Application' -OverflowAction 'OverwriteOlder' -RetentionDays 30 } | Should -Throw } } - Describe "$($script:dscResourceName)\Set-LogRetentionDays" -Tag 'Helper' { + Describe 'DSC_WindowsEventLog\Set-LogRetentionDays' -Tag 'Helper' { Mock -CommandName Limit-Eventlog -MockWith { throw } It 'Should throw if we are unable to get a log' { - { Limit-Eventlog -LogName 'Application' -OverflowAction 'OverwriteOlder' -RetentionDays 30 } | Should -Throw + { Limit-Eventlog -LogName 'Application' -OverflowAction 'OverwriteOlder' -RetentionDays 30 } | Should -Throw } } } @@ -387,5 +392,5 @@ try } finally { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Invoke-TestCleanup } From 5609c724ffdb6a13b4be08335cfe53ceb3dff09d Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 20:55:50 +1300 Subject: [PATCH 05/30] Fix first integration test --- CHANGELOG.md | 2 +- tests/Integration/DSC_PendingReboot.Tests.ps1 | 184 +++++++++--------- 2 files changed, 94 insertions(+), 92 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b8339b0..8b6fef35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# Change log for NetworkingDSc +# Change log for ComputerManagementDsc The format is based on and uses the types of changes according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). diff --git a/tests/Integration/DSC_PendingReboot.Tests.ps1 b/tests/Integration/DSC_PendingReboot.Tests.ps1 index 22247407..cde2162d 100644 --- a/tests/Integration/DSC_PendingReboot.Tests.ps1 +++ b/tests/Integration/DSC_PendingReboot.Tests.ps1 @@ -1,115 +1,118 @@ -#region HEADER -$script:dscModuleName = 'ComputerManagementDsc' +$script:dscModuleName = 'NetworkingDsc' $script:dscResourceName = 'DSC_PendingReboot' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') + +# Begin Testing try { - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" - . $configFile - - Describe "$($script:dscResourceName)_Integration" { - <# - These integration tests will not actually reboot the node - because that would terminate the tests and cause them to fail. - - There does not appear to be a method of determining if the - reboot is in fact triggered, so this is not currently tested. - - Instead, we will preserve the current state of the Auto Update - reboot flag and then set it to reboot required. After the tests - have run we will determine if the Get-TargetResource indicates - that a reboot would have been required. - #> - $windowsUpdateKeys = (Get-ChildItem -Path $rebootRegistryKeys.WindowsUpdate).Name - - if ($windowsUpdateKeys) - { - $script:currentAutoUpdateRebootState = $windowsUpdateKeys.Split('\') -contains 'RebootRequired' - } + Describe 'PendingReboot Integration Tests' { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" + . $configFile - if (-not $script:currentAutoUpdateRebootState) - { - $null = New-Item ` - -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\' ` - -Name 'RebootRequired' - } + Describe "$($script:dscResourceName)_Integration" { + <# + These integration tests will not actually reboot the node + because that would terminate the tests and cause them to fail. - $configData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - RebootName = 'TestReboot' - SkipComponentBasedServicing = $false - SkipWindowsUpdate = $false - SkipPendingFileRename = $false - SkipPendingComputerRename = $false - SkipCcmClientSDK = $true - } - ) - } + There does not appear to be a method of determining if the + reboot is in fact triggered, so this is not currently tested. - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:dscResourceName)_Config" ` - -OutputPath $TestDrive ` - -ConfigurationData $configData - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } + Instead, we will preserve the current state of the Auto Update + reboot flag and then set it to reboot required. After the tests + have run we will determine if the Get-TargetResource indicates + that a reboot would have been required. + #> + $windowsUpdateKeys = (Get-ChildItem -Path $rebootRegistryKeys.WindowsUpdate).Name - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } + if ($windowsUpdateKeys) + { + $script:currentAutoUpdateRebootState = $windowsUpdateKeys.Split('\') -contains 'RebootRequired' + } - It 'Should be able to call Get-DscConfiguration without throwing' { + if (-not $script:currentAutoUpdateRebootState) { - Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } + $null = New-Item ` + -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\' ` + -Name 'RebootRequired' + } + + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + RebootName = 'TestReboot' + SkipComponentBasedServicing = $false + SkipWindowsUpdate = $false + SkipPendingFileRename = $false + SkipPendingComputerRename = $false + SkipCcmClientSDK = $true + } + ) + } + + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { + Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.Name | Should -Be $configData.AllNodes[0].RebootName + $current.SkipComponentBasedServicing | Should -Be $configData.AllNodes[0].SkipComponentBasedServicing + $current.ComponentBasedServicing | Should -BeFalse + $current.SkipWindowsUpdate | Should -Be $configData.AllNodes[0].SkipWindowsUpdate + $current.WindowsUpdate | Should -BeTrue + $current.SkipPendingFileRename | Should -Be $configData.AllNodes[0].SkipPendingFileRename + $current.PendingFileRename | Should -BeFalse + $current.SkipPendingComputerRename | Should -Be $configData.AllNodes[0].SkipPendingComputerRename + $current.PendingComputerRename | Should -BeFalse + $current.SkipCcmClientSDK | Should -Be $configData.AllNodes[0].SkipCcmClientSDK + $current.CcmClientSDK | Should -BeFalse + $current.RebootRequired | Should -BeTrue } - $current.Name | Should -Be $configData.AllNodes[0].RebootName - $current.SkipComponentBasedServicing | Should -Be $configData.AllNodes[0].SkipComponentBasedServicing - $current.ComponentBasedServicing | Should -BeFalse - $current.SkipWindowsUpdate | Should -Be $configData.AllNodes[0].SkipWindowsUpdate - $current.WindowsUpdate | Should -BeTrue - $current.SkipPendingFileRename | Should -Be $configData.AllNodes[0].SkipPendingFileRename - $current.PendingFileRename | Should -BeFalse - $current.SkipPendingComputerRename | Should -Be $configData.AllNodes[0].SkipPendingComputerRename - $current.PendingComputerRename | Should -BeFalse - $current.SkipCcmClientSDK | Should -Be $configData.AllNodes[0].SkipCcmClientSDK - $current.CcmClientSDK | Should -BeFalse - $current.RebootRequired | Should -BeTrue } } } finally { - #region FOOTER if (-not $script:currentAutoUpdateRebootState) { $null = Remove-Item ` @@ -117,6 +120,5 @@ finally -ErrorAction SilentlyContinue } - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } From d9954a764297fe7e9afe7f875ab44a79ce90a23b Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 21:06:47 +1300 Subject: [PATCH 06/30] Fix HQRM violations --- source/DSCResources/DSC_Computer/DSC_Computer.psm1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/DSCResources/DSC_Computer/DSC_Computer.psm1 b/source/DSCResources/DSC_Computer/DSC_Computer.psm1 index 4ad282ee..9664928f 100644 --- a/source/DSCResources/DSC_Computer/DSC_Computer.psm1 +++ b/source/DSCResources/DSC_Computer/DSC_Computer.psm1 @@ -90,18 +90,18 @@ function Get-TargetResource $convertToCimCredential = New-CimInstance ` -ClassName DSC_Credential ` -Property @{ - Username = [System.String] $Credential.UserName - Password = [System.String] $null - } ` + Username = [System.String] $Credential.UserName + Password = [System.String] $null + } ` -Namespace root/microsoft/windows/desiredstateconfiguration ` -ClientOnly $convertToCimUnjoinCredential = New-CimInstance ` -ClassName DSC_Credential ` -Property @{ - Username = [System.String] $UnjoinCredential.UserName - Password = [System.String] $null - } ` + Username = [System.String] $UnjoinCredential.UserName + Password = [System.String] $null + } ` -Namespace root/microsoft/windows/desiredstateconfiguration ` -ClientOnly From abf76cac9de904cfce43a3e38a410b4017411e64 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 21:07:40 +1300 Subject: [PATCH 07/30] Fix integration test --- tests/Integration/DSC_PendingReboot.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Integration/DSC_PendingReboot.Tests.ps1 b/tests/Integration/DSC_PendingReboot.Tests.ps1 index cde2162d..bb19c65e 100644 --- a/tests/Integration/DSC_PendingReboot.Tests.ps1 +++ b/tests/Integration/DSC_PendingReboot.Tests.ps1 @@ -1,4 +1,4 @@ -$script:dscModuleName = 'NetworkingDsc' +$script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_PendingReboot' try From 74ec777e2fc90e0a23678ac282cd2ba0fbd02cab Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 21:20:09 +1300 Subject: [PATCH 08/30] Fix more integration tests --- ...ShellExecutionPolicy.Integration.Tests.ps1 | 87 +- ...C_RemoteDesktopAdmin.Integration.Tests.ps1 | 304 ++++--- .../DSC_ScheduledTask.Integration.Tests.ps1 | 543 ++++++------ .../DSC_SmbServerConfiguration.Tests.ps1 | 266 +++--- .../DSC_SmbShare.Integration.Tests.ps1 | 814 +++++++++--------- .../DSC_WindowsEventLog.Integration.Tests.ps1 | 551 ++++++------ 6 files changed, 1277 insertions(+), 1288 deletions(-) diff --git a/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 b/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 index 730098f0..f0f5d9f1 100644 --- a/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 +++ b/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 @@ -1,68 +1,65 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_PowerShellExecutionPolicy' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') + +# Begin Testing try { - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" - . $configFile + Describe 'PowerShellExecutionPolicy Integration Tests' { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" + . $configFile - Describe "$($script:dscResourceName)_Integration" { - #region DEFAULT TESTS - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:dscResourceName)_Config" -OutputPath $TestDrive + Describe "$($script:dscResourceName)_Integration" { + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" -OutputPath $TestDrive - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - It 'Should be able to call Get-DscConfiguration without throwing' { - { - Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } - #endregion + It 'Should be able to call Get-DscConfiguration without throwing' { + { + Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.ExecutionPolicy | Should -Be 'RemoteSigned' + $current.ExecutionPolicyScope | Should -Be 'LocalMachine' } - $current.ExecutionPolicy | Should -Be 'RemoteSigned' - $current.ExecutionPolicyScope | Should -Be 'LocalMachine' } } - #endregion - } finally { - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 b/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 index cc0796d0..b5bd9f3b 100644 --- a/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 +++ b/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 @@ -1,171 +1,169 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_RemoteDesktopAdmin' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -# Using try/finally to always cleanup. +# Begin Testing try { - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" - . $configFile - - $script:tSRegistryKey = 'HKLM:\System\CurrentControlSet\Control\Terminal Server' - $script:winStationsRegistryKey = 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' - - Describe "$($script:dscResourceName)_Integration" { - Context 'When setting Remote Desktop for Administration to Denied' { - $CurrentConfig = 'setToDenied' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true - } - - It 'Should return the correct values from Get-DscConfiguration' { - $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} - $Current.IsSingleInstance | Should -Be 'Yes' - $Current.Ensure | Should -Be 'Absent' - } - - It 'Should have set the correct registry values' { - (Get-ItemProperty -Path $script:tSRegistryKey -Name 'fDenyTSConnections').fDenyTSConnections | Should -Be 1 - } - } - - Context 'When setting Remote Desktop for Administration to Allowed' { - $CurrentConfig = 'setToAllowed' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true - } - - It 'Should return the correct values from Get-DscConfiguration' { - $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} - $Current.IsSingleInstance | Should -Be 'Yes' - $Current.Ensure | Should -Be 'Present' - } - - It 'Should have set the correct registry values' { - (Get-ItemProperty -Path $script:tSRegistryKey -Name 'fDenyTSConnections').fDenyTSConnections | Should -Be 0 - } - } - - Context 'When settting Remote Desktop for Administration to Allowed with Secure Authentication' { - $CurrentConfig = 'setToAllowedSecure' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true - } - - It 'Should return the correct values from Get-DscConfiguration' { - $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} - $Current.IsSingleInstance | Should -Be 'Yes' - $Current.Ensure | Should -Be 'Present' - $Current.UserAuthentication | Should -Be 'Secure' - } - - It 'Should have set the correct registry values' { - (Get-ItemProperty -Path $script:tSRegistryKey -Name 'fDenyTSConnections').fDenyTSConnections | Should -Be 0 - (Get-ItemProperty -Path $script:winStationsRegistryKey -Name 'UserAuthentication').UserAuthentication | Should -Be 1 - } - } - - Context 'When settting Remote Desktop for Administration to Allowed with NonSecure Authentication' { - $CurrentConfig = 'setToAllowedNonSecure' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true - } - - It 'Should return the correct values from Get-DscConfiguration' { - $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} - $Current.IsSingleInstance | Should -Be 'Yes' - $Current.Ensure | Should -Be 'Present' - $Current.UserAuthentication | Should -Be 'NonSecure' - } - - It 'Should have set the correct registry values' { - (Get-ItemProperty -Path $script:tSRegistryKey -Name 'fDenyTSConnections').fDenyTSConnections | Should -Be 0 - (Get-ItemProperty -Path $script:winStationsRegistryKey -Name 'UserAuthentication').UserAuthentication | Should -Be 0 + Describe 'RemoteDesktopAdmin Integration Tests' { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" + . $configFile + + $script:tSRegistryKey = 'HKLM:\System\CurrentControlSet\Control\Terminal Server' + $script:winStationsRegistryKey = 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' + + Describe "$($script:dscResourceName)_Integration" { + Context 'When setting Remote Desktop for Administration to Denied' { + $CurrentConfig = 'setToDenied' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true + } + + It 'Should return the correct values from Get-DscConfiguration' { + $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} + $Current.IsSingleInstance | Should -Be 'Yes' + $Current.Ensure | Should -Be 'Absent' + } + + It 'Should have set the correct registry values' { + (Get-ItemProperty -Path $script:tSRegistryKey -Name 'fDenyTSConnections').fDenyTSConnections | Should -Be 1 + } + } + + Context 'When setting Remote Desktop for Administration to Allowed' { + $CurrentConfig = 'setToAllowed' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true + } + + It 'Should return the correct values from Get-DscConfiguration' { + $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} + $Current.IsSingleInstance | Should -Be 'Yes' + $Current.Ensure | Should -Be 'Present' + } + + It 'Should have set the correct registry values' { + (Get-ItemProperty -Path $script:tSRegistryKey -Name 'fDenyTSConnections').fDenyTSConnections | Should -Be 0 + } + } + + Context 'When settting Remote Desktop for Administration to Allowed with Secure Authentication' { + $CurrentConfig = 'setToAllowedSecure' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true + } + + It 'Should return the correct values from Get-DscConfiguration' { + $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} + $Current.IsSingleInstance | Should -Be 'Yes' + $Current.Ensure | Should -Be 'Present' + $Current.UserAuthentication | Should -Be 'Secure' + } + + It 'Should have set the correct registry values' { + (Get-ItemProperty -Path $script:tSRegistryKey -Name 'fDenyTSConnections').fDenyTSConnections | Should -Be 0 + (Get-ItemProperty -Path $script:winStationsRegistryKey -Name 'UserAuthentication').UserAuthentication | Should -Be 1 + } + } + + Context 'When settting Remote Desktop for Administration to Allowed with NonSecure Authentication' { + $CurrentConfig = 'setToAllowedNonSecure' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true + } + + It 'Should return the correct values from Get-DscConfiguration' { + $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} + $Current.IsSingleInstance | Should -Be 'Yes' + $Current.Ensure | Should -Be 'Present' + $Current.UserAuthentication | Should -Be 'NonSecure' + } + + It 'Should have set the correct registry values' { + (Get-ItemProperty -Path $script:tSRegistryKey -Name 'fDenyTSConnections').fDenyTSConnections | Should -Be 0 + (Get-ItemProperty -Path $script:winStationsRegistryKey -Name 'UserAuthentication').UserAuthentication | Should -Be 0 + } } } } } finally { - #region FOOTER - - Restore-TestEnvironment -TestEnvironment $TestEnvironment - - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 b/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 index 5a202661..cdd656a0 100644 --- a/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 +++ b/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 @@ -1,75 +1,166 @@ #Requires -Version 5.0 -#region HEADER + $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_ScheduledTask' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global - -# Load the ComputerManagementDsc.Common module to use Set-TimezoneId function -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'Modules' -ChildPath 'ComputerManagementDsc.Common')) -Force +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') # Begin Testing try { - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" - . $ConfigFile - - #region Pester Tests - Describe $script:dscResourceName { - - $contexts = @{ - Once = 'ScheduledTaskOnce' - Daily = 'ScheduledTaskDaily' - DailyIndefinitely = 'ScheduledTaskDailyIndefinitely' - Weekly = 'ScheduledTaskWeekly' - AtLogon = 'ScheduledTaskLogon' - AtStartup = 'ScheduledTaskStartup' - ExecuteAs = 'ScheduledTaskExecuteAs' - ExecuteAsGroup = 'ScheduledTaskExecuteAsGroup' - OnEvent = 'ScheduledTaskOnEvent' - } + Describe 'ScheduledTask Integration Tests' { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" + . $configFile + + #region Pester Tests + Describe "$($script:dscResourceName)_Integration" { + $contexts = @{ + Once = 'ScheduledTaskOnce' + Daily = 'ScheduledTaskDaily' + DailyIndefinitely = 'ScheduledTaskDailyIndefinitely' + Weekly = 'ScheduledTaskWeekly' + AtLogon = 'ScheduledTaskLogon' + AtStartup = 'ScheduledTaskStartup' + ExecuteAs = 'ScheduledTaskExecuteAs' + ExecuteAsGroup = 'ScheduledTaskExecuteAsGroup' + OnEvent = 'ScheduledTaskOnEvent' + } + + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + PSDscAllowPlainTextPassword = $true + } + ) + } - $configData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - PSDscAllowPlainTextPassword = $true + foreach ($contextInfo in $contexts.GetEnumerator()) + { + Context "[$($contextInfo.Key)] No scheduled task exists but it should" { + $currentConfig = '{0}Add' -f $contextInfo.Value + $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) + $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') + + It 'Should compile the MOF without throwing' { + { + . $currentConfig ` + -OutputPath $configDir ` + -ConfigurationData $configData + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration ` + -Path $configDir ` + -Wait ` + -Force ` + -Verbose ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue + } + } + + Context "[$($contextInfo.Key)] A scheduled task exists with the wrong settings" { + $currentConfig = '{0}Mod' -f $contextInfo.Value + $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) + $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') + + It 'Should compile the MOF without throwing' { + { + . $currentConfig ` + -OutputPath $configDir ` + -ConfigurationData $configData + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration ` + -Path $configDir ` + -Wait ` + -Force ` + -Verbose ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue + } } - ) - } - foreach ($contextInfo in $contexts.GetEnumerator()) - { - Context "[$($contextInfo.Key)] No scheduled task exists but it should" { - $currentConfig = '{0}Add' -f $contextInfo.Value + Context "[$($contextInfo.Key)] A scheduled tasks exists but it should not" { + $currentConfig = '{0}Del' -f $contextInfo.Value + $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) + $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') + + It 'Should compile the MOF without throwing' { + { + . $currentConfig ` + -OutputPath $configDir ` + -ConfigurationData $configData + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration ` + -Path $configDir ` + -Wait ` + -Force ` + -Verbose ` + -ErrorAction Stop + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue + } + } + } + + Context 'MOF is created in a different timezone to node MOF being applied to' { + BeforeAll { + $currentTimeZoneId = Get-TimeZoneId + } + + $currentConfig = 'ScheduledTaskOnceCrossTimezone' $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') - It 'Should compile the MOF without throwing' { + It 'Should compile the MOF without throwing in W. Australia Standard Time Timezone' { { + + Set-TimeZoneId -TimeZoneId 'W. Australia Standard Time' . $currentConfig ` - -OutputPath $configDir ` - -ConfigurationData $configData + -OutputPath $configDir } | Should -Not -Throw } - It 'Should apply the MOF correctly' { + It 'Should apply the MOF correctly in New Zealand Standard Time Timezone' { { + Set-TimeZoneId -TimeZoneId 'New Zealand Standard Time' Start-DscConfiguration ` -Path $configDir ` -Wait ` @@ -82,18 +173,39 @@ try It 'Should return a compliant state after being applied' { (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue } + + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $currentConfig} + $current.TaskName | Should -Be 'Test task once cross timezone' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + $current.ScheduleType | Should -Be 'Once' + $current.RepeatInterval | Should -Be '00:15:00' + $current.RepetitionDuration | Should -Be '23:00:00' + $current.ActionWorkingPath | Should -Be (Get-Location).Path + $current.Enable | Should -BeTrue + $current.RandomDelay | Should -Be '01:00:00' + $current.DisallowHardTerminate | Should -BeTrue + $current.RunOnlyIfIdle | Should -BeFalse + $current.Priority | Should -Be 9 + $current.RunLevel | Should -Be 'Limited' + $current.ExecutionTimeLimit | Should -Be '00:00:00' + } + + AfterAll { + Set-TimeZoneId -TimeZoneId $currentTimeZoneId + } } - Context "[$($contextInfo.Key)] A scheduled task exists with the wrong settings" { - $currentConfig = '{0}Mod' -f $contextInfo.Value + Context 'When a scheduled task is created and synchronize across time zone is disabled' { + $currentConfig = 'ScheduledTaskOnceSynchronizeAcrossTimeZoneDisabled' $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') It 'Should compile the MOF without throwing' { { . $currentConfig ` - -OutputPath $configDir ` - -ConfigurationData $configData + -OutputPath $configDir } | Should -Not -Throw } @@ -111,18 +223,36 @@ try It 'Should return a compliant state after being applied' { (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue } + + $expectedStartTime = '2018-10-01T01:00:00' + + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $currentConfig} + $current.TaskName | Should -Be 'Test task sync across time zone disabled' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + $current.ScheduleType | Should -Be 'Once' + $current.StartTime | Should -Be (Get-Date -Date $expectedStartTime) + $current.SynchronizeAcrossTimeZone | Should -BeFalse + $current.ActionWorkingPath | Should -Be (Get-Location).Path + $current.Enable | Should -BeTrue + } + + It "Should have the trigger startBoundary set to $expectedStartTime" { + $task = (Get-ScheduledTask -TaskName 'Test task sync across time zone disabled') + $task.Triggers[0].StartBoundary | Should -Be $expectedStartTime + } } - Context "[$($contextInfo.Key)] A scheduled tasks exists but it should not" { - $currentConfig = '{0}Del' -f $contextInfo.Value + Context 'When a scheduled task is created and synchronize across time zone is enabled' { + $currentConfig = 'ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled' $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') It 'Should compile the MOF without throwing' { { . $currentConfig ` - -OutputPath $configDir ` - -ConfigurationData $configData + -OutputPath $configDir } | Should -Not -Throw } @@ -140,248 +270,114 @@ try It 'Should return a compliant state after being applied' { (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue } - } - } - - Context "MOF is created in a different timezone to node MOF being applied to" { - BeforeAll { - $currentTimeZoneId = Get-TimeZoneId - } - - $currentConfig = 'ScheduledTaskOnceCrossTimezone' - $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) - $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') - - It 'Should compile the MOF without throwing in W. Australia Standard Time Timezone' { - { - - Set-TimeZoneId -TimeZoneId 'W. Australia Standard Time' - . $currentConfig ` - -OutputPath $configDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly in New Zealand Standard Time Timezone' { - { - Set-TimeZoneId -TimeZoneId 'New Zealand Standard Time' - Start-DscConfiguration ` - -Path $configDir ` - -Wait ` - -Force ` - -Verbose ` - -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue - } - - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $currentConfig} - $current.TaskName | Should -Be 'Test task once cross timezone' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - $current.ScheduleType | Should -Be 'Once' - $current.RepeatInterval | Should -Be '00:15:00' - $current.RepetitionDuration | Should -Be '23:00:00' - $current.ActionWorkingPath | Should -Be (Get-Location).Path - $current.Enable | Should -BeTrue - $current.RandomDelay | Should -Be '01:00:00' - $current.DisallowHardTerminate | Should -BeTrue - $current.RunOnlyIfIdle | Should -BeFalse - $current.Priority | Should -Be 9 - $current.RunLevel | Should -Be 'Limited' - $current.ExecutionTimeLimit | Should -Be '00:00:00' - } - - AfterAll { - Set-TimeZoneId -TimeZoneId $currentTimeZoneId - } - } - - Context "When a scheduled task is created and synchronize across time zone is disabled" { - $currentConfig = 'ScheduledTaskOnceSynchronizeAcrossTimeZoneDisabled' - $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) - $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') - - It 'Should compile the MOF without throwing' { - { - . $currentConfig ` - -OutputPath $configDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration ` - -Path $configDir ` - -Wait ` - -Force ` - -Verbose ` - -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue - } - - $expectedStartTime = '2018-10-01T01:00:00' - - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $currentConfig} - $current.TaskName | Should -Be 'Test task sync across time zone disabled' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - $current.ScheduleType | Should -Be 'Once' - $current.StartTime | Should -Be (Get-Date -Date $expectedStartTime) - $current.SynchronizeAcrossTimeZone | Should -BeFalse - $current.ActionWorkingPath | Should -Be (Get-Location).Path - $current.Enable | Should -BeTrue - } - - It "Should have the trigger startBoundary set to $expectedStartTime" { - $task = (Get-ScheduledTask -TaskName 'Test task sync across time zone disabled') - $task.Triggers[0].StartBoundary | Should -Be $expectedStartTime - } - } - - Context "When a scheduled task is created and synchronize across time zone is enabled" { - $currentConfig = 'ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled' - $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) - $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') - - It 'Should compile the MOF without throwing' { - { - . $currentConfig ` - -OutputPath $configDir - } | Should -Not -Throw - } - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration ` - -Path $configDir ` - -Wait ` - -Force ` - -Verbose ` - -ErrorAction Stop - } | Should -Not -Throw - } + $expectedStartTime = '2018-10-01T01:00:00' + (Get-Date -Format 'zzz') + + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $currentConfig} + $current.TaskName | Should -Be 'Test task sync across time zone enabled' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + $current.ScheduleType | Should -Be 'Once' + $current.StartTime | Should -Be (Get-Date -Date $expectedStartTime) + $current.SynchronizeAcrossTimeZone | Should -BeTrue + $current.ActionWorkingPath | Should -Be (Get-Location).Path + $current.Enable | Should -BeTrue + } - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue + It "Should have the trigger startBoundary set to $expectedStartTime" { + $task = (Get-ScheduledTask -TaskName 'Test task sync across time zone enabled') + $task.Triggers[0].StartBoundary | Should -Be $expectedStartTime + } } - $expectedStartTime = '2018-10-01T01:00:00' + (Get-Date -Format 'zzz') - - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $currentConfig} - $current.TaskName | Should -Be 'Test task sync across time zone enabled' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - $current.ScheduleType | Should -Be 'Once' - $current.StartTime | Should -Be (Get-Date -Date $expectedStartTime) - $current.SynchronizeAcrossTimeZone | Should -BeTrue - $current.ActionWorkingPath | Should -Be (Get-Location).Path - $current.Enable | Should -BeTrue - } + # Simulate a "built-in" scheduled task + $action = New-ScheduledTaskAction -Execute 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) + $task = New-ScheduledTask -Action $action -Trigger $trigger + Register-ScheduledTask -InputObject $task -TaskName 'Test task builtin' -TaskPath '\ComputerManagementDsc\' -User 'NT AUTHORITY\SYSTEM' - It "Should have the trigger startBoundary set to $expectedStartTime" { - $task = (Get-ScheduledTask -TaskName 'Test task sync across time zone enabled') - $task.Triggers[0].StartBoundary | Should -Be $expectedStartTime - } - } + Context 'Built-in task needs to be disabled' { + $currentConfig = 'ScheduledTaskDisableBuiltIn' + $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) + $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') - # Simulate a "built-in" scheduled task - $action = New-ScheduledTaskAction -Execute 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) - $task = New-ScheduledTask -Action $action -Trigger $trigger - Register-ScheduledTask -InputObject $task -TaskName 'Test task builtin' -TaskPath '\ComputerManagementDsc\' -User 'NT AUTHORITY\SYSTEM' - - Context 'Built-in task needs to be disabled' { - $currentConfig = 'ScheduledTaskDisableBuiltIn' - $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) - $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') - - It 'Should compile the MOF without throwing' { - { - . $currentConfig ` - -OutputPath $configDir ` - -ConfigurationData $configData - } | Should -Not -Throw - } + It 'Should compile the MOF without throwing' { + { + . $currentConfig ` + -OutputPath $configDir ` + -ConfigurationData $configData + } | Should -Not -Throw + } - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration ` - -Path $configDir ` - -Wait ` - -Force ` - -Verbose ` - -ErrorAction Stop - } | Should -Not -Throw - } + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration ` + -Path $configDir ` + -Wait ` + -Force ` + -Verbose ` + -ErrorAction Stop + } | Should -Not -Throw + } - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue - } + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue + } - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $currentConfig + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq $currentConfig + } + $current.TaskName | Should -Be 'Test task builtin' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.Enable | Should -BeFalse } - $current.TaskName | Should -Be 'Test task builtin' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.Enable | Should -BeFalse } - } - Context 'Built-in task needs to be removed' { - $currentConfig = 'ScheduledTaskRemoveBuiltIn' - $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) - $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') + Context 'Built-in task needs to be removed' { + $currentConfig = 'ScheduledTaskRemoveBuiltIn' + $configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig) + $configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof') - It 'Should compile the MOF without throwing' { - { - . $currentConfig ` - -OutputPath $configDir ` - -ConfigurationData $configData - } | Should -Not -Throw - } + It 'Should compile the MOF without throwing' { + { + . $currentConfig ` + -OutputPath $configDir ` + -ConfigurationData $configData + } | Should -Not -Throw + } - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration ` - -Path $configDir ` - -Wait ` - -Force ` - -Verbose ` - -ErrorAction Stop - } | Should -Not -Throw - } + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration ` + -Path $configDir ` + -Wait ` + -Force ` + -Verbose ` + -ErrorAction Stop + } | Should -Not -Throw + } - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue - } + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -BeTrue + } - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $currentConfig + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq $currentConfig + } + $current.TaskName | Should -Be 'Test task builtin' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.Ensure | Should -Be 'Absent' } - $current.TaskName | Should -Be 'Test task builtin' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.Ensure | Should -Be 'Absent' } } } } finally { - #region FOOTER - # Remove any traces of the created tasks Get-ScheduledTask -TaskPath '\ComputerManagementDsc\' -ErrorAction SilentlyContinue | Unregister-ScheduledTask -ErrorAction SilentlyContinue -Confirm:$false @@ -390,6 +386,5 @@ finally $rootFolder = $scheduler.GetFolder('\') $rootFolder.DeleteFolder('ComputerManagementDsc', 0) - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 b/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 index 35009228..efdc162f 100644 --- a/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 +++ b/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 @@ -1,159 +1,160 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_SmbServerConfiguration' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' -$script:CurrentSmbServerConfigBackup = Get-SmbServerConfiguration +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +# Begin Testing try { - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" - . $configFile + Describe 'SmbServerConfiguration Integration Tests' { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" + . $configFile - Describe "$($script:dscResourceName)_Integration" { + Describe "$($script:dscResourceName)_Integration" { - $configData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - IsSingleInstance = 'Yes' - AnnounceComment = 'Test String' - AnnounceServer = $true - AsynchronousCredits = 32 - AuditSmb1Access = $true - AutoDisconnectTimeout = 30 - AutoShareServer = $false - AutoShareWorkstation = $false - CachedOpenLimit = 20 - DurableHandleV2TimeoutInSeconds = 90 - EnableAuthenticateUserSharing = $true - EnableDownlevelTimewarp = $true - EnableForcedLogoff = $false - EnableLeasing = $false - EnableMultiChannel = $false - EnableOplocks = $false - EnableSecuritySignature = $true - EnableSMB1Protocol = $false - EnableSMB2Protocol = $false - EnableStrictNameChecking = $false - EncryptData = $true - IrpStackSize = 20 - KeepAliveTime = 3 - MaxChannelPerSession = 16 - MaxMpxCount = 100 - MaxSessionPerConnection = 16000 - MaxThreadsPerQueue = 15 - MaxWorkItems = 2 - NullSessionPipes = 'TestPipe' - NullSessionShares = 'TestShare' - OplockBreakWait = 30 - PendingClientTimeoutInSeconds = 60 - RejectUnencryptedAccess = $false - RequireSecuritySignature = $true - ServerHidden = $false - Smb2CreditsMax = 2000 - Smb2CreditsMin = 256 - SmbServerNameHardeningLevel = 1 - TreatHostAsStableStorage = $true - ValidateAliasNotCircular = $false - ValidateShareScope = $false - ValidateShareScopeNotAliased = $false - ValidateTargetName = $false - } - ) - } + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + IsSingleInstance = 'Yes' + AnnounceComment = 'Test String' + AnnounceServer = $true + AsynchronousCredits = 32 + AuditSmb1Access = $true + AutoDisconnectTimeout = 30 + AutoShareServer = $false + AutoShareWorkstation = $false + CachedOpenLimit = 20 + DurableHandleV2TimeoutInSeconds = 90 + EnableAuthenticateUserSharing = $true + EnableDownlevelTimewarp = $true + EnableForcedLogoff = $false + EnableLeasing = $false + EnableMultiChannel = $false + EnableOplocks = $false + EnableSecuritySignature = $true + EnableSMB1Protocol = $false + EnableSMB2Protocol = $false + EnableStrictNameChecking = $false + EncryptData = $true + IrpStackSize = 20 + KeepAliveTime = 3 + MaxChannelPerSession = 16 + MaxMpxCount = 100 + MaxSessionPerConnection = 16000 + MaxThreadsPerQueue = 15 + MaxWorkItems = 2 + NullSessionPipes = 'TestPipe' + NullSessionShares = 'TestShare' + OplockBreakWait = 30 + PendingClientTimeoutInSeconds = 60 + RejectUnencryptedAccess = $false + RequireSecuritySignature = $true + ServerHidden = $false + Smb2CreditsMax = 2000 + Smb2CreditsMin = 256 + SmbServerNameHardeningLevel = 1 + TreatHostAsStableStorage = $true + ValidateAliasNotCircular = $false + ValidateShareScope = $false + ValidateShareScopeNotAliased = $false + ValidateTargetName = $false + } + ) + } - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:dscResourceName)_Config" ` - -OutputPath $TestDrive ` - -ConfigurationData $configData + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - It 'Should be able to call Get-DscConfiguration without throwing' { - { - Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } + It 'Should be able to call Get-DscConfiguration without throwing' { + { + Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.AnnounceComment | Should -Be $configData.AllNodes[0].AnnounceComment + $current.AnnounceServer | Should -Be $configData.AllNodes[0].AnnounceServer + $current.AsynchronousCredits | Should -Be $configData.AllNodes[0].AsynchronousCredits + $current.AuditSmb1Access | Should -Be $configData.AllNodes[0].AuditSmb1Access + $current.AutoDisconnectTimeout | Should -Be $configData.AllNodes[0].AutoDisconnectTimeout + $current.AutoShareServer | Should -Be $configData.AllNodes[0].AutoShareServer + $current.AutoShareWorkstation | Should -Be $configData.AllNodes[0].AutoShareWorkstation + $current.CachedOpenLimit | Should -Be $configData.AllNodes[0].CachedOpenLimit + $current.DurableHandleV2TimeoutInSeconds | Should -Be $configData.AllNodes[0].DurableHandleV2TimeoutInSeconds + $current.EnableAuthenticateUserSharing | Should -Be $configData.AllNodes[0].EnableAuthenticateUserSharing + $current.EnableDownlevelTimewarp | Should -Be $configData.AllNodes[0].EnableDownlevelTimewarp + $current.EnableForcedLogoff | Should -Be $configData.AllNodes[0].EnableForcedLogoff + $current.EnableLeasing | Should -Be $configData.AllNodes[0].EnableLeasing + $current.EnableMultiChannel | Should -Be $configData.AllNodes[0].EnableMultiChannel + $current.EnableOplocks | Should -Be $configData.AllNodes[0].EnableOplocks + $current.EnableSecuritySignature | Should -Be $configData.AllNodes[0].EnableSecuritySignature + $current.EnableSMB1Protocol | Should -Be $configData.AllNodes[0].EnableSMB1Protocol + $current.EnableSMB2Protocol | Should -Be $configData.AllNodes[0].EnableSMB2Protocol + $current.EnableStrictNameChecking | Should -Be $configData.AllNodes[0].EnableStrictNameChecking + $current.EncryptData | Should -Be $configData.AllNodes[0].EncryptData + $current.IrpStackSize | Should -Be $configData.AllNodes[0].IrpStackSize + $current.KeepAliveTime | Should -Be $configData.AllNodes[0].KeepAliveTime + $current.MaxChannelPerSession | Should -Be $configData.AllNodes[0].MaxChannelPerSession + $current.MaxMpxCount | Should -Be $configData.AllNodes[0].MaxMpxCount + $current.MaxSessionPerConnection | Should -Be $configData.AllNodes[0].MaxSessionPerConnection + $current.MaxThreadsPerQueue | Should -Be $configData.AllNodes[0].MaxThreadsPerQueue + $current.MaxWorkItems | Should -Be $configData.AllNodes[0].MaxWorkItems + $current.NullSessionPipes | Should -Be $configData.AllNodes[0].NullSessionPipes + $current.NullSessionShares | Should -Be $configData.AllNodes[0].NullSessionShares + $current.OplockBreakWait | Should -Be $configData.AllNodes[0].OplockBreakWait + $current.PendingClientTimeoutInSeconds | Should -Be $configData.AllNodes[0].PendingClientTimeoutInSeconds + $current.RejectUnencryptedAccess | Should -Be $configData.AllNodes[0].RejectUnencryptedAccess + $current.RequireSecuritySignature | Should -Be $configData.AllNodes[0].RequireSecuritySignature + $current.ServerHidden | Should -Be $configData.AllNodes[0].ServerHidden + $current.Smb2CreditsMax | Should -Be $configData.AllNodes[0].Smb2CreditsMax + $current.Smb2CreditsMin | Should -Be $configData.AllNodes[0].Smb2CreditsMin + $current.SmbServerNameHardeningLevel | Should -Be $configData.AllNodes[0].SmbServerNameHardeningLevel + $current.TreatHostAsStableStorage | Should -Be $configData.AllNodes[0].TreatHostAsStableStorage + $current.ValidateAliasNotCircular | Should -Be $configData.AllNodes[0].ValidateAliasNotCircular + $current.ValidateShareScope | Should -Be $configData.AllNodes[0].ValidateShareScope + $current.ValidateShareScopeNotAliased | Should -Be $configData.AllNodes[0].ValidateShareScopeNotAliased + $current.ValidateTargetName | Should -Be $configData.AllNodes[0].ValidateTargetName } - $current.AnnounceComment | Should -Be $configData.AllNodes[0].AnnounceComment - $current.AnnounceServer | Should -Be $configData.AllNodes[0].AnnounceServer - $current.AsynchronousCredits | Should -Be $configData.AllNodes[0].AsynchronousCredits - $current.AuditSmb1Access | Should -Be $configData.AllNodes[0].AuditSmb1Access - $current.AutoDisconnectTimeout | Should -Be $configData.AllNodes[0].AutoDisconnectTimeout - $current.AutoShareServer | Should -Be $configData.AllNodes[0].AutoShareServer - $current.AutoShareWorkstation | Should -Be $configData.AllNodes[0].AutoShareWorkstation - $current.CachedOpenLimit | Should -Be $configData.AllNodes[0].CachedOpenLimit - $current.DurableHandleV2TimeoutInSeconds | Should -Be $configData.AllNodes[0].DurableHandleV2TimeoutInSeconds - $current.EnableAuthenticateUserSharing | Should -Be $configData.AllNodes[0].EnableAuthenticateUserSharing - $current.EnableDownlevelTimewarp | Should -Be $configData.AllNodes[0].EnableDownlevelTimewarp - $current.EnableForcedLogoff | Should -Be $configData.AllNodes[0].EnableForcedLogoff - $current.EnableLeasing | Should -Be $configData.AllNodes[0].EnableLeasing - $current.EnableMultiChannel | Should -Be $configData.AllNodes[0].EnableMultiChannel - $current.EnableOplocks | Should -Be $configData.AllNodes[0].EnableOplocks - $current.EnableSecuritySignature | Should -Be $configData.AllNodes[0].EnableSecuritySignature - $current.EnableSMB1Protocol | Should -Be $configData.AllNodes[0].EnableSMB1Protocol - $current.EnableSMB2Protocol | Should -Be $configData.AllNodes[0].EnableSMB2Protocol - $current.EnableStrictNameChecking | Should -Be $configData.AllNodes[0].EnableStrictNameChecking - $current.EncryptData | Should -Be $configData.AllNodes[0].EncryptData - $current.IrpStackSize | Should -Be $configData.AllNodes[0].IrpStackSize - $current.KeepAliveTime | Should -Be $configData.AllNodes[0].KeepAliveTime - $current.MaxChannelPerSession | Should -Be $configData.AllNodes[0].MaxChannelPerSession - $current.MaxMpxCount | Should -Be $configData.AllNodes[0].MaxMpxCount - $current.MaxSessionPerConnection | Should -Be $configData.AllNodes[0].MaxSessionPerConnection - $current.MaxThreadsPerQueue | Should -Be $configData.AllNodes[0].MaxThreadsPerQueue - $current.MaxWorkItems | Should -Be $configData.AllNodes[0].MaxWorkItems - $current.NullSessionPipes | Should -Be $configData.AllNodes[0].NullSessionPipes - $current.NullSessionShares | Should -Be $configData.AllNodes[0].NullSessionShares - $current.OplockBreakWait | Should -Be $configData.AllNodes[0].OplockBreakWait - $current.PendingClientTimeoutInSeconds | Should -Be $configData.AllNodes[0].PendingClientTimeoutInSeconds - $current.RejectUnencryptedAccess | Should -Be $configData.AllNodes[0].RejectUnencryptedAccess - $current.RequireSecuritySignature | Should -Be $configData.AllNodes[0].RequireSecuritySignature - $current.ServerHidden | Should -Be $configData.AllNodes[0].ServerHidden - $current.Smb2CreditsMax | Should -Be $configData.AllNodes[0].Smb2CreditsMax - $current.Smb2CreditsMin | Should -Be $configData.AllNodes[0].Smb2CreditsMin - $current.SmbServerNameHardeningLevel | Should -Be $configData.AllNodes[0].SmbServerNameHardeningLevel - $current.TreatHostAsStableStorage | Should -Be $configData.AllNodes[0].TreatHostAsStableStorage - $current.ValidateAliasNotCircular | Should -Be $configData.AllNodes[0].ValidateAliasNotCircular - $current.ValidateShareScope | Should -Be $configData.AllNodes[0].ValidateShareScope - $current.ValidateShareScopeNotAliased | Should -Be $configData.AllNodes[0].ValidateShareScopeNotAliased - $current.ValidateTargetName | Should -Be $configData.AllNodes[0].ValidateTargetName } } } finally { - #region FOOTER Set-SmbServerConfiguration -AnnounceComment $script:CurrentSmbServerConfigBackup.AnnounceComment ` -AnnounceServer $script:CurrentSmbServerConfigBackup.AnnounceServer ` -AsynchronousCredits $script:CurrentSmbServerConfigBackup.AsynchronousCredits ` @@ -198,6 +199,5 @@ finally -ValidateTargetName $script:CurrentSmbServerConfigBackup.ValidateTargetName ` -Confirm:$false - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 b/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 index 9fac9880..2e5aa0d8 100644 --- a/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 @@ -1,484 +1,480 @@ -<# - .SYNOPSIS - Integration tests for DSC resource SmbShare. -#> - -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceFriendlyName = 'SmbShare' -$script:dscResourceName = "DSC_$($script:dscResourceFriendlyName)" +$script:dscResourceName = 'DSC_SmbShare' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion - -#region HEADER - -$script:dscResourceFriendlyName = 'SmbShare' -$script:dcsResourceName = "DSC_$($script:dscResourceFriendlyName)" - -#region Integration Tests -$configurationFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dcsResourceName).config.ps1" -. $configurationFile - -Describe "$($script:dcsResourceName)_Integration" { - $configurationName = "$($script:dcsResourceName)_Prerequisites_Config" + -ResourceType 'Mof' ` + -TestType 'Integration' - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw +# Begin Testing +try +{ + Describe 'SmbShare Integration Tests' { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dcsResourceName).config.ps1" + . $configFile + + $configurationName = "$($script:dcsResourceName)_Prerequisites_Config" + + Context ('When using configuration {0}' -f $configurationName) { + It 'Should compile and apply the MOF without throwing' { + { + $configurationParameters = @{ + OutputPath = $TestDrive + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } } - } - $configurationName = "$($script:dcsResourceName)_CreateShare1_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - ConfigurationData = $ConfigurationData - } + $configurationName = "$($script:dcsResourceName)_CreateShare1_Config" + + Context ('When using configuration {0}' -f $configurationName) { + It 'Should compile and apply the MOF without throwing' { + { + $configurationParameters = @{ + OutputPath = $TestDrive + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - & $configurationName @configurationParameters + It 'Should be able to call Get-DscConfiguration without throwing' { + { + $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' + It 'Should have set the resource and all the parameters should match' { + $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq $configurationName ` + -and $_.ResourceId -eq "[SmbShare]Integration_Test" } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq "[$($script:dscResourceFriendlyName)]Integration_Test" + $resourceCurrentState.Ensure | Should -Be 'Present' + $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 + $resourceCurrentState.Path | Should -Be $ConfigurationData.AllNodes.SharePath1 + $resourceCurrentState.Description | Should -BeNullOrEmpty + $resourceCurrentState.EncryptData | Should -BeFalse + $resourceCurrentState.ConcurrentUserLimit | Should -Be 0 + $resourceCurrentState.Description | Should -BeNullOrEmpty + $resourceCurrentState.CachingMode | Should -Be 'Manual' + $resourceCurrentState.ContinuouslyAvailable | Should -BeFalse + $resourceCurrentState.ShareState | Should -Be 'Online' + $resourceCurrentState.ShareType | Should -Be 'FileSystemDirectory' + $resourceCurrentState.ShadowCopy | Should -BeFalse + $resourceCurrentState.Special | Should -BeFalse + $resourceCurrentState.FullAccess | Should -BeNullOrEmpty + $resourceCurrentState.ChangeAccess | Should -BeNullOrEmpty + $resourceCurrentState.NoAccess | Should -BeNullOrEmpty + + <# + By design of the cmdlet `New-SmbShare`, the Everyone group is + always added when not providing any access permission members + in the configuration. + #> + $resourceCurrentState.ReadAccess | Should -HaveCount 1 + $resourceCurrentState.ReadAccess | Should -Contain 'Everyone' } - $resourceCurrentState.Ensure | Should -Be 'Present' - $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 - $resourceCurrentState.Path | Should -Be $ConfigurationData.AllNodes.SharePath1 - $resourceCurrentState.Description | Should -BeNullOrEmpty - $resourceCurrentState.EncryptData | Should -BeFalse - $resourceCurrentState.ConcurrentUserLimit | Should -Be 0 - $resourceCurrentState.Description | Should -BeNullOrEmpty - $resourceCurrentState.CachingMode | Should -Be 'Manual' - $resourceCurrentState.ContinuouslyAvailable | Should -BeFalse - $resourceCurrentState.ShareState | Should -Be 'Online' - $resourceCurrentState.ShareType | Should -Be 'FileSystemDirectory' - $resourceCurrentState.ShadowCopy | Should -BeFalse - $resourceCurrentState.Special | Should -BeFalse - $resourceCurrentState.FullAccess | Should -BeNullOrEmpty - $resourceCurrentState.ChangeAccess | Should -BeNullOrEmpty - $resourceCurrentState.NoAccess | Should -BeNullOrEmpty - - <# - By design of the cmdlet `New-SmbShare`, the Everyone group is - always added when not providing any access permission members - in the configuration. - #> - $resourceCurrentState.ReadAccess | Should -HaveCount 1 - $resourceCurrentState.ReadAccess | Should -Contain 'Everyone' - } - - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -BeTrue + It 'Should return $true when Test-DscConfiguration is run' { + Test-DscConfiguration -Verbose | Should -BeTrue + } } - } - - $configurationName = "$($script:dcsResourceName)_CreateShare2_Config" - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - ConfigurationData = $ConfigurationData - } + $configurationName = "$($script:dcsResourceName)_CreateShare2_Config" + + Context ('When using configuration {0}' -f $configurationName) { + It 'Should compile and apply the MOF without throwing' { + { + $configurationParameters = @{ + OutputPath = $TestDrive + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - & $configurationName @configurationParameters + It 'Should be able to call Get-DscConfiguration without throwing' { + { + $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' + It 'Should have set the resource and all the parameters should match' { + $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq $configurationName ` + -and $_.ResourceId -eq "[SmbShare]Integration_Test" } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq "[$($script:dscResourceFriendlyName)]Integration_Test" + $resourceCurrentState.Ensure | Should -Be 'Present' + $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName2 + $resourceCurrentState.Path | Should -Be $ConfigurationData.AllNodes.SharePath2 + $resourceCurrentState.Description | Should -BeNullOrEmpty + $resourceCurrentState.EncryptData | Should -BeFalse + $resourceCurrentState.ConcurrentUserLimit | Should -Be 0 + $resourceCurrentState.Description | Should -BeNullOrEmpty + $resourceCurrentState.CachingMode | Should -Be 'Manual' + $resourceCurrentState.ContinuouslyAvailable | Should -BeFalse + $resourceCurrentState.ShareState | Should -Be 'Online' + $resourceCurrentState.ShareType | Should -Be 'FileSystemDirectory' + $resourceCurrentState.ShadowCopy | Should -BeFalse + $resourceCurrentState.Special | Should -BeFalse + $resourceCurrentState.FullAccess | Should -BeNullOrEmpty + $resourceCurrentState.ReadAccess | Should -BeNullOrEmpty + $resourceCurrentState.NoAccess | Should -BeNullOrEmpty + + <# + By design of the cmdlet `New-SmbShare`, the Everyone group is + always added when using `ReadAccess = @()` in the configuration. + #> + $resourceCurrentState.ChangeAccess | Should -HaveCount 1 + $resourceCurrentState.ChangeAccess | Should -Contain $ConfigurationData.AllNodes.UserName1 } - $resourceCurrentState.Ensure | Should -Be 'Present' - $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName2 - $resourceCurrentState.Path | Should -Be $ConfigurationData.AllNodes.SharePath2 - $resourceCurrentState.Description | Should -BeNullOrEmpty - $resourceCurrentState.EncryptData | Should -BeFalse - $resourceCurrentState.ConcurrentUserLimit | Should -Be 0 - $resourceCurrentState.Description | Should -BeNullOrEmpty - $resourceCurrentState.CachingMode | Should -Be 'Manual' - $resourceCurrentState.ContinuouslyAvailable | Should -BeFalse - $resourceCurrentState.ShareState | Should -Be 'Online' - $resourceCurrentState.ShareType | Should -Be 'FileSystemDirectory' - $resourceCurrentState.ShadowCopy | Should -BeFalse - $resourceCurrentState.Special | Should -BeFalse - $resourceCurrentState.FullAccess | Should -BeNullOrEmpty - $resourceCurrentState.ReadAccess | Should -BeNullOrEmpty - $resourceCurrentState.NoAccess | Should -BeNullOrEmpty - - <# - By design of the cmdlet `New-SmbShare`, the Everyone group is - always added when using `ReadAccess = @()` in the configuration. - #> - $resourceCurrentState.ChangeAccess | Should -HaveCount 1 - $resourceCurrentState.ChangeAccess | Should -Contain $ConfigurationData.AllNodes.UserName1 - } - - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -BeTrue + It 'Should return $true when Test-DscConfiguration is run' { + Test-DscConfiguration -Verbose | Should -BeTrue + } } - } - - $configurationName = "$($script:dcsResourceName)_UpdateProperties_Config" - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - ConfigurationData = $ConfigurationData - } + $configurationName = "$($script:dcsResourceName)_UpdateProperties_Config" + + Context ('When using configuration {0}' -f $configurationName) { + It 'Should compile and apply the MOF without throwing' { + { + $configurationParameters = @{ + OutputPath = $TestDrive + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - & $configurationName @configurationParameters + It 'Should be able to call Get-DscConfiguration without throwing' { + { + $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' + It 'Should have set the resource and all the parameters should match' { + $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq $configurationName ` + -and $_.ResourceId -eq "[SmbShare]Integration_Test" } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq "[$($script:dscResourceFriendlyName)]Integration_Test" + $resourceCurrentState.Ensure | Should -Be 'Present' + $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 + $resourceCurrentState.Path | Should -Be $ConfigurationData.AllNodes.SharePath1 + $resourceCurrentState.Description | Should -Be 'A new description' + #$resourceCurrentState.EncryptData | Should -BeTrue + $resourceCurrentState.ConcurrentUserLimit | Should -Be 20 + #$resourceCurrentState.FolderEnumerationMode | Should -Be 'AccessBased' + #$resourceCurrentState.CachingMode | Should -Be 'None' + #$resourceCurrentState.ContinuouslyAvailable | Should -BeTrue + $resourceCurrentState.ShareState | Should -Be 'Online' + $resourceCurrentState.ShareType | Should -Be 'FileSystemDirectory' + $resourceCurrentState.ShadowCopy | Should -BeFalse + $resourceCurrentState.Special | Should -BeFalse + + $resourceCurrentState.FullAccess | Should -HaveCount 1 + $resourceCurrentState.FullAccess | Should -Contain $ConfigurationData.AllNodes.UserName1 + + $resourceCurrentState.ChangeAccess | Should -HaveCount 1 + $resourceCurrentState.ChangeAccess | Should -Contain $ConfigurationData.AllNodes.UserName2 + + $resourceCurrentState.ReadAccess | Should -HaveCount 1 + $resourceCurrentState.ReadAccess | Should -Contain $ConfigurationData.AllNodes.UserName3 + + $resourceCurrentState.NoAccess | Should -HaveCount 1 + $resourceCurrentState.NoAccess | Should -Contain $ConfigurationData.AllNodes.UserName4 } - $resourceCurrentState.Ensure | Should -Be 'Present' - $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 - $resourceCurrentState.Path | Should -Be $ConfigurationData.AllNodes.SharePath1 - $resourceCurrentState.Description | Should -Be 'A new description' - #$resourceCurrentState.EncryptData | Should -BeTrue - $resourceCurrentState.ConcurrentUserLimit | Should -Be 20 - #$resourceCurrentState.FolderEnumerationMode | Should -Be 'AccessBased' - #$resourceCurrentState.CachingMode | Should -Be 'None' - #$resourceCurrentState.ContinuouslyAvailable | Should -BeTrue - $resourceCurrentState.ShareState | Should -Be 'Online' - $resourceCurrentState.ShareType | Should -Be 'FileSystemDirectory' - $resourceCurrentState.ShadowCopy | Should -BeFalse - $resourceCurrentState.Special | Should -BeFalse - - $resourceCurrentState.FullAccess | Should -HaveCount 1 - $resourceCurrentState.FullAccess | Should -Contain $ConfigurationData.AllNodes.UserName1 - - $resourceCurrentState.ChangeAccess | Should -HaveCount 1 - $resourceCurrentState.ChangeAccess | Should -Contain $ConfigurationData.AllNodes.UserName2 - - $resourceCurrentState.ReadAccess | Should -HaveCount 1 - $resourceCurrentState.ReadAccess | Should -Contain $ConfigurationData.AllNodes.UserName3 - - $resourceCurrentState.NoAccess | Should -HaveCount 1 - $resourceCurrentState.NoAccess | Should -Contain $ConfigurationData.AllNodes.UserName4 - } - - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -BeTrue + It 'Should return $true when Test-DscConfiguration is run' { + Test-DscConfiguration -Verbose | Should -BeTrue + } } - } - $configurationName = "$($script:dcsResourceName)_RemovePermission_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - ConfigurationData = $ConfigurationData - } + $configurationName = "$($script:dcsResourceName)_RemovePermission_Config" + + Context ('When using configuration {0}' -f $configurationName) { + It 'Should compile and apply the MOF without throwing' { + { + $configurationParameters = @{ + OutputPath = $TestDrive + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - & $configurationName @configurationParameters + It 'Should be able to call Get-DscConfiguration without throwing' { + { + $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' + It 'Should have set the resource and all the parameters should match' { + $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq $configurationName ` + -and $_.ResourceId -eq "[SmbShare]Integration_Test" } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } + $resourceCurrentState.Ensure | Should -Be 'Present' + $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 + $resourceCurrentState.FullAccess | Should -BeNullOrEmpty + $resourceCurrentState.ChangeAccess | Should -BeNullOrEmpty + $resourceCurrentState.NoAccess | Should -BeNullOrEmpty - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq "[$($script:dscResourceFriendlyName)]Integration_Test" + $resourceCurrentState.ReadAccess | Should -HaveCount 1 + $resourceCurrentState.ReadAccess | Should -Contain 'Everyone' } - $resourceCurrentState.Ensure | Should -Be 'Present' - $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 - $resourceCurrentState.FullAccess | Should -BeNullOrEmpty - $resourceCurrentState.ChangeAccess | Should -BeNullOrEmpty - $resourceCurrentState.NoAccess | Should -BeNullOrEmpty - - $resourceCurrentState.ReadAccess | Should -HaveCount 1 - $resourceCurrentState.ReadAccess | Should -Contain 'Everyone' - } - - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -BeTrue + It 'Should return $true when Test-DscConfiguration is run' { + Test-DscConfiguration -Verbose | Should -BeTrue + } } - } - - $configurationName = "$($script:dcsResourceName)_RecreateShare1_Config" - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - ConfigurationData = $ConfigurationData - } + $configurationName = "$($script:dcsResourceName)_RecreateShare1_Config" + + Context ('When using configuration {0}' -f $configurationName) { + It 'Should compile and apply the MOF without throwing' { + { + $configurationParameters = @{ + OutputPath = $TestDrive + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - & $configurationName @configurationParameters + It 'Should be able to call Get-DscConfiguration without throwing' { + { + $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' + It 'Should have set the resource and all the parameters should match' { + $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq $configurationName ` + -and $_.ResourceId -eq "[SmbShare]Integration_Test" } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq "[$($script:dscResourceFriendlyName)]Integration_Test" + $resourceCurrentState.Ensure | Should -Be 'Present' + $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 + $resourceCurrentState.Path | Should -Be $ConfigurationData.AllNodes.SharePath2 } - $resourceCurrentState.Ensure | Should -Be 'Present' - $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 - $resourceCurrentState.Path | Should -Be $ConfigurationData.AllNodes.SharePath2 + It 'Should return $true when Test-DscConfiguration is run' { + Test-DscConfiguration -Verbose | Should -BeTrue + } } - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -BeTrue - } - } + $configurationName = "$($script:dcsResourceName)_RemoveShare1_Config" - $configurationName = "$($script:dcsResourceName)_RemoveShare1_Config" + Context ('When using configuration {0}' -f $configurationName) { + It 'Should compile and apply the MOF without throwing' { + { + $configurationParameters = @{ + OutputPath = $TestDrive + ConfigurationData = $ConfigurationData + } - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } - - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } + & $configurationName @configurationParameters - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq "[$($script:dscResourceFriendlyName)]Integration_Test" + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw } - $resourceCurrentState.Ensure | Should -Be 'Absent' - $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 - } - - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -BeTrue - } - } - - $configurationName = "$($script:dcsResourceName)_RemoveShare2_Config" - - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - ConfigurationData = $ConfigurationData - } - - & $configurationName @configurationParameters + It 'Should be able to call Get-DscConfiguration without throwing' { + { + $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' + It 'Should have set the resource and all the parameters should match' { + $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq $configurationName ` + -and $_.ResourceId -eq "[SmbShare]Integration_Test" } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { - $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } - - It 'Should have set the resource and all the parameters should match' { - $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq $configurationName ` - -and $_.ResourceId -eq "[$($script:dscResourceFriendlyName)]Integration_Test" + $resourceCurrentState.Ensure | Should -Be 'Absent' + $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName1 } - $resourceCurrentState.Ensure | Should -Be 'Absent' - $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName2 + It 'Should return $true when Test-DscConfiguration is run' { + Test-DscConfiguration -Verbose | Should -BeTrue + } } - It 'Should return $true when Test-DscConfiguration is run' { - Test-DscConfiguration -Verbose | Should -BeTrue - } - } + $configurationName = "$($script:dcsResourceName)_RemoveShare2_Config" + + Context ('When using configuration {0}' -f $configurationName) { + It 'Should compile and apply the MOF without throwing' { + { + $configurationParameters = @{ + OutputPath = $TestDrive + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - $configurationName = "$($script:dcsResourceName)_Cleanup_Config" + It 'Should be able to call Get-DscConfiguration without throwing' { + { + $script:currentConfiguration = Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - Context ('When using configuration {0}' -f $configurationName) { - It 'Should compile and apply the MOF without throwing' { - { - $configurationParameters = @{ - OutputPath = $TestDrive - ConfigurationData = $ConfigurationData + It 'Should have set the resource and all the parameters should match' { + $resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq $configurationName ` + -and $_.ResourceId -eq "[SmbShare]Integration_Test" } - & $configurationName @configurationParameters + $resourceCurrentState.Ensure | Should -Be 'Absent' + $resourceCurrentState.Name | Should -Be $ConfigurationData.AllNodes.ShareName2 + } - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } + It 'Should return $true when Test-DscConfiguration is run' { + Test-DscConfiguration -Verbose | Should -BeTrue + } + } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw + $configurationName = "$($script:dcsResourceName)_Cleanup_Config" + + Context ('When using configuration {0}' -f $configurationName) { + It 'Should compile and apply the MOF without throwing' { + { + $configurationParameters = @{ + OutputPath = $TestDrive + ConfigurationData = $ConfigurationData + } + + & $configurationName @configurationParameters + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } } } } -#endregion +finally +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} diff --git a/tests/Integration/DSC_WindowsEventLog.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsEventLog.Integration.Tests.ps1 index aefe2f80..2efe7e87 100644 --- a/tests/Integration/DSC_WindowsEventLog.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsEventLog.Integration.Tests.ps1 @@ -1,292 +1,295 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_WindowsEventLog' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -# Using try/finally to always cleanup. +# Begin Testing try { - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" - . $configFile - Describe "$($script:dscResourceName)_Integration" { - - Context 'Set Windows Event Log to Logmode Retain' { - $CurrentConfig = 'DSC_WindowsEventLog_RetainSize' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Set Windows Event Log to Logmode AutoBackup with LogRetentionDays of 30 days' { - $CurrentConfig = 'DSC_WindowsEventLog_AutobackupLogRetention' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Set Windows Event Log to Logmode Circular, MaximumSizeInBytes 20971520, LogFilePath C:\temp\Application.evtx' { - $CurrentConfig = 'DSC_WindowsEventLog_CircularLogPath' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Set Windows Event Log to Default' { - $CurrentConfig = 'DSC_WindowsEventLog_Default' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Enable a Logfile other than Application Eventlog' { - $CurrentConfig = 'DSC_WindowsEventLog_EnableLog' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Disable a Logfile other than Application Windows Event Log' { - $CurrentConfig = 'DSC_WindowsEventLog_DisableLog' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Set Eventlog to Logmode Circular with a SecurityDescriptor' { - $CurrentConfig = 'DSC_WindowsEventLog_CircularSecurityDescriptor' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Enable a Logfile other than Application Windows Event Log with Retention' { - $CurrentConfig = 'DSC_WindowsEventLog_EnableBackupLog' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should not apply the MOF' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a incompliant state' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeFalse - } - } - - Context 'Disable a Logfile other than Application Eventlog with retention' { - $CurrentConfig = 'DSC_WindowsEventLog_DisableBackupLog' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Set Windows Event Log back to the default configuration' { - $CurrentConfig = 'DSC_WindowsEventLog_Default' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + Describe 'WindowsEventLog Integration Tests' { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + + Context 'Set Windows Event Log to Logmode Retain' { + $CurrentConfig = 'DSC_WindowsEventLog_RetainSize' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } + } + + Context 'Set Windows Event Log to Logmode AutoBackup with LogRetentionDays of 30 days' { + $CurrentConfig = 'DSC_WindowsEventLog_AutobackupLogRetention' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } + } + + Context 'Set Windows Event Log to Logmode Circular, MaximumSizeInBytes 20971520, LogFilePath C:\temp\Application.evtx' { + $CurrentConfig = 'DSC_WindowsEventLog_CircularLogPath' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } + } + + Context 'Set Windows Event Log to Default' { + $CurrentConfig = 'DSC_WindowsEventLog_Default' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } + } + + Context 'Enable a Logfile other than Application Eventlog' { + $CurrentConfig = 'DSC_WindowsEventLog_EnableLog' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } + } + + Context 'Disable a Logfile other than Application Windows Event Log' { + $CurrentConfig = 'DSC_WindowsEventLog_DisableLog' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } + } + + Context 'Set Eventlog to Logmode Circular with a SecurityDescriptor' { + $CurrentConfig = 'DSC_WindowsEventLog_CircularSecurityDescriptor' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } + } + + Context 'Enable a Logfile other than Application Windows Event Log with Retention' { + $CurrentConfig = 'DSC_WindowsEventLog_EnableBackupLog' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should not apply the MOF' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a incompliant state' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeFalse + } + } + + Context 'Disable a Logfile other than Application Eventlog with retention' { + $CurrentConfig = 'DSC_WindowsEventLog_DisableBackupLog' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } + } + + Context 'Set Windows Event Log back to the default configuration' { + $CurrentConfig = 'DSC_WindowsEventLog_Default' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } } } } } finally { - Restore-TestEnvironment -TestEnvironment $TestEnvironment + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } From 8106430a58fdb0cdc257193eafafa06c2a4f8c6a Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 21:53:35 +1300 Subject: [PATCH 09/30] Fix unit tests --- .../ComputerManagementDsc.Common.Tests.ps1 | 50 ++-- .../DSC_SystemLocale.Integration.Tests.ps1 | 113 ++++---- .../DSC_TimeZone.Integration.Tests.ps1 | 104 ++++---- .../DSC_VirtualMemory.Integration.Tests.ps1 | 200 +++++++------- ...SC_WindowsCapability.Integration.Tests.ps1 | 251 +++++++++--------- tests/Unit/DSC_PowerPlan.Tests.ps1 | 43 ++- 6 files changed, 372 insertions(+), 389 deletions(-) diff --git a/tests/Integration/ComputerManagementDsc.Common.Tests.ps1 b/tests/Integration/ComputerManagementDsc.Common.Tests.ps1 index a99b5a2b..33dfe358 100644 --- a/tests/Integration/ComputerManagementDsc.Common.Tests.ps1 +++ b/tests/Integration/ComputerManagementDsc.Common.Tests.ps1 @@ -1,18 +1,23 @@ #region HEADER -$script:ModuleName = 'ComputerManagementDsc.Common' +$script:projectPath = "$PSScriptRoot\..\.." | Convert-Path +$script:projectName = (Get-ChildItem -Path "$script:projectPath\*\*.psd1" | Where-Object -FilterScript { + ($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and + $(try + { Test-ModuleManifest -Path $_.FullName -ErrorAction Stop + } + catch + { $false + }) + }).BaseName -Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global +$script:parentModule = Get-Module -Name $script:projectName -ListAvailable | Select-Object -First 1 +$script:subModulesFolder = Join-Path -Path $script:parentModule.ModuleBase -ChildPath 'Modules' +Remove-Module -Name $script:parentModule -Force -ErrorAction 'SilentlyContinue' -# Unit Test Template Version: 1.2.4 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) -{ - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) -} +$script:subModuleName = (Split-Path -Path $PSCommandPath -Leaf) -replace '\.Tests.ps1' +$script:subModuleFile = Join-Path -Path $script:subModulesFolder -ChildPath "$($script:subModuleName)/$($script:subModuleName).psm1" -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -Import-Module (Join-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'Modules' -ChildPath $script:ModuleName)) -ChildPath "$script:ModuleName.psm1") -Force +Import-Module $script:subModuleFile -Force -ErrorAction Stop #endregion HEADER # Store the test machine timezone @@ -24,8 +29,7 @@ tzutil.exe /s 'Eastern Standard Time' # Using try/finally to always cleanup even if something awful happens. try { - InModuleScope $script:ModuleName { - + InModuleScope $script:subModuleName { Describe 'ComputerManagementDsc.Common\Set-TimeZoneId' { <# The purpose of this test is to ensure the C# .NET code @@ -42,16 +46,16 @@ try Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Add-Type' - } -MockWith { - 'Add-Type' - } + $Name -eq 'Add-Type' + } -MockWith { + 'Add-Type' + } Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Set-TimeZone' - } + $Name -eq 'Set-TimeZone' + } Mock -CommandName 'TzUtil.exe' -MockWith { $Script:LASTEXITCODE = 0 @@ -70,14 +74,14 @@ try Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Add-Type' - } -Exactly -Times 1 + $Name -eq 'Add-Type' + } -Exactly -Times 1 Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Set-TimeZone' - } -Exactly -Times 1 + $Name -eq 'Set-TimeZone' + } -Exactly -Times 1 Assert-MockCalled -CommandName TzUtil.exe -Exactly -Times 0 } diff --git a/tests/Integration/DSC_SystemLocale.Integration.Tests.ps1 b/tests/Integration/DSC_SystemLocale.Integration.Tests.ps1 index b0d2ea98..ef7ae931 100644 --- a/tests/Integration/DSC_SystemLocale.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SystemLocale.Integration.Tests.ps1 @@ -1,21 +1,22 @@ -$script:DSCModuleName = 'ComputerManagementDsc' -$script:DSCResourceName = 'DSC_SystemLocale' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'DSC_SystemLocale' -#region HEADER -# Integration Test Template Version: 1.1.1 -[String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $Script:DSCModuleName ` - -DSCResourceName $Script:DSCResourceName ` - -TestType Integration -#endregion +$script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') # Store the test machine system locale $currentSystemLocale = (Get-WinSystemLocale).Name @@ -23,53 +24,55 @@ $currentSystemLocale = (Get-WinSystemLocale).Name # Change the current system locale so that a complete test occurs. Set-WinSystemLocale -SystemLocale 'kl-GL' -# Using try/finally to always cleanup even if something awful happens. +# Begin Testing try { - $ConfigFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" - . $ConfigFile -Verbose -ErrorAction Stop + Describe 'SystemLocale Integration Tests' { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:DSCResourceName).config.ps1" + . $configFile -Verbose -ErrorAction Stop - Describe "$($script:DSCResourceName)_Integration" { - Context 'When settting System Locale to fr-FR' { - $configData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - SystemLocale = 'fr-FR' - IsSingleInstance = 'Yes' - } - ) - } + Describe "$($script:DSCResourceName)_Integration" { + Context 'When settting System Locale to fr-FR' { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + SystemLocale = 'fr-FR' + IsSingleInstance = 'Yes' + } + ) + } - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:DSCResourceName)_Config" ` - -OutputPath $TestDrive ` - -ConfigurationData $configData + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:DSCResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData - Start-DscConfiguration ` - -Path $TestDrive ` - -ComputerName localhost ` - -Wait ` - -Verbose ` - -Force ` - -ErrorAction Stop - } | Should -Not -Throw - } + Start-DscConfiguration ` + -Path $TestDrive ` + -ComputerName localhost ` + -Wait ` + -Verbose ` + -Force ` + -ErrorAction Stop + } | Should -Not -Throw + } - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object { - $_.ConfigurationName -eq "$($script:DSCResourceName)_Config" + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object { + $_.ConfigurationName -eq "$($script:DSCResourceName)_Config" + } + <# + A reboot would need to occur before this node can be bought into alignment. + Therefore a test for the new SystemLocale can not be automated. + #> + $current.IsSingleInstance | Should -Be $configData.AllNodes[0].IsSingleInstance } - <# - A reboot would need to occur before this node can be bought into alignment. - Therefore a test for the new SystemLocale can not be automated. - #> - $current.IsSingleInstance | Should -Be $configData.AllNodes[0].IsSingleInstance } } } @@ -79,7 +82,5 @@ finally # Restore the test machine system locale Set-WinSystemLocale -SystemLocale $currentSystemLocale - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 b/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 index 863b0f3f..f58cec2f 100644 --- a/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 +++ b/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 @@ -1,21 +1,22 @@ -#region HEADER -$script:dscModuleName = 'ComputerManagementDsc' -$script:dscResourceName = 'DSC_TimeZone' +$script:dscModuleName = 'ComputerManagementDsc' +$script:dscResourceName = 'DSC_TimeZone' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') # Store the test machine timezone $currentTimeZone = & tzutil.exe /g @@ -23,60 +24,59 @@ $currentTimeZone = & tzutil.exe /g # Change the current timezone so that a complete test occurs. tzutil.exe /s 'Eastern Standard Time' -# Using try/finally to always cleanup even if something awful happens. +# Begin Testing try { - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" - . $configFile -Verbose -ErrorAction Stop + Describe 'TimeZone Integration Tests' { + #region Integration Tests + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" + . $configFile -Verbose -ErrorAction Stop - Describe "$($script:dscResourceName)_Integration" { - $configData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - TimeZone = 'Pacific Standard Time' - IsSingleInstance = 'Yes' - } - ) - } + Describe "$($script:dscResourceName)_Integration" { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + TimeZone = 'Pacific Standard Time' + IsSingleInstance = 'Yes' + } + ) + } - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:dscResourceName)_Config" ` - -OutputPath $TestDrive ` - -ConfigurationData $configData + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData - Start-DscConfiguration ` - -Path $TestDrive ` - -ComputerName localhost ` - -Wait ` - -Verbose ` - -Force ` - -ErrorAction Stop - } | Should -Not -Throw - } + Start-DscConfiguration ` + -Path $TestDrive ` + -ComputerName localhost ` + -Wait ` + -Verbose ` + -Force ` + -ErrorAction Stop + } | Should -Not -Throw + } - It 'Should be able to call Get-DscConfiguration without throwing' { - { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw - } + It 'Should be able to call Get-DscConfiguration without throwing' { + { Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw + } - It 'Should have set the configuration and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + It 'Should have set the configuration and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.TimeZone | Should -Be $configData.AllNodes[0].TimeZone + $current.IsSingleInstance | Should -Be $configData.AllNodes[0].IsSingleInstance } - $current.TimeZone | Should -Be $configData.AllNodes[0].TimeZone - $current.IsSingleInstance | Should -Be $configData.AllNodes[0].IsSingleInstance } } - #endregion } finally { # Restore the test machine timezone & tzutil.exe /s $CurrentTimeZone - #region FOOTER - Restore-TestEnvironment -TestEnvironment $TestEnvironment - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/tests/Integration/DSC_VirtualMemory.Integration.Tests.ps1 b/tests/Integration/DSC_VirtualMemory.Integration.Tests.ps1 index 7682314e..1dd75844 100644 --- a/tests/Integration/DSC_VirtualMemory.Integration.Tests.ps1 +++ b/tests/Integration/DSC_VirtualMemory.Integration.Tests.ps1 @@ -1,125 +1,123 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_VirtualMemory' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion + -ResourceType 'Mof' ` + -TestType 'Integration' + +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -# Using try/finally to always cleanup. +# Begin Testing try { - #region Integration Tests - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" - . $configFile - - Describe "$($script:dscResourceName)_Integration" { - - Context 'Set page file to automatically managed' { - $CurrentConfig = 'setToAuto' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + Describe 'VirtualMemory Integration Tests' { + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + + Context 'Set page file to automatically managed' { + $CurrentConfig = 'setToAuto' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } } - } - Context 'Set page file to custom size' { - $CurrentConfig = 'setToCustom' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw + Context 'Set page file to custom size' { + $CurrentConfig = 'setToCustom' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } } - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw + Context 'Set page file to system managed' { + $CurrentConfig = 'setToSystemManaged' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } } - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Set page file to system managed' { - $CurrentConfig = 'setToSystemManaged' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue - } - } - - Context 'Set page file to none' { - $CurrentConfig = 'setToNone' - $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) - $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') - - It 'Should compile a MOF file without error' { - { - . $CurrentConfig -OutputPath $ConfigDir - } | Should -Not -Throw - } - - It 'Should apply the MOF correctly' { - { - Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should -Not -Throw - } - - It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + Context 'Set page file to none' { + $CurrentConfig = 'setToNone' + $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) + $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath 'localhost.mof') + + It 'Should compile a MOF file without error' { + { + . $CurrentConfig -OutputPath $ConfigDir + } | Should -Not -Throw + } + + It 'Should apply the MOF correctly' { + { + Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force + } | Should -Not -Throw + } + + It 'Should return a compliant state after being applied' { + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -BeTrue + } } } } } finally { - #region FOOTER - - Restore-TestEnvironment -TestEnvironment $TestEnvironment - - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 index c91c9019..7cf3949e 100644 --- a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 @@ -1,165 +1,158 @@ -#region HEADER $script:dscModuleName = 'ComputerManagementDsc' $script:dscResourceName = 'DSC_WindowsCapability' -# Integration Test Template Version: 1.3.3 -$script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) -if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) +try +{ + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' +} +catch [System.IO.FileNotFoundException] { - & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath 'DscResource.Tests')) + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' } -Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath (Join-Path -Path 'DSCResource.Tests' -ChildPath 'TestHelper.psm1')) -Force -$TestEnvironment = Initialize-TestEnvironment ` +$script:testEnvironment = Initialize-TestEnvironment ` -DSCModuleName $script:dscModuleName ` -DSCResourceName $script:dscResourceName ` - -TestType Integration -#endregion - -function Invoke-TestSetup -{ - if (-not (Get-Module dism -ListAvailable)) - { - Import-Module (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs\dism.psm1') -Force - } -} + -ResourceType 'Mof' ` + -TestType 'Integration' -function Invoke-TestCleanup -{ - Restore-TestEnvironment -TestEnvironment $TestEnvironment -} +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +# Begin Testing try { - Invoke-TestSetup - - # Ensure that the tests can be performed on this computer - $productType = (Get-CimInstance Win32_OperatingSystem).ProductType - Describe 'Environment' { - Context 'Operating System' { - It 'Should be a Desktop OS' { - if ($productType -ne 1) - { - Set-ItResult -Inconclusive -Because 'Operating System is not a Desktop OS' + Describe 'WindowsCapability Integration Tests' { + # Ensure that the tests can be performed on this computer + $productType = (Get-CimInstance Win32_OperatingSystem).ProductType + + Describe 'Environment' { + Context 'Operating System' { + It 'Should be a Desktop OS' { + if ($productType -ne 1) + { + Set-ItResult -Inconclusive -Because 'Operating System is not a Desktop OS' + } } } } - } - - if ($productType -ne 1) - { - break - } - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" - . $configFile - - Describe "$($script:dscResourceName)_Integration" { - Context 'When adding a Windows Capability' { - $configData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - Name = 'XPS.Viewer~~~~0.0.1.0' - LogLevel = 'Errors' - LogPath = Join-Path -Path $ENV:Temp -ChildPath 'Logfile.log' - Ensure = 'Present' - } - ) - } + if ($productType -ne 1) + { + break + } - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:dscResourceName)_Config" ` - -OutputPath $TestDrive ` - -ConfigurationData $configData - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } + if (-not (Get-Module dism -ListAvailable)) + { + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs\dism.psm1') -Force + } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" + . $configFile + + Describe "$($script:dscResourceName)_Integration" { + Context 'When adding a Windows Capability' { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Name = 'XPS.Viewer~~~~0.0.1.0' + LogLevel = 'Errors' + LogPath = Join-Path -Path $ENV:Temp -ChildPath 'Logfile.log' + Ensure = 'Present' + } + ) + } - It 'Should be able to call Get-DscConfiguration without throwing' { - { - Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + It 'Should be able to call Get-DscConfiguration without throwing' { + { + Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw } - $current.Name | Should -Be $configData.AllNodes[0].Name - $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel - $current.LogPath | Should -Be $configData.AllNodes[0].LogPath - $current.Ensure | Should -Be $configData.AllNodes[0].Ensure - $current.IsSingleInstance | Should -Be 'Yes' - } - } - Context 'When removing a Windows Capability' { - $configData = @{ - AllNodes = @( - @{ - NodeName = 'localhost' - Name = 'XPS.Viewer~~~~0.0.1.0' - LogLevel = 'Errors' - LogPath = Join-Path -Path $ENV:Temp -ChildPath 'Logfile.log' - Ensure = 'Absent' + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" } - ) + $current.Name | Should -Be $configData.AllNodes[0].Name + $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel + $current.LogPath | Should -Be $configData.AllNodes[0].LogPath + $current.Ensure | Should -Be $configData.AllNodes[0].Ensure + $current.IsSingleInstance | Should -Be 'Yes' + } } - It 'Should compile and apply the MOF without throwing' { - { - & "$($script:dscResourceName)_Config" ` - -OutputPath $TestDrive ` - -ConfigurationData $configData - - $startDscConfigurationParameters = @{ - Path = $TestDrive - ComputerName = 'localhost' - Wait = $true - Verbose = $true - Force = $true - ErrorAction = 'Stop' - } + Context 'When removing a Windows Capability' { + $configData = @{ + AllNodes = @( + @{ + NodeName = 'localhost' + Name = 'XPS.Viewer~~~~0.0.1.0' + LogLevel = 'Errors' + LogPath = Join-Path -Path $ENV:Temp -ChildPath 'Logfile.log' + Ensure = 'Absent' + } + ) + } - Start-DscConfiguration @startDscConfigurationParameters - } | Should -Not -Throw - } + It 'Should compile and apply the MOF without throwing' { + { + & "$($script:dscResourceName)_Config" ` + -OutputPath $TestDrive ` + -ConfigurationData $configData + + $startDscConfigurationParameters = @{ + Path = $TestDrive + ComputerName = 'localhost' + Wait = $true + Verbose = $true + Force = $true + ErrorAction = 'Stop' + } + + Start-DscConfiguration @startDscConfigurationParameters + } | Should -Not -Throw + } - It 'Should be able to call Get-DscConfiguration without throwing' { - { - Get-DscConfiguration -Verbose -ErrorAction Stop - } | Should -Not -Throw - } + It 'Should be able to call Get-DscConfiguration without throwing' { + { + Get-DscConfiguration -Verbose -ErrorAction Stop + } | Should -Not -Throw + } - It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { - $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + It 'Should have set the resource and all the parameters should match' { + $current = Get-DscConfiguration | Where-Object -FilterScript { + $_.ConfigurationName -eq "$($script:dscResourceName)_Config" + } + $current.Name | Should -Be $configData.AllNodes[0].Name + $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel + $current.LogPath | Should -Be $configData.AllNodes[0].LogPath + $current.Ensure | Should -Be $configData.AllNodes[0].Ensure + $current.IsSingleInstance | Should -Be 'Yes' } - $current.Name | Should -Be $configData.AllNodes[0].Name - $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel - $current.LogPath | Should -Be $configData.AllNodes[0].LogPath - $current.Ensure | Should -Be $configData.AllNodes[0].Ensure - $current.IsSingleInstance | Should -Be 'Yes' } } } } finally { - #region FOOTER - Invoke-TestCleanup - #endregion + Restore-TestEnvironment -TestEnvironment $script:testEnvironment } diff --git a/tests/Unit/DSC_PowerPlan.Tests.ps1 b/tests/Unit/DSC_PowerPlan.Tests.ps1 index 60380ac1..d1a5586c 100644 --- a/tests/Unit/DSC_PowerPlan.Tests.ps1 +++ b/tests/Unit/DSC_PowerPlan.Tests.ps1 @@ -52,20 +52,18 @@ try Mock ` -CommandName Get-PowerPlan ` -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` - -ModuleName $script:dscResourceName ` + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` -Verifiable Mock ` -CommandName Get-ActivePowerPlan ` -MockWith { - return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } ` - -ModuleName $script:dscResourceName ` + return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } ` -Verifiable } @@ -88,20 +86,18 @@ try Mock ` -CommandName Get-PowerPlan ` -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` - -ModuleName $script:dscResourceName ` + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` -Verifiable Mock ` -CommandName Get-ActivePowerPlan ` -MockWith { - return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' - } ` - -ModuleName $script:dscResourceName ` + return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' + } ` -Verifiable } @@ -124,7 +120,6 @@ try BeforeEach { Mock ` -CommandName Get-PowerPlan ` - -ModuleName $script:dscResourceName ` -Verifiable } @@ -156,12 +151,10 @@ try Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } } ` - -ModuleName $script:dscResourceName ` -Verifiable Mock ` -CommandName Set-ActivePowerPlan ` - -ModuleName $script:dscResourceName ` -Verifiable } @@ -175,7 +168,7 @@ try Set-TargetResource -Name $Name -IsSingleInstance 'Yes' -Verbose - Assert-MockCalled -CommandName Get-PowerPlan -Exactly -Times 1 -Scope It -ModuleName $script:dscResourceName + Assert-MockCalled -CommandName Get-PowerPlan -Exactly -Times 1 -Scope It } It 'Should call Set-ActivePowerPlan once (power plan specified as )' -TestCases $testCases { @@ -192,7 +185,6 @@ try -Exactly ` -Times 1 ` -Scope It ` - -ModuleName $script:dscResourceName ` -ParameterFilter {$PowerPlanGuid -eq '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'} } } @@ -201,7 +193,6 @@ try BeforeEach { Mock ` -CommandName Get-PowerPlan ` - -ModuleName $script:dscResourceName ` -Verifiable } @@ -233,7 +224,6 @@ try Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } } ` - -ModuleName $script:dscResourceName ` -Verifiable Mock ` @@ -241,7 +231,6 @@ try -MockWith { return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } ` - -ModuleName $script:dscResourceName ` -Verifiable } @@ -267,7 +256,6 @@ try Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } } ` - -ModuleName $script:dscResourceName ` -Verifiable Mock ` @@ -275,7 +263,6 @@ try -MockWith { return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' } ` - -ModuleName $script:dscResourceName ` -Verifiable } From 2d379938337a03fba2bdd36b9dfe702e983acd1a Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Mon, 20 Jan 2020 22:17:05 +1300 Subject: [PATCH 10/30] Fix more unit tests --- .../DSC_PowerShellExecutionpolicy.Tests.ps1 | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 b/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 index c56d5753..75a1421b 100644 --- a/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 +++ b/tests/Unit/DSC_PowerShellExecutionpolicy.Tests.ps1 @@ -32,19 +32,9 @@ Invoke-TestSetup try { InModuleScope $script:dscResourceName { - $Script:invalidPolicyThrowMessage = @" -Cannot validate argument on parameter 'ExecutionPolicy'. The argument `"badParam`" does -not belong to the set `"Bypass,Restricted,AllSigned,RemoteSigned,Unrestricted`" -specified by the ValidateSet attribute. Supply an argument that is in the set and then -try the command again. -"@ - - $Script:invalidPolicyExecutionPolicyScopeThrowMessage = @" -Cannot validate argument on parameter 'ExecutionPolicyScope'. The argument `"badParam`" -does not belong to the set `"CurrentUser,LocalMachine,MachinePolicy,Process,UserPolicy`" -specified by the ValidateSet attribute. Supply an argument that is in the set and then -try the command again. -"@ + $Script:invalidPolicyThrowMessage = "Cannot validate argument on parameter 'ExecutionPolicy'. The argument `"badParam`" does not belong to the set `"Bypass,Restricted,AllSigned,RemoteSigned,Unrestricted`" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again." + + $Script:invalidPolicyExecutionPolicyScopeThrowMessage = "Cannot validate argument on parameter 'ExecutionPolicyScope'. The argument `"badParam`" does not belong to the set `"CurrentUser,LocalMachine,MachinePolicy,Process,UserPolicy`" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again." Describe 'DSC_PowershellExecutionPolicy\Get-TargetResource' { It 'Throws when passed an invalid execution policy' { @@ -53,7 +43,7 @@ try the command again. It 'Returns correct execution policy' { Mock Get-ExecutionPolicy { 'Unrestricted' } - $result = Get-TargetResource -ExecutionPolicy $(Get-ExecutionPolicy ) -ExecutionPolicyScope 'LocalMachine' + $result = Get-TargetResource -ExecutionPolicy $(Get-ExecutionPolicy) -ExecutionPolicyScope 'LocalMachine' $result.ExecutionPolicy | Should -Be $(Get-ExecutionPolicy) } From 67a8b652b3112b21a967bc2d7a9d24f47613ddba Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Tue, 21 Jan 2020 17:43:46 +1300 Subject: [PATCH 11/30] Fix WindowsCapability --- CHANGELOG.md | 6 +++-- .../DSC_WindowsCapability.psm1 | 19 ++++++++------- ...SC_WindowsCapability.Integration.Tests.ps1 | 24 ------------------- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b6fef35..54f1c2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - SmbShare: - Add parameter ScopeName to support creating shares in a different - scope. Fixes [Issue #284](https://github.com/dsccommunity/ComputerManagementDsc/issues/284) + scope - Fixes [Issue #284](https://github.com/dsccommunity/ComputerManagementDsc/issues/284). - Added `.gitattributes` to ensure CRLF is used when pulling repository - Fixes [Issue #290](https://github.com/dsccommunity/ComputerManagementDsc/issues/290). - SystemLocale: @@ -31,7 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- None +- WindowsCapability: + - Fix `A parameter cannot be found that matches parameter name 'Ensure'.` + error in `Test-TargetResource` - Fixes [Issue #297](https://github.com/dsccommunity/ComputerManagementDsc/issues/297). ### Security diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index 2ebc69c2..39defaaa 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -167,7 +167,7 @@ function Test-TargetResource [Parameter()] [ValidateSet('Present', 'Absent')] [System.String] - $Ensure, + $Ensure = 'Present', [Parameter()] [ValidateSet('Errors', 'Warnings', 'WarningsInfo')] @@ -179,13 +179,13 @@ function Test-TargetResource $LogPath ) - Write-Verbose -Message ($script:localizedData.TestTargetResourceStartMessage -f $Name) - - $desiredState = $true + $inDesiredState = $true + Write-Verbose -Message ($script:localizedData.TestTargetResourceStartMessage -f $Name) + $null = $PSBoundParameters.Remove('Ensure') $windowsCapability = Get-WindowsCapability -Online @PSBoundParameters - if ($null -eq $windowsCapability.Name) + if ([System.String]::IsNullOrEmpty($windowsCapability.Name)) { New-InvalidArgumentException -Message ($script:localizedData.CapabilityNameNotFound -f $Name) } @@ -196,7 +196,7 @@ function Test-TargetResource if ($LogPath) { - if (-not (Test-Path $LogPath)) + if (-not (Test-Path -Path $LogPath)) { New-InvalidArgumentException -Message ($script:localizedData.LogPathFailedMessage -f $LogPath) } @@ -218,14 +218,15 @@ function Test-TargetResource if ($PSBoundParameters.ContainsKey('Ensure') -and $Ensure -ne $ensureResult) { Write-Verbose -Message ($script:localizedData.SetResourceIsNotInDesiredState -f $Name) - $desiredState = $false + $inDesiredState = $false } else { Write-Verbose -Message ($script:localizedData.SetResourceIsInDesiredState -f $Name) - $desiredState = $true + $inDesiredState = $true } - return $desiredState + + return $inDesiredState } Export-ModuleMember -Function *-TargetResource diff --git a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 index 7cf3949e..e9a1b45e 100644 --- a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 @@ -22,30 +22,6 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\Co try { Describe 'WindowsCapability Integration Tests' { - # Ensure that the tests can be performed on this computer - $productType = (Get-CimInstance Win32_OperatingSystem).ProductType - - Describe 'Environment' { - Context 'Operating System' { - It 'Should be a Desktop OS' { - if ($productType -ne 1) - { - Set-ItResult -Inconclusive -Because 'Operating System is not a Desktop OS' - } - } - } - } - - if ($productType -ne 1) - { - break - } - - if (-not (Get-Module dism -ListAvailable)) - { - Import-Module (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs\dism.psm1') -Force - } - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" . $configFile From 2003ecc7035e672518efae87b493f286a2e84296 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Tue, 21 Jan 2020 19:39:43 +1300 Subject: [PATCH 12/30] Fix Integration tests for WindowsCapability --- .../DSC_WindowsCapability/DSC_WindowsCapability.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index 39defaaa..26089b38 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -35,7 +35,7 @@ function Get-TargetResource ) Write-Verbose -Message ($script:localizedData.GetTargetResourceStartMessage -f $Name) - + $null = $PSBoundParameters.Remove('Ensure') $windowsCapability = Get-WindowsCapability -Online @PSBoundParameters if ($windowsCapability.State -eq 'Installed') From 93883f698a88696c442395d198db12e6abebac44 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Tue, 21 Jan 2020 19:57:25 +1300 Subject: [PATCH 13/30] Fix integration test and output WindowsCapability --- .../DSC_SmbServerConfiguration.Tests.ps1 | 2 ++ .../DSC_SmbShare.Integration.Tests.ps1 | 20 +++++++++---------- ...SC_WindowsCapability.Integration.Tests.ps1 | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 b/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 index efdc162f..11106bb8 100644 --- a/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 +++ b/tests/Integration/DSC_SmbServerConfiguration.Tests.ps1 @@ -18,6 +18,8 @@ $script:testEnvironment = Initialize-TestEnvironment ` Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +$script:CurrentSmbServerConfigBackup = Get-SmbServerConfiguration + # Begin Testing try { diff --git a/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 b/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 index 2e5aa0d8..409508b7 100644 --- a/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 +++ b/tests/Integration/DSC_SmbShare.Integration.Tests.ps1 @@ -22,10 +22,10 @@ Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\Co try { Describe 'SmbShare Integration Tests' { - $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dcsResourceName).config.ps1" + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" . $configFile - $configurationName = "$($script:dcsResourceName)_Prerequisites_Config" + $configurationName = "$($script:dscResourceName)_Prerequisites_Config" Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { @@ -51,7 +51,7 @@ try } } - $configurationName = "$($script:dcsResourceName)_CreateShare1_Config" + $configurationName = "$($script:dscResourceName)_CreateShare1_Config" Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { @@ -119,7 +119,7 @@ try } } - $configurationName = "$($script:dcsResourceName)_CreateShare2_Config" + $configurationName = "$($script:dscResourceName)_CreateShare2_Config" Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { @@ -186,7 +186,7 @@ try } } - $configurationName = "$($script:dcsResourceName)_UpdateProperties_Config" + $configurationName = "$($script:dscResourceName)_UpdateProperties_Config" Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { @@ -255,7 +255,7 @@ try } } - $configurationName = "$($script:dcsResourceName)_RemovePermission_Config" + $configurationName = "$($script:dscResourceName)_RemovePermission_Config" Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { @@ -307,7 +307,7 @@ try } } - $configurationName = "$($script:dcsResourceName)_RecreateShare1_Config" + $configurationName = "$($script:dscResourceName)_RecreateShare1_Config" Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { @@ -355,7 +355,7 @@ try } - $configurationName = "$($script:dcsResourceName)_RemoveShare1_Config" + $configurationName = "$($script:dscResourceName)_RemoveShare1_Config" Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { @@ -401,7 +401,7 @@ try } } - $configurationName = "$($script:dcsResourceName)_RemoveShare2_Config" + $configurationName = "$($script:dscResourceName)_RemoveShare2_Config" Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { @@ -447,7 +447,7 @@ try } } - $configurationName = "$($script:dcsResourceName)_Cleanup_Config" + $configurationName = "$($script:dscResourceName)_Cleanup_Config" Context ('When using configuration {0}' -f $configurationName) { It 'Should compile and apply the MOF without throwing' { diff --git a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 index e9a1b45e..1e2d4b25 100644 --- a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 @@ -18,6 +18,8 @@ $script:testEnvironment = Initialize-TestEnvironment ` Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') +Write-Verbose -Message (Get-WindowsCapability -Online | Format-List -Property * | Out-String) -Verbose + # Begin Testing try { From d39dd4f6a87fab12fec9da1d509f654419fd7d94 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Tue, 21 Jan 2020 20:57:12 +1300 Subject: [PATCH 14/30] Fix integration tests for ScheduledTask --- tests/Integration/DSC_ScheduledTask.Config.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Integration/DSC_ScheduledTask.Config.ps1 b/tests/Integration/DSC_ScheduledTask.Config.ps1 index 96b42fb0..7a477483 100644 --- a/tests/Integration/DSC_ScheduledTask.Config.ps1 +++ b/tests/Integration/DSC_ScheduledTask.Config.ps1 @@ -191,7 +191,7 @@ Configuration ScheduledTaskExecuteAsAdd { $executeAsCredential = New-Object ` -TypeName System.Management.Automation.PSCredential ` - -ArgumentList ($ENV:USERNAME, (ConvertTo-SecureString -String 'Ignore' -AsPlainText -Force)) + -ArgumentList ("$ENV:COMPUTERNAME\$ENV:USERNAME", (ConvertTo-SecureString -String 'Ignore' -AsPlainText -Force)) ScheduledTask ScheduledTaskExecuteAsAdd { @@ -213,7 +213,7 @@ Configuration ScheduledTaskExecuteAsGroupAdd { $executeAsCredential = New-Object ` -TypeName System.Management.Automation.PSCredential ` - -ArgumentList ('Users', (ConvertTo-SecureString -String 'Ignore' -AsPlainText -Force)) + -ArgumentList ('BUILTIN\Users', (ConvertTo-SecureString -String 'Ignore' -AsPlainText -Force)) ScheduledTask ScheduledTaskExecuteAsAdd { From dc4b931ad4a32be583ac15e6295eaa6abac583dc Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Tue, 21 Jan 2020 21:30:01 +1300 Subject: [PATCH 15/30] Work on integration tests --- ...SC_WindowsCapability.Integration.Tests.ps1 | 19 ++++++++++-- tests/TestHelpers/CommonTestHelper.psm1 | 30 ++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 index 1e2d4b25..3281fefb 100644 --- a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 @@ -18,12 +18,27 @@ $script:testEnvironment = Initialize-TestEnvironment ` Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') -Write-Verbose -Message (Get-WindowsCapability -Online | Format-List -Property * | Out-String) -Verbose - # Begin Testing try { Describe 'WindowsCapability Integration Tests' { + # Ensure that the tests can be performed on this computer + $sourceAvailable = Test-WindowsCapabilitySourceAvailable -Verbose + + Describe 'Windows capability source files' { + It 'Should be available' { + if (-not $sourceAvailable) + { + Set-ItResult -Inconclusive -Because 'Windows capability source files are not available' + } + } + } + + if (-not $sourceAvailable) + { + break + } + $configFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).Config.ps1" . $configFile diff --git a/tests/TestHelpers/CommonTestHelper.psm1 b/tests/TestHelpers/CommonTestHelper.psm1 index a99e3db7..d9c80fdc 100644 --- a/tests/TestHelpers/CommonTestHelper.psm1 +++ b/tests/TestHelpers/CommonTestHelper.psm1 @@ -81,6 +81,34 @@ function Get-InvalidOperationRecord return New-Object @newObjectParams } +<# + .SYNOPSIS + Test if the source files are available for Windows Capability. + If the source files are not available Get-WindowsCapability + will throw an exception. +#> +function Test-WindowsCapabilitySourceAvailable +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param () + + $sourceAvailable = $true + + try + { + Get-WindowsCapability -Online -ErrorAction + } + catch + { + $sourceAvailable = $false + Write-Verbose -Message ($_ | Format-List * | Out-String) + } + + return $sourceAvailable +} + Export-ModuleMember -Function ` Get-InvalidArgumentRecord, ` - Get-InvalidOperationRecord + Get-InvalidOperationRecord, ` + Test-WindowsCapabilitySourceAvailable From 1ea6bde8b9b943ceab0d0130fbb11e4260ecf206 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Wed, 22 Jan 2020 08:14:04 +1300 Subject: [PATCH 16/30] Start Windows Update Service in integeration tests --- azure-pipelines.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 17c374ba..f272d3ed 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -143,6 +143,10 @@ stages: script: 'winrm quickconfig -quiet' pwsh: false + - powershell: | + Set-Service -Name wuauserv -StartupType Manual -Verbose + Start-Service -name wuauserv -Verbose + - task: PowerShell@2 name: test displayName: 'Run Integration Test' From c0dbdc042bb2d0bda4a52e22eba0ce2089699247 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Wed, 22 Jan 2020 18:31:49 +1300 Subject: [PATCH 17/30] Fix Test-WindowsCapabilitySourceAvailable --- tests/TestHelpers/CommonTestHelper.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestHelpers/CommonTestHelper.psm1 b/tests/TestHelpers/CommonTestHelper.psm1 index d9c80fdc..629054ce 100644 --- a/tests/TestHelpers/CommonTestHelper.psm1 +++ b/tests/TestHelpers/CommonTestHelper.psm1 @@ -97,7 +97,7 @@ function Test-WindowsCapabilitySourceAvailable try { - Get-WindowsCapability -Online -ErrorAction + Get-WindowsCapability -Online -ErrorAction Stop } catch { From ec684b2292a1036b677acdeca6deb5c906ccfdb1 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 17:04:09 +1300 Subject: [PATCH 18/30] Fix integration tests again --- tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 index 3281fefb..0af77464 100644 --- a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 @@ -89,7 +89,6 @@ try $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel $current.LogPath | Should -Be $configData.AllNodes[0].LogPath $current.Ensure | Should -Be $configData.AllNodes[0].Ensure - $current.IsSingleInstance | Should -Be 'Yes' } } @@ -139,7 +138,6 @@ try $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel $current.LogPath | Should -Be $configData.AllNodes[0].LogPath $current.Ensure | Should -Be $configData.AllNodes[0].Ensure - $current.IsSingleInstance | Should -Be 'Yes' } } } From c65d8f9e1aaa0cec1f80fe4d0a1eb1cc8391dab9 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 17:26:33 +1300 Subject: [PATCH 19/30] Fix Windows Capability --- .../DSC_WindowsCapability/DSC_WindowsCapability.psm1 | 1 - 1 file changed, 1 deletion(-) diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index 26089b38..6271d8e6 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -52,7 +52,6 @@ function Get-TargetResource LogLevel = $windowsCapability.LogLevel State = $windowsCapability.State Ensure = $Ensure - IsSingleInstance = 'Yes' } Write-Verbose -Message ($script:localizedData.GetTargetResourceEndMessage -f $Name) From 8932339d80562f462d916a04e5683124e63a546c Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 17:49:13 +1300 Subject: [PATCH 20/30] Further fixes --- .../DSC_WindowsCapability/DSC_WindowsCapability.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index 6271d8e6..17c4d533 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -50,7 +50,7 @@ function Get-TargetResource $returnValue = @{ Name = $Name LogLevel = $windowsCapability.LogLevel - State = $windowsCapability.State + LogPath = $null Ensure = $Ensure } From 39f87965b466ab06079e8a3e8687559a091c9230 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 19:24:14 +1300 Subject: [PATCH 21/30] Fix resource --- ...SC_WindowsCapability.Integration.Tests.ps1 | 2 -- tests/Unit/DSC_WindowsCapability.Tests.ps1 | 32 ++++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 index 0af77464..f10af45b 100644 --- a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 @@ -87,7 +87,6 @@ try } $current.Name | Should -Be $configData.AllNodes[0].Name $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel - $current.LogPath | Should -Be $configData.AllNodes[0].LogPath $current.Ensure | Should -Be $configData.AllNodes[0].Ensure } } @@ -136,7 +135,6 @@ try } $current.Name | Should -Be $configData.AllNodes[0].Name $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel - $current.LogPath | Should -Be $configData.AllNodes[0].LogPath $current.Ensure | Should -Be $configData.AllNodes[0].Ensure } } diff --git a/tests/Unit/DSC_WindowsCapability.Tests.ps1 b/tests/Unit/DSC_WindowsCapability.Tests.ps1 index 2eece8f4..2bcc4831 100644 --- a/tests/Unit/DSC_WindowsCapability.Tests.ps1 +++ b/tests/Unit/DSC_WindowsCapability.Tests.ps1 @@ -32,31 +32,31 @@ Invoke-TestSetup try { InModuleScope $script:dscResourceName { - $script:testResourceName = 'Test' + $script:testCapabilityName = 'Test' $script:testAndSetTargetResourceParametersPresent = @{ - Name = $script:testResourceName + Name = $script:testCapabilityName Ensure = 'Present' } $script:testAndSetTargetResourceParametersAbsent = @{ - Name = $script:testResourceName + Name = $script:testCapabilityName Ensure = 'Absent' } $getWindowsCapabilityIsInstalled = { @{ - Name = 'Test' - State = 'Installed' - Ensure = 'Present' + Name = $script:testCapabilityName + State = 'Installed' + LogLevel = 'Errors' } } $getWindowsCapabilityIsNotInstalled = { @{ - Name = 'Test' - State = 'NotPresent' - Ensure = 'Absent' + Name = $script:testCapabilityName + State = 'NotPresent' + LogLevel = 'Errors' } } @@ -114,13 +114,14 @@ try It 'Should not throw an exception' { { - $script:getTargetResourceResult = Get-TargetResource -Name $script:testResourceName -Verbose + $script:getTargetResourceResult = Get-TargetResource -Name $script:testCapabilityName -Verbose } | Should -Not -Throw } It 'Should return expected result' { - $script:getTargetResourceResult.Name | Should -Be $script:testResourceName - $script:getTargetResourceResult.State | Should -Be 'Installed' + $script:getTargetResourceResult.Name | Should -Be $script:testCapabilityName + $script:getTargetResourceResult.Ensure | Should -Be 'Present' + $script:getTargetResourceResult.LogLevel | Should -Be 'Errors' } It 'Should call all verifiable mocks' { @@ -136,13 +137,14 @@ try It 'Should not throw an exception' { { - $script:getTargetResourceResult = Get-TargetResource -Name $script:testResourceName -Verbose + $script:getTargetResourceResult = Get-TargetResource -Name $script:testCapabilityName -Verbose } | Should -Not -Throw } It 'Should return expected result' { - $script:getTargetResourceResult.Name | Should -Be $script:testResourceName - $script:getTargetResourceResult.State | Should -Be 'NotPresent' + $script:getTargetResourceResult.Name | Should -Be $script:testCapabilityName + $script:getTargetResourceResult.Ensure | Should -Be 'Absent' + $script:getTargetResourceResult.LogLevel | Should -Be 'Errors' } It 'Should call all verifiable mocks' { From f9f4649ea99bfba6afae29b43352e8a97c662058 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 20:51:44 +1300 Subject: [PATCH 22/30] Fix Windows Capability --- .../DSC_WindowsCapability.psm1 | 110 +++---- .../DSC_WindowsCapability.schema.mof | 6 +- .../en-US/DSC_WindowsCapability.strings.psd1 | 2 - ...SC_WindowsCapability.Integration.Tests.ps1 | 2 - tests/Unit/DSC_WindowsCapability.Tests.ps1 | 291 +++++++++++++----- 5 files changed, 257 insertions(+), 154 deletions(-) diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index 17c4d533..f5ec9330 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -13,10 +13,7 @@ $script:localizedData = Get-LocalizedData -ResourceName 'DSC_WindowsCapability' Gets the current state of the Windows Capability. .PARAMETER Name - Specifies the given name of a Windows Capability. - - .PARAMETER Name - Specifies the given name of a Windows Capability. + Specifies the name of the Windows Capability. #> function Get-TargetResource { @@ -26,18 +23,21 @@ function Get-TargetResource ( [Parameter(Mandatory = $true)] [System.String] - $Name, - - [Parameter()] - [ValidateSet('Present', 'Absent')] - [System.String] - $Ensure = 'Present' + $Name ) Write-Verbose -Message ($script:localizedData.GetTargetResourceStartMessage -f $Name) - $null = $PSBoundParameters.Remove('Ensure') $windowsCapability = Get-WindowsCapability -Online @PSBoundParameters + if ([System.String]::IsNullOrEmpty($windowsCapability.Name)) + { + New-InvalidArgumentException -Message ($script:localizedData.CapabilityNameNotFound -f $Name) + } + else + { + Write-Verbose -Message ($script:localizedData.CapabilityNameFound -f $Name) + } + if ($windowsCapability.State -eq 'Installed') { $Ensure = 'Present' @@ -48,10 +48,10 @@ function Get-TargetResource } $returnValue = @{ - Name = $Name - LogLevel = $windowsCapability.LogLevel - LogPath = $null - Ensure = $Ensure + Name = $Name + LogLevel = $null + LogPath = $null + Ensure = $Ensure } Write-Verbose -Message ($script:localizedData.GetTargetResourceEndMessage -f $Name) @@ -63,18 +63,21 @@ function Get-TargetResource Sets if the the current state of the Windows Capability is in the desired state. .PARAMETER Name - Specifies the given name of a Windows Capability. + Specifies the name of the Windows Capability. .PARAMETER Ensure - Specifies whether the Windows Capability should be installed or uninstalled. + Specifies whether the Windows Capability should be installed + or uninstalled. .PARAMETER LogLevel - Specifies the given LogLevel of a Windows Capability. - Default LogLevel is: 'WarningsInfo' + Specifies the given Log Level of a Windows Capability. This is a write + only parameter that is used when updating the status of a Windows + Capability. If not specified, the default is 'WarningsInfo'. .PARAMETER LogPath - Specifies the full path and file name to log to. - If not set, the default is %WINDIR%\Logs\Dism\dism.log + Specifies the full path and file name to log to. This is a write + only parameter that is used when updating the status of a Windows + Capability. If not specified, the default is '$ENV:windir\Logs\Dism\dism.log'. #> function Set-TargetResource { @@ -102,22 +105,13 @@ function Set-TargetResource Write-Verbose -Message ($script:localizedData.SetTargetResourceStartMessage -f $Name) $null = $PSBoundParameters.Remove('Ensure') - $windowsCapability = Get-WindowsCapability -Online @PSBoundParameters - - if ($windowsCapability.State -eq 'Installed') - { - $ensureResult = 'Present' - } - else - { - $ensureResult = 'Absent' - } + $currentState = Get-TargetResource -Name $Name switch ($Ensure) { 'Present' { - if ($Ensure -ne $ensureResult) + if ($Ensure -ne $currentState.Ensure) { Write-Verbose -Message ($script:localizedData.SetTargetAddMessage -f $Name) $null = Add-WindowsCapability -Online @PSBoundParameters @@ -126,7 +120,7 @@ function Set-TargetResource 'Absent' { - if ($Ensure -ne $ensureResult) + if ($Ensure -ne $currentState.Ensure) { Write-Verbose -Message ($script:localizedData.SetTargetRemoveMessage -f $Name) $null = Remove-WindowsCapability -Online @PSBoundParameters @@ -140,18 +134,21 @@ function Set-TargetResource Tests if the the current state of the Windows Capability is in the desired state. .PARAMETER Name - Specifies the given name of a Windows Capability. + Specifies the name of the Windows Capability. .PARAMETER Ensure - Specifies whether the Windows Capability should be installed or uninstalled. + Specifies whether the Windows Capability should be installed + or uninstalled. .PARAMETER LogLevel - Specifies the given LogLevel of a Windows Capability. - Default LogLevel is: 'WarningsInfo' + Specifies the given Log Level of a Windows Capability. This is a write + only parameter that is used when updating the status of a Windows + Capability. If not specified, the default is 'WarningsInfo'. .PARAMETER LogPath - Specifies the full path and file name to log to. - If not set, the default is %WINDIR%\Logs\Dism\dism.log + Specifies the full path and file name to log to. This is a write + only parameter that is used when updating the status of a Windows + Capability. If not specified, the default is '$ENV:windir\Logs\Dism\dism.log'. #> function Test-TargetResource { @@ -181,40 +178,9 @@ function Test-TargetResource $inDesiredState = $true Write-Verbose -Message ($script:localizedData.TestTargetResourceStartMessage -f $Name) - $null = $PSBoundParameters.Remove('Ensure') - $windowsCapability = Get-WindowsCapability -Online @PSBoundParameters - - if ([System.String]::IsNullOrEmpty($windowsCapability.Name)) - { - New-InvalidArgumentException -Message ($script:localizedData.CapabilityNameNotFound -f $Name) - } - else - { - Write-Verbose -Message ($script:localizedData.CapabilityNameFound -f $Name) - } - - if ($LogPath) - { - if (-not (Test-Path -Path $LogPath)) - { - New-InvalidArgumentException -Message ($script:localizedData.LogPathFailedMessage -f $LogPath) - } - else - { - Write-Verbose -Message ($script:localizedData.LogPathFoundMessage -f $LogPath) - } - } - - if ($windowsCapability.State -eq 'Installed') - { - $ensureResult = 'Present' - } - else - { - $ensureResult = 'Absent' - } + $currentState = Get-TargetResource -Name $Name - if ($PSBoundParameters.ContainsKey('Ensure') -and $Ensure -ne $ensureResult) + if ($Ensure -ne $currentState.Ensure) { Write-Verbose -Message ($script:localizedData.SetResourceIsNotInDesiredState -f $Name) $inDesiredState = $false diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof index 0b364422..63ce4e36 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof @@ -2,8 +2,8 @@ [ClassVersion("1.0.0.1"), FriendlyName("WindowsCapability")] class DSC_WindowsCapability : OMI_BaseResource { - [Key, Description("Specifies the given name of a Windows Capability")] String Name; + [Key, Description("Specifies the name of the Windows Capability.")] String Name; [Write, Description("Specifies whether the Windows Capability should be installed or uninstalled. To install the Windows Capability, set this property to Present. To uninstall the Windows Capability, set the property to Absent."), ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}] String Ensure; - [Write, Description("Specifies the given LogLevel of a Windows Capability."), ValueMap{"Errors", "Warnings", "WarningsInfo"}, Values{"Errors", "Warnings", "WarningsInfo"}] String LogLevel; - [Write, Description("Specifies the full path and file name to log to.")] String LogPath; + [Write, Description("Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is 'WarningsInfo'."), ValueMap{"Errors", "Warnings", "WarningsInfo"}, Values{"Errors", "Warnings", "WarningsInfo"}] String LogLevel; + [Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is '$ENV:windir\Logs\Dism\dism.log'.")] String LogPath; }; diff --git a/source/DSCResources/DSC_WindowsCapability/en-US/DSC_WindowsCapability.strings.psd1 b/source/DSCResources/DSC_WindowsCapability/en-US/DSC_WindowsCapability.strings.psd1 index 185fb528..55dc8056 100644 --- a/source/DSCResources/DSC_WindowsCapability/en-US/DSC_WindowsCapability.strings.psd1 +++ b/source/DSCResources/DSC_WindowsCapability/en-US/DSC_WindowsCapability.strings.psd1 @@ -8,8 +8,6 @@ ConvertFrom-StringData -StringData @' SetTargetRemoveMessage = Executing Remove functionality on Windows Capability '{0}'. SetTargetAddMessage = Executing Add functionality on Windows Capability '{0}'. TestTargetResourceStartMessage = Begin executing Test functionality on Windows Capability '{0}'. - LogPathFailedMessage = LogPath '{0}' not found. - LogPathFoundMessage = LogPath '{0}' found. CapabilityNameFound = Specified Windows Capability '{0}' found. CapabilityNameNotFound = Specified Windows Capability '{0}' not found. '@ diff --git a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 index f10af45b..5252dd70 100644 --- a/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 +++ b/tests/Integration/DSC_WindowsCapability.Integration.Tests.ps1 @@ -86,7 +86,6 @@ try $_.ConfigurationName -eq "$($script:dscResourceName)_Config" } $current.Name | Should -Be $configData.AllNodes[0].Name - $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel $current.Ensure | Should -Be $configData.AllNodes[0].Ensure } } @@ -134,7 +133,6 @@ try $_.ConfigurationName -eq "$($script:dscResourceName)_Config" } $current.Name | Should -Be $configData.AllNodes[0].Name - $current.LogLevel | Should -Be $configData.AllNodes[0].LogLevel $current.Ensure | Should -Be $configData.AllNodes[0].Ensure } } diff --git a/tests/Unit/DSC_WindowsCapability.Tests.ps1 b/tests/Unit/DSC_WindowsCapability.Tests.ps1 index 2bcc4831..3115a432 100644 --- a/tests/Unit/DSC_WindowsCapability.Tests.ps1 +++ b/tests/Unit/DSC_WindowsCapability.Tests.ps1 @@ -106,11 +106,9 @@ try } Describe 'DSC_WindowsCapability\Get-TargetResource' { - Context 'When a Windows Capability is enabled and it should' { + Context 'When a Windows Capability is installed' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsInstalled ` - -ModuleName 'DSC_WindowsCapability' ` - -Verifiable + -MockWith $getWindowsCapabilityIsInstalled It 'Should not throw an exception' { { @@ -121,18 +119,23 @@ try It 'Should return expected result' { $script:getTargetResourceResult.Name | Should -Be $script:testCapabilityName $script:getTargetResourceResult.Ensure | Should -Be 'Present' - $script:getTargetResourceResult.LogLevel | Should -Be 'Errors' } - It 'Should call all verifiable mocks' { - Assert-VerifiableMock + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 } } - Context 'When a Windows Capability is not enabled' { + Context 'When a Windows Capability is not installed' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsNotInstalled ` - -ModuleName 'DSC_WindowsCapability' ` -Verifiable It 'Should not throw an exception' { @@ -144,25 +147,55 @@ try It 'Should return expected result' { $script:getTargetResourceResult.Name | Should -Be $script:testCapabilityName $script:getTargetResourceResult.Ensure | Should -Be 'Absent' - $script:getTargetResourceResult.LogLevel | Should -Be 'Errors' } - It 'Should call all verifiable mocks' { - Assert-VerifiableMock + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 + } + } + + Context 'When a Windows Capability does not exist' { + Mock -CommandName Get-WindowsCapability ` + -MockWith $getWindowsCapabilityIsNotInstalled ` + -Verifiable + + $errorRecord = Get-InvalidArgumentRecord -Message ($script:localizedData.CapabilityNameNotFound -f $Name) + + It 'Should throw expected exception' { + { + $script:getTargetResourceResult = Get-TargetResource -Name $script:testCapabilityName -Verbose + } | Should -Throw $errorRecord + } + + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 } } } Describe 'DSC_WindowsCapability\Test-TargetResource' { - Context 'When a Windows Capability is enabled' { + Context 'When a Windows Capability is installed and should be' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsInstalled ` - -ModuleName 'DSC_WindowsCapability' ` -Verifiable It 'Should not throw an exception' { { - $script:testTargetResourceResult = Test-TargetResource $script:testAndSetTargetResourceParametersPresent + $script:testTargetResourceResult = Test-TargetResource @script:testAndSetTargetResourceParametersPresent } | Should -Not -Throw } @@ -170,135 +203,243 @@ try $script:testTargetResourceResult | Should -BeTrue } - It 'Should call all verifiable mocks' { - Assert-VerifiableMock + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 } } - Context 'When a Windows Capability is not enabled' { + Context 'When a Windows Capability is not installed and should be' { Mock -CommandName Get-WindowsCapability ` -MockWith $getWindowsCapabilityIsNotInstalled ` - -ModuleName 'DSC_WindowsCapability' ` -Verifiable It 'Should not throw an exception' { { - $script:testTargetResourceResult = Test-TargetResource $script:testAndSetTargetResourceParametersAbsent + $script:testTargetResourceResult = Test-TargetResource @script:testAndSetTargetResourceParametersAbsent } | Should -Not -Throw } - It 'Should return true' { - $script:testTargetResourceResult | Should -BeTrue + It 'Should return false' { + $script:testTargetResourceResult | Should -BeFalse } - It 'Should call all verifiable mocks' { - Assert-VerifiableMock + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 } } - } - Describe 'DSC_WindowsCapability\Set-TargetResource' { - Context 'When a Windows Capability is not enabled' { + Context 'When a Windows Capability is installed and should not be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsNotInstalled ` - -ModuleName 'DSC_WindowsCapability' ` + -MockWith $getWindowsCapabilityIsInstalled ` -Verifiable - Mock -CommandName Add-WindowsCapability -MockWith { } - It 'Should not throw an exception' { { - Set-TargetResource @script:testAndSetTargetResourceParametersAbsent + $script:testTargetResourceResult = Test-TargetResource @script:testAndSetTargetResourceParametersAbsent } | Should -Not -Throw } - It 'Should call Add-WindowsCapability when Ensure set to Present' { - { - Set-TargetResource -Name $testResourceName - } | Should -Not -Throw - Assert-MockCalled -CommandName Add-WindowsCapability -Times 1 -Exactly -Scope It + It 'Should return true' { + $script:testTargetResourceResult | Should -BeTrue } - It 'Should call Get-WindowsCapability when Ensure set to Present' { - { Set-TargetResource -Name $testResourceName } | Should -Not -Throw - Assert-MockCalled -CommandName Get-WindowsCapability -Times 1 -Exactly -Scope It + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 } } - Context 'When a Windows Capability is already enabled' { + Context 'When a Windows Capability is not installed and should not be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsInstalled ` - -ModuleName 'DSC_WindowsCapability' ` + -MockWith $getWindowsCapabilityIsNotInstalled -Verifiable - Mock -CommandName Add-WindowsCapability -MockWith { } - It 'Should not throw an exception' { { - Set-TargetResource @script:testAndSetTargetResourceParametersPresent + $script:testTargetResourceResult = Test-TargetResource @script:testAndSetTargetResourceParametersAbsent } | Should -Not -Throw } - It 'Should not call Add-WindowsCapability when Windows Capability is already enabled' { - { Set-TargetResource -Name $testResourceName } | Should -Not -Throw - Assert-MockCalled -CommandName Add-WindowsCapability -Times 0 -Exactly -Scope It + It 'Should return false' { + $script:testTargetResourceResult | Should -BeFalse } - It 'Should call Get-WindowsCapability when when Windows Capability is already enabled' { - { Set-TargetResource -Name $testResourceName } | Should -Not -Throw - Assert-MockCalled -CommandName Get-WindowsCapability -Times 1 -Exactly -Scope It + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 } } + } + + Describe 'DSC_WindowsCapability\Set-TargetResource' { + BeforeAll { + Mock -CommandName Add-WindowsCapability + Mock -CommandName Remove-WindowsCapability + } - Context 'When a Windows Capability is already disabled' { + Context 'When a Windows Capability is installed and should be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsNotInstalled ` - -ModuleName 'DSC_WindowsCapability' ` + -MockWith $getWindowsCapabilityIsNotInstalled -Verifiable - Mock -CommandName Remove-WindowsCapability -MockWith { } - It 'Should not throw an exception' { { - Set-TargetResource @script:testAndSetTargetResourceParametersPresent + Set-TargetResource @script:testAndSetTargetResourceParametersAbsent } | Should -Not -Throw } - It 'Should not call Remove-WindowsCapability when Windows Capability is already disabled' { + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 + + Assert-MockCalled ` + -CommandName Add-WindowsCapability ` + -Exactly ` + -Times 0 + + Assert-MockCalled ` + -CommandName Remove-WindowsCapability ` + -Exactly ` + -Times 0 + } + } + + Context 'When a Windows Capability is not installed and should be' { + Mock -CommandName Get-WindowsCapability ` + -MockWith $getWindowsCapabilityIsNotInstalled + -Verifiable + + It 'Should not throw an exception' { { - Set-TargetResource -Name $testResourceName + Set-TargetResource @script:testAndSetTargetResourceParametersPresent } | Should -Not -Throw - Assert-MockCalled -CommandName Remove-WindowsCapability -Times 0 -Exactly -Scope It } - It 'Should call Get-WindowsCapability when when Windows Capability is already enabled' { - { Set-TargetResource -Name $testResourceName } | Should -Not -Throw - Assert-MockCalled -CommandName Get-WindowsCapability -Times 1 -Exactly -Scope It + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 + + Assert-MockCalled ` + -CommandName Add-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 + + Assert-MockCalled ` + -CommandName Remove-WindowsCapability ` + -Exactly ` + -Times 0 } } - Context 'When a Windows Capability is enabled and should not be' { + Context 'When a Windows Capability is installed and should not be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsInstalled ` - -ModuleName 'DSC_WindowsCapability' ` + -MockWith $getWindowsCapabilityIsInstalled -Verifiable - Mock -CommandName Remove-WindowsCapability -MockWith { } - It 'Should not throw an exception' { { Set-TargetResource @script:testAndSetTargetResourceParametersAbsent } | Should -Not -Throw } - It 'Should call Remove-WindowsCapability when Ensure set to Absent' { - { Set-TargetResource -Name $testResourceName -Ensure 'Absent' } | Should -Not -Throw - Assert-MockCalled -CommandName Remove-WindowsCapability -Times 1 -Exactly -Scope It + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 + + Assert-MockCalled ` + -CommandName Add-WindowsCapability ` + -Exactly ` + -Times 0 + + Assert-MockCalled ` + -CommandName Remove-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 0 + } + } + + Context 'When a Windows Capability is not installed and should not be' { + Mock -CommandName Get-WindowsCapability ` + -MockWith $getWindowsCapabilityIsNotInstalled + -Verifiable + + It 'Should not throw an exception' { + { + Set-TargetResource @script:testAndSetTargetResourceParametersAbsent + } | Should -Not -Throw } - It 'Should call Get-WindowsCapability when Windows Capability is set to Absent' { - { Set-TargetResource -Name $testResourceName -Ensure 'Absent' } | Should -Not -Throw - Assert-MockCalled -CommandName Get-WindowsCapability -Times 1 -Exactly -Scope It + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Get-WindowsCapability ` + -ParameterFilter { + $Name -eq $script:testCapabilityName -and ` + $Online -eq $true + } ` + -Exactly ` + -Times 1 + + Assert-MockCalled ` + -CommandName Add-WindowsCapability ` + -Exactly ` + -Times 0 + + Assert-MockCalled ` + -CommandName Remove-WindowsCapability ` + -Exactly ` + -Times 0 } } } From 3d3742b2727b9b533bb0a3a328681bce198673a3 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 21:26:30 +1300 Subject: [PATCH 23/30] Rework WindowsCapability --- CHANGELOG.md | 2 ++ .../DSC_WindowsCapability.psm1 | 16 +++++++--- .../DSC_WindowsCapability.schema.mof | 2 +- .../DSC_WindowsCapability/README.md | 11 +++++-- tests/Unit/DSC_WindowsCapability.Tests.ps1 | 32 +++++++++++-------- 5 files changed, 42 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54f1c2d6..70d75d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Migrated SystemLocale from [SystemLocaleDsc](https://github.com/PowerShell/SystemLocaleDsc). - RemoteDesktopAdmin: - Correct Context messages in integration tests by adding 'When'. +- WindowsCapability: + - Change `Test-TargetResource` to remove test for valid LogPath. ### Deprecated diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index f5ec9330..ef598a3b 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -49,8 +49,8 @@ function Get-TargetResource $returnValue = @{ Name = $Name - LogLevel = $null - LogPath = $null + LogLevel = $windowsCapability.LogLevel + LogPath = $windowsCapability.LogPath Ensure = $Ensure } @@ -77,7 +77,7 @@ function Get-TargetResource .PARAMETER LogPath Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is '$ENV:windir\Logs\Dism\dism.log'. + Capability. If not specified, the default is '%WINDIR%\Logs\Dism\dism.log'. #> function Set-TargetResource { @@ -148,7 +148,15 @@ function Set-TargetResource .PARAMETER LogPath Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is '$ENV:windir\Logs\Dism\dism.log'. + Capability. If not specified, the default is '%WINDIR%\Logs\Dism\dism.log'. + + .NOTES + Get-WindowsCapability will return the LogLevel and LogPath + properties, but these values don't reflect the values set + when calling Add-WindowsCapability or Remove-WindowsCapability. + + Therefore, these values can not be used to determine if the + resource is in state. #> function Test-TargetResource { diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof index 63ce4e36..7d57d743 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof @@ -5,5 +5,5 @@ class DSC_WindowsCapability : OMI_BaseResource [Key, Description("Specifies the name of the Windows Capability.")] String Name; [Write, Description("Specifies whether the Windows Capability should be installed or uninstalled. To install the Windows Capability, set this property to Present. To uninstall the Windows Capability, set the property to Absent."), ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}] String Ensure; [Write, Description("Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is 'WarningsInfo'."), ValueMap{"Errors", "Warnings", "WarningsInfo"}, Values{"Errors", "Warnings", "WarningsInfo"}] String LogLevel; - [Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is '$ENV:windir\Logs\Dism\dism.log'.")] String LogPath; + [Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is '%WINDIR%\Logs\Dism\dism.log'.")] String LogPath; }; diff --git a/source/DSCResources/DSC_WindowsCapability/README.md b/source/DSCResources/DSC_WindowsCapability/README.md index 874d0a41..5be0f6d5 100644 --- a/source/DSCResources/DSC_WindowsCapability/README.md +++ b/source/DSCResources/DSC_WindowsCapability/README.md @@ -1,5 +1,10 @@ # Description -This resource allows the configuration of a Windows Capability. -It can be used for enabling or disabling Windows Capabilities -and configure the desired Loglevel and Logpath. +This resource enables installation or removal of a Windows Capability. + +The LogLevel and LogPath parameters can be passed to the resource but +are not used to determine if the resource is in the desired state. + +This is because the LogLevel and LogPath properties returned by +`Get-WindowsCapability` do not reflect the values that may have been +set with `Add-WindowsCapability` or `Remove-WindowsCapability`. diff --git a/tests/Unit/DSC_WindowsCapability.Tests.ps1 b/tests/Unit/DSC_WindowsCapability.Tests.ps1 index 3115a432..386ffc0b 100644 --- a/tests/Unit/DSC_WindowsCapability.Tests.ps1 +++ b/tests/Unit/DSC_WindowsCapability.Tests.ps1 @@ -44,19 +44,21 @@ try Ensure = 'Absent' } - $getWindowsCapabilityIsInstalled = { + $script:getWindowsCapabilityIsInstalled = { @{ Name = $script:testCapabilityName State = 'Installed' LogLevel = 'Errors' + LogPath = 'LogPath' } } - $getWindowsCapabilityIsNotInstalled = { + $script:getWindowsCapabilityIsNotInstalled = { @{ Name = $script:testCapabilityName State = 'NotPresent' LogLevel = 'Errors' + LogPath = 'LogPath' } } @@ -108,7 +110,7 @@ try Describe 'DSC_WindowsCapability\Get-TargetResource' { Context 'When a Windows Capability is installed' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsInstalled + -MockWith $script:getWindowsCapabilityIsInstalled It 'Should not throw an exception' { { @@ -119,6 +121,8 @@ try It 'Should return expected result' { $script:getTargetResourceResult.Name | Should -Be $script:testCapabilityName $script:getTargetResourceResult.Ensure | Should -Be 'Present' + $script:getTargetResourceResult.LogLevel | Should -Be 'Errors' + $script:getTargetResourceResult.LogPath | Should -Be 'LogPath' } It 'Should call expected mocks' { @@ -135,7 +139,7 @@ try Context 'When a Windows Capability is not installed' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsNotInstalled ` + -MockWith $script:getWindowsCapabilityIsNotInstalled ` -Verifiable It 'Should not throw an exception' { @@ -147,6 +151,8 @@ try It 'Should return expected result' { $script:getTargetResourceResult.Name | Should -Be $script:testCapabilityName $script:getTargetResourceResult.Ensure | Should -Be 'Absent' + $script:getTargetResourceResult.LogLevel | Should -Be 'Errors' + $script:getTargetResourceResult.LogPath | Should -Be 'LogPath' } It 'Should call expected mocks' { @@ -163,7 +169,7 @@ try Context 'When a Windows Capability does not exist' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsNotInstalled ` + -MockWith $script:getWindowsCapabilityIsNotInstalled ` -Verifiable $errorRecord = Get-InvalidArgumentRecord -Message ($script:localizedData.CapabilityNameNotFound -f $Name) @@ -190,7 +196,7 @@ try Describe 'DSC_WindowsCapability\Test-TargetResource' { Context 'When a Windows Capability is installed and should be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsInstalled ` + -MockWith $script:getWindowsCapabilityIsInstalled ` -Verifiable It 'Should not throw an exception' { @@ -217,7 +223,7 @@ try Context 'When a Windows Capability is not installed and should be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsNotInstalled ` + -MockWith $script:getWindowsCapabilityIsNotInstalled ` -Verifiable It 'Should not throw an exception' { @@ -244,7 +250,7 @@ try Context 'When a Windows Capability is installed and should not be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsInstalled ` + -MockWith $script:getWindowsCapabilityIsInstalled ` -Verifiable It 'Should not throw an exception' { @@ -271,7 +277,7 @@ try Context 'When a Windows Capability is not installed and should not be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsNotInstalled + -MockWith $script:getWindowsCapabilityIsNotInstalled -Verifiable It 'Should not throw an exception' { @@ -305,7 +311,7 @@ try Context 'When a Windows Capability is installed and should be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsNotInstalled + -MockWith $script:getWindowsCapabilityIsNotInstalled -Verifiable It 'Should not throw an exception' { @@ -338,7 +344,7 @@ try Context 'When a Windows Capability is not installed and should be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsNotInstalled + -MockWith $script:getWindowsCapabilityIsNotInstalled -Verifiable It 'Should not throw an exception' { @@ -375,7 +381,7 @@ try Context 'When a Windows Capability is installed and should not be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsInstalled + -MockWith $script:getWindowsCapabilityIsInstalled -Verifiable It 'Should not throw an exception' { @@ -412,7 +418,7 @@ try Context 'When a Windows Capability is not installed and should not be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $getWindowsCapabilityIsNotInstalled + -MockWith $script:getWindowsCapabilityIsNotInstalled -Verifiable It 'Should not throw an exception' { From 5940abb589a353531e43020e24cd7539d6956cc6 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 21:35:46 +1300 Subject: [PATCH 24/30] Remove quotes from MOF --- .../DSC_WindowsCapability/DSC_WindowsCapability.psm1 | 8 ++++---- .../DSC_WindowsCapability.schema.mof | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index ef598a3b..384fe5c0 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -72,12 +72,12 @@ function Get-TargetResource .PARAMETER LogLevel Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is 'WarningsInfo'. + Capability. If not specified, the default is WarningsInfo. .PARAMETER LogPath Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is '%WINDIR%\Logs\Dism\dism.log'. + Capability. If not specified, the default is %WINDIR%\Logs\Dism\dism.log. #> function Set-TargetResource { @@ -143,12 +143,12 @@ function Set-TargetResource .PARAMETER LogLevel Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is 'WarningsInfo'. + Capability. If not specified, the default is WarningsInfo. .PARAMETER LogPath Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is '%WINDIR%\Logs\Dism\dism.log'. + Capability. If not specified, the default is %WINDIR%\Logs\Dism\dism.log. .NOTES Get-WindowsCapability will return the LogLevel and LogPath diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof index 7d57d743..d902099f 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof @@ -4,6 +4,6 @@ class DSC_WindowsCapability : OMI_BaseResource { [Key, Description("Specifies the name of the Windows Capability.")] String Name; [Write, Description("Specifies whether the Windows Capability should be installed or uninstalled. To install the Windows Capability, set this property to Present. To uninstall the Windows Capability, set the property to Absent."), ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}] String Ensure; - [Write, Description("Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is 'WarningsInfo'."), ValueMap{"Errors", "Warnings", "WarningsInfo"}, Values{"Errors", "Warnings", "WarningsInfo"}] String LogLevel; - [Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is '%WINDIR%\Logs\Dism\dism.log'.")] String LogPath; + [Write, Description("Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is WarningsInfo."), ValueMap{"Errors", "Warnings", "WarningsInfo"}, Values{"Errors", "Warnings", "WarningsInfo"}] String LogLevel; + [Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is %WINDIR%\Logs\Dism\dism.log.")] String LogPath; }; From 6271a4c68d85dce0a93c042ac549b3498bad6577 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 22:04:00 +1300 Subject: [PATCH 25/30] Fix unit tests on WindowsCapability --- .../DSC_WindowsCapability.psm1 | 4 +- tests/Unit/DSC_WindowsCapability.Tests.ps1 | 116 +++++++++--------- 2 files changed, 64 insertions(+), 56 deletions(-) diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index 384fe5c0..c769d4c9 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -31,7 +31,9 @@ function Get-TargetResource if ([System.String]::IsNullOrEmpty($windowsCapability.Name)) { - New-InvalidArgumentException -Message ($script:localizedData.CapabilityNameNotFound -f $Name) + New-InvalidArgumentException ` + -Message ($script:localizedData.CapabilityNameNotFound -f $Name) ` + -ArgumentName 'Name' } else { diff --git a/tests/Unit/DSC_WindowsCapability.Tests.ps1 b/tests/Unit/DSC_WindowsCapability.Tests.ps1 index 386ffc0b..019c62b5 100644 --- a/tests/Unit/DSC_WindowsCapability.Tests.ps1 +++ b/tests/Unit/DSC_WindowsCapability.Tests.ps1 @@ -35,13 +35,24 @@ try $script:testCapabilityName = 'Test' $script:testAndSetTargetResourceParametersPresent = @{ - Name = $script:testCapabilityName - Ensure = 'Present' + Name = $script:testCapabilityName + Ensure = 'Present' + Verbose = $true } $script:testAndSetTargetResourceParametersAbsent = @{ - Name = $script:testCapabilityName - Ensure = 'Absent' + Name = $script:testCapabilityName + Ensure = 'Absent' + Verbose = $true + } + + $script:getWindowsCapabilityDoesNotExist = { + @{ + Name = '' + State = '' + LogLevel = 'Errors' + LogPath = 'LogPath' + } } $script:getWindowsCapabilityIsInstalled = { @@ -114,7 +125,8 @@ try It 'Should not throw an exception' { { - $script:getTargetResourceResult = Get-TargetResource -Name $script:testCapabilityName -Verbose + $script:getTargetResourceResult = Get-TargetResource ` + -Name $script:testCapabilityName -Verbose } | Should -Not -Throw } @@ -129,9 +141,9 @@ try Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 } @@ -139,12 +151,12 @@ try Context 'When a Windows Capability is not installed' { Mock -CommandName Get-WindowsCapability ` - -MockWith $script:getWindowsCapabilityIsNotInstalled ` - -Verifiable + -MockWith $script:getWindowsCapabilityIsNotInstalled It 'Should not throw an exception' { { - $script:getTargetResourceResult = Get-TargetResource -Name $script:testCapabilityName -Verbose + $script:getTargetResourceResult = Get-TargetResource ` + -Name $script:testCapabilityName -Verbose } | Should -Not -Throw } @@ -159,9 +171,9 @@ try Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 } @@ -169,14 +181,16 @@ try Context 'When a Windows Capability does not exist' { Mock -CommandName Get-WindowsCapability ` - -MockWith $script:getWindowsCapabilityIsNotInstalled ` - -Verifiable + -MockWith $script:getWindowsCapabilityDoesNotExist - $errorRecord = Get-InvalidArgumentRecord -Message ($script:localizedData.CapabilityNameNotFound -f $Name) + $errorRecord = Get-InvalidArgumentRecord ` + -Message ($script:localizedData.CapabilityNameNotFound -f $script:testCapabilityName) ` + -ArgumentName 'Name' It 'Should throw expected exception' { { - $script:getTargetResourceResult = Get-TargetResource -Name $script:testCapabilityName -Verbose + $script:getTargetResourceResult = Get-TargetResource ` + -Name $script:testCapabilityName -Verbose } | Should -Throw $errorRecord } @@ -184,9 +198,9 @@ try Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 } @@ -196,8 +210,7 @@ try Describe 'DSC_WindowsCapability\Test-TargetResource' { Context 'When a Windows Capability is installed and should be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $script:getWindowsCapabilityIsInstalled ` - -Verifiable + -MockWith $script:getWindowsCapabilityIsInstalled It 'Should not throw an exception' { { @@ -213,9 +226,9 @@ try Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 } @@ -223,12 +236,11 @@ try Context 'When a Windows Capability is not installed and should be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $script:getWindowsCapabilityIsNotInstalled ` - -Verifiable + -MockWith $script:getWindowsCapabilityIsNotInstalled It 'Should not throw an exception' { { - $script:testTargetResourceResult = Test-TargetResource @script:testAndSetTargetResourceParametersAbsent + $script:testTargetResourceResult = Test-TargetResource @script:testAndSetTargetResourceParametersPresent } | Should -Not -Throw } @@ -240,9 +252,9 @@ try Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 } @@ -250,8 +262,7 @@ try Context 'When a Windows Capability is installed and should not be' { Mock -CommandName Get-WindowsCapability ` - -MockWith $script:getWindowsCapabilityIsInstalled ` - -Verifiable + -MockWith $script:getWindowsCapabilityIsInstalled It 'Should not throw an exception' { { @@ -259,17 +270,17 @@ try } | Should -Not -Throw } - It 'Should return true' { - $script:testTargetResourceResult | Should -BeTrue + It 'Should return false' { + $script:testTargetResourceResult | Should -BeFalse } It 'Should call expected mocks' { Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 } @@ -278,7 +289,6 @@ try Context 'When a Windows Capability is not installed and should not be' { Mock -CommandName Get-WindowsCapability ` -MockWith $script:getWindowsCapabilityIsNotInstalled - -Verifiable It 'Should not throw an exception' { { @@ -286,17 +296,17 @@ try } | Should -Not -Throw } - It 'Should return false' { - $script:testTargetResourceResult | Should -BeFalse + It 'Should return true' { + $script:testTargetResourceResult | Should -BeTrue } It 'Should call expected mocks' { Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 } @@ -312,7 +322,6 @@ try Context 'When a Windows Capability is installed and should be' { Mock -CommandName Get-WindowsCapability ` -MockWith $script:getWindowsCapabilityIsNotInstalled - -Verifiable It 'Should not throw an exception' { { @@ -324,9 +333,9 @@ try Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 @@ -345,7 +354,6 @@ try Context 'When a Windows Capability is not installed and should be' { Mock -CommandName Get-WindowsCapability ` -MockWith $script:getWindowsCapabilityIsNotInstalled - -Verifiable It 'Should not throw an exception' { { @@ -357,18 +365,18 @@ try Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 Assert-MockCalled ` -CommandName Add-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 @@ -382,7 +390,6 @@ try Context 'When a Windows Capability is installed and should not be' { Mock -CommandName Get-WindowsCapability ` -MockWith $script:getWindowsCapabilityIsInstalled - -Verifiable It 'Should not throw an exception' { { @@ -394,9 +401,9 @@ try Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 @@ -408,18 +415,17 @@ try Assert-MockCalled ` -CommandName Remove-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` - -Times 0 + -Times 1 } } Context 'When a Windows Capability is not installed and should not be' { Mock -CommandName Get-WindowsCapability ` -MockWith $script:getWindowsCapabilityIsNotInstalled - -Verifiable It 'Should not throw an exception' { { @@ -431,9 +437,9 @@ try Assert-MockCalled ` -CommandName Get-WindowsCapability ` -ParameterFilter { - $Name -eq $script:testCapabilityName -and ` + $Name -eq $script:testCapabilityName -and ` $Online -eq $true - } ` + } ` -Exactly ` -Times 1 From b47136ce50c212d6d5de666746632e8da3143fb3 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 22:15:32 +1300 Subject: [PATCH 26/30] Correct MOF file --- .../DSC_WindowsCapability/DSC_WindowsCapability.schema.mof | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof index d902099f..9ac86abd 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof @@ -5,5 +5,5 @@ class DSC_WindowsCapability : OMI_BaseResource [Key, Description("Specifies the name of the Windows Capability.")] String Name; [Write, Description("Specifies whether the Windows Capability should be installed or uninstalled. To install the Windows Capability, set this property to Present. To uninstall the Windows Capability, set the property to Absent."), ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}] String Ensure; [Write, Description("Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is WarningsInfo."), ValueMap{"Errors", "Warnings", "WarningsInfo"}, Values{"Errors", "Warnings", "WarningsInfo"}] String LogLevel; - [Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is %WINDIR%\Logs\Dism\dism.log.")] String LogPath; + [Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is %WINDIR%\\Logs\\Dism\\dism.log.")] String LogPath; }; From 9b042e502808da4a8f64f9aef1f18e5b57d77557 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 24 Jan 2020 22:23:30 +1300 Subject: [PATCH 27/30] Improve MOF --- .../DSC_WindowsCapability/DSC_WindowsCapability.psm1 | 8 ++++---- .../DSC_WindowsCapability.schema.mof | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 index c769d4c9..92ae611f 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.psm1 @@ -74,12 +74,12 @@ function Get-TargetResource .PARAMETER LogLevel Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is WarningsInfo. + Capability. If not specified, the default is 'WarningsInfo'. .PARAMETER LogPath Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is %WINDIR%\Logs\Dism\dism.log. + Capability. If not specified, the default is '%WINDIR%\Logs\Dism\dism.log'. #> function Set-TargetResource { @@ -145,12 +145,12 @@ function Set-TargetResource .PARAMETER LogLevel Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is WarningsInfo. + Capability. If not specified, the default is 'WarningsInfo'. .PARAMETER LogPath Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows - Capability. If not specified, the default is %WINDIR%\Logs\Dism\dism.log. + Capability. If not specified, the default is '%WINDIR%\Logs\Dism\dism.log'. .NOTES Get-WindowsCapability will return the LogLevel and LogPath diff --git a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof index 9ac86abd..339247a5 100644 --- a/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof +++ b/source/DSCResources/DSC_WindowsCapability/DSC_WindowsCapability.schema.mof @@ -4,6 +4,6 @@ class DSC_WindowsCapability : OMI_BaseResource { [Key, Description("Specifies the name of the Windows Capability.")] String Name; [Write, Description("Specifies whether the Windows Capability should be installed or uninstalled. To install the Windows Capability, set this property to Present. To uninstall the Windows Capability, set the property to Absent."), ValueMap{"Present", "Absent"}, Values{"Present", "Absent"}] String Ensure; - [Write, Description("Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is WarningsInfo."), ValueMap{"Errors", "Warnings", "WarningsInfo"}, Values{"Errors", "Warnings", "WarningsInfo"}] String LogLevel; - [Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is %WINDIR%\\Logs\\Dism\\dism.log.")] String LogPath; + [Write, Description("Specifies the given Log Level of a Windows Capability. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is 'WarningsInfo'."), ValueMap{"Errors", "Warnings", "WarningsInfo"}, Values{"Errors", "Warnings", "WarningsInfo"}] String LogLevel; + [Write, Description("Specifies the full path and file name to log to. This is a write only parameter that is used when updating the status of a Windows Capability. If not specified, the default is '%WINDIR%\\Logs\\Dism\\dism.log'.")] String LogPath; }; From c7db824d33cff480ee1e0cddeb9d588736f2e1f9 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Sat, 25 Jan 2020 10:35:22 +1300 Subject: [PATCH 28/30] Fix Common Test Helper --- tests/TestHelpers/CommonTestHelper.psm1 | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/TestHelpers/CommonTestHelper.psm1 b/tests/TestHelpers/CommonTestHelper.psm1 index 629054ce..64600a49 100644 --- a/tests/TestHelpers/CommonTestHelper.psm1 +++ b/tests/TestHelpers/CommonTestHelper.psm1 @@ -102,7 +102,6 @@ function Test-WindowsCapabilitySourceAvailable catch { $sourceAvailable = $false - Write-Verbose -Message ($_ | Format-List * | Out-String) } return $sourceAvailable From 82b92cd8673c19880b84eb6e8d881ba4dabf93b8 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 31 Jan 2020 18:52:29 +1300 Subject: [PATCH 29/30] Changes as per PR comments --- .vscode/settings.json | 29 ++- .../1-PowerPlan_SetPowerPlan_Config.ps1 | 4 +- .../ComputerManagementDsc.Common.psm1 | 16 +- tests/Integration/DSC_PendingReboot.Tests.ps1 | 4 +- ...onfig.ps1 => DSC_PendingReboot.config.ps1} | 5 +- ...ShellExecutionPolicy.Integration.Tests.ps1 | 2 +- .../DSC_PowerShellExecutionPolicy.config.ps1 | 4 +- ...C_RemoteDesktopAdmin.Integration.Tests.ps1 | 24 +-- ....ps1 => DSC_RemoteDesktopAdmin.config.ps1} | 24 ++- .../DSC_ScheduledTask.Integration.Tests.ps1 | 76 +++---- ...onfig.ps1 => DSC_ScheduledTask.config.ps1} | 32 +++ ... => DSC_SmbServerConfiguration.config.ps1} | 2 +- tests/Integration/DSC_SmbShare.config.ps1 | 2 +- tests/Integration/DSC_SystemLocale.config.ps1 | 2 +- .../DSC_TimeZone.Integration.Tests.ps1 | 2 +- tests/Integration/DSC_TimeZone.config.ps1 | 8 +- ...onfig.ps1 => DSC_VirtualMemory.config.ps1} | 25 ++- ...g.ps1 => DSC_WindowsCapability.config.ps1} | 5 +- .../DSC_WindowsEventLog.config.ps1 | 42 ++-- .../ComputerManagementDsc.Common.Tests.ps1 | 188 +++++++++--------- tests/Unit/DSC_Computer.Tests.ps1 | 10 +- tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 | 4 +- tests/Unit/DSC_PendingReboot.Tests.ps1 | 12 +- tests/Unit/DSC_PowerPlan.Tests.ps1 | 72 +++---- tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 | 16 +- tests/Unit/DSC_ScheduledTask.Tests.ps1 | 166 ++++++++-------- .../Unit/DSC_SmbServerConfiguration.Tests.ps1 | 2 +- tests/Unit/DSC_SmbShare.Tests.ps1 | 48 ++--- 28 files changed, 448 insertions(+), 378 deletions(-) rename tests/Integration/{DSC_PendingReboot.Config.ps1 => DSC_PendingReboot.config.ps1} (88%) rename tests/Integration/{DSC_RemoteDesktopAdmin.Config.ps1 => DSC_RemoteDesktopAdmin.config.ps1} (67%) rename tests/Integration/{DSC_ScheduledTask.Config.ps1 => DSC_ScheduledTask.config.ps1} (99%) rename tests/Integration/{DSC_SmbServerConfiguration.Config.ps1 => DSC_SmbServerConfiguration.config.ps1} (98%) rename tests/Integration/{DSC_VirtualMemory.Config.ps1 => DSC_VirtualMemory.config.ps1} (70%) rename tests/Integration/{DSC_WindowsCapability.Config.ps1 => DSC_WindowsCapability.config.ps1} (80%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 52e2e057..503b7024 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,16 +1,37 @@ -// Place your settings in this file to overwrite default and user settings. { "powershell.codeFormatting.openBraceOnSameLine": false, - "powershell.codeFormatting.newLineAfterOpenBrace": false, + "powershell.codeFormatting.newLineAfterOpenBrace": true, "powershell.codeFormatting.newLineAfterCloseBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, "powershell.codeFormatting.whitespaceBeforeOpenParen": true, "powershell.codeFormatting.whitespaceAroundOperator": true, "powershell.codeFormatting.whitespaceAfterSeparator": true, "powershell.codeFormatting.ignoreOneLineBlock": false, - "powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationAfterEveryPipeline", "powershell.codeFormatting.preset": "Custom", + "powershell.codeFormatting.alignPropertyValuePairs": true, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, - "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1" + "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1", + "powershell.scriptAnalysis.enable": true, + "files.associations": { + "*.ps1xml": "xml" + }, + "cSpell.words": [ + "COMPANYNAME", + "ICONURI", + "LICENSEURI", + "PROJECTURI", + "RELEASENOTES", + "buildhelpers", + "endregion", + "gitversion", + "icontains", + "keepachangelog", + "notin", + "pscmdlet", + "steppable" + ], + "[markdown]": { + "files.encoding": "utf8" + } } diff --git a/source/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 b/source/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 index bc8bb270..61318277 100644 --- a/source/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 +++ b/source/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 @@ -29,8 +29,8 @@ Configuration PowerPlan_SetPowerPlan_Config { PowerPlan SetPlanHighPerformance { - IsSingleInstance = 'Yes' - Name = 'High performance' + IsSingleInstance = 'Yes' + Name = 'High performance' } } } diff --git a/source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 b/source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 index 1399e679..16250bf1 100644 --- a/source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 +++ b/source/Modules/ComputerManagementDsc.Common/ComputerManagementDsc.Common.psm1 @@ -82,7 +82,7 @@ function Test-IsNanoServer $computerInfo = Get-ComputerInfo if ('Server' -eq $computerInfo.OsProductType ` - -and 'NanoServer' -eq $computerInfo.OsServerLevel) + -and 'NanoServer' -eq $computerInfo.OsServerLevel) { return $true } @@ -120,7 +120,7 @@ function New-InvalidArgumentException $argumentException = New-Object -TypeName 'ArgumentException' -ArgumentList @( $Message, $ArgumentName ) $newObjectParams = @{ - TypeName = 'System.Management.Automation.ErrorRecord' + TypeName = 'System.Management.Automation.ErrorRecord' ArgumentList = @( $argumentException, $ArgumentName, 'InvalidArgument', $null ) } $errorRecord = New-Object @newObjectParams @@ -157,17 +157,17 @@ function New-InvalidOperationException if ($null -eq $ErrorRecord) { $invalidOperationException = - New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message ) + New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message ) } else { $invalidOperationException = - New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message, - $ErrorRecord.Exception ) + New-Object -TypeName 'InvalidOperationException' -ArgumentList @( $Message, + $ErrorRecord.Exception ) } $newObjectParams = @{ - TypeName = 'System.Management.Automation.ErrorRecord' + TypeName = 'System.Management.Automation.ErrorRecord' ArgumentList = @( $invalidOperationException.ToString(), 'MachineStateIncorrect', 'InvalidOperation', $null ) } @@ -719,7 +719,7 @@ function Get-TimeZoneId Write-Verbose -Message ($script:localizedData.CurrentTimeZoneMessage -f $timeZone) $timeZoneInfo = [System.TimeZoneInfo]::GetSystemTimeZones() | - Where-Object -Property StandardName -EQ $timeZone + Where-Object -Property StandardName -EQ $timeZone return $timeZoneInfo.Id } # function Get-TimeZoneId @@ -1215,7 +1215,7 @@ function Set-ActivePowerPlan try { # Set the active power scheme with the native function - $returnCode = $powrprof::PowerSetActiveScheme([System.IntPtr]::Zero,$PowerPlanGuid) + $returnCode = $powrprof::PowerSetActiveScheme([System.IntPtr]::Zero, $PowerPlanGuid) # Check for non 0 return codes / errors form the native function if ($returnCode -ne 0) diff --git a/tests/Integration/DSC_PendingReboot.Tests.ps1 b/tests/Integration/DSC_PendingReboot.Tests.ps1 index bb19c65e..cf9a9854 100644 --- a/tests/Integration/DSC_PendingReboot.Tests.ps1 +++ b/tests/Integration/DSC_PendingReboot.Tests.ps1 @@ -55,8 +55,8 @@ try $configData = @{ AllNodes = @( @{ - NodeName = 'localhost' - RebootName = 'TestReboot' + NodeName = 'localhost' + RebootName = 'TestReboot' SkipComponentBasedServicing = $false SkipWindowsUpdate = $false SkipPendingFileRename = $false diff --git a/tests/Integration/DSC_PendingReboot.Config.ps1 b/tests/Integration/DSC_PendingReboot.config.ps1 similarity index 88% rename from tests/Integration/DSC_PendingReboot.Config.ps1 rename to tests/Integration/DSC_PendingReboot.config.ps1 index 4468bb63..9736087a 100644 --- a/tests/Integration/DSC_PendingReboot.Config.ps1 +++ b/tests/Integration/DSC_PendingReboot.config.ps1 @@ -1,9 +1,10 @@ # Integration Test Config Template Version: 1.0.0 -configuration DSC_PendingReboot_config +Configuration DSC_PendingReboot_config { Import-DscResource -ModuleName ComputerManagementDsc - node $AllNodes.NodeName { + node $AllNodes.NodeName + { PendingReboot TestReboot { Name = $Node.RebootName diff --git a/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 b/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 index f0f5d9f1..cbdba374 100644 --- a/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 +++ b/tests/Integration/DSC_PowerShellExecutionPolicy.Integration.Tests.ps1 @@ -53,7 +53,7 @@ try $current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq "$($script:dscResourceName)_Config" } - $current.ExecutionPolicy | Should -Be 'RemoteSigned' + $current.ExecutionPolicy | Should -Be 'RemoteSigned' $current.ExecutionPolicyScope | Should -Be 'LocalMachine' } } diff --git a/tests/Integration/DSC_PowerShellExecutionPolicy.config.ps1 b/tests/Integration/DSC_PowerShellExecutionPolicy.config.ps1 index 7641c9fa..6355181a 100644 --- a/tests/Integration/DSC_PowerShellExecutionPolicy.config.ps1 +++ b/tests/Integration/DSC_PowerShellExecutionPolicy.config.ps1 @@ -1,6 +1,6 @@ # Integration Test Config Template Version: 1.0.0 -configuration DSC_PowerShellExecutionPolicy_config - { +Configuration DSC_PowerShellExecutionPolicy_config +{ Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' diff --git a/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 b/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 index b5bd9f3b..439d9ce8 100644 --- a/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 +++ b/tests/Integration/DSC_RemoteDesktopAdmin.Integration.Tests.ps1 @@ -51,9 +51,9 @@ try } It 'Should return the correct values from Get-DscConfiguration' { - $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} - $Current.IsSingleInstance | Should -Be 'Yes' - $Current.Ensure | Should -Be 'Absent' + $Current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq $CurrentConfig } + $Current.IsSingleInstance | Should -Be 'Yes' + $Current.Ensure | Should -Be 'Absent' } It 'Should have set the correct registry values' { @@ -83,9 +83,9 @@ try } It 'Should return the correct values from Get-DscConfiguration' { - $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} - $Current.IsSingleInstance | Should -Be 'Yes' - $Current.Ensure | Should -Be 'Present' + $Current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq $CurrentConfig } + $Current.IsSingleInstance | Should -Be 'Yes' + $Current.Ensure | Should -Be 'Present' } It 'Should have set the correct registry values' { @@ -115,9 +115,9 @@ try } It 'Should return the correct values from Get-DscConfiguration' { - $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} - $Current.IsSingleInstance | Should -Be 'Yes' - $Current.Ensure | Should -Be 'Present' + $Current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq $CurrentConfig } + $Current.IsSingleInstance | Should -Be 'Yes' + $Current.Ensure | Should -Be 'Present' $Current.UserAuthentication | Should -Be 'Secure' } @@ -149,9 +149,9 @@ try } It 'Should return the correct values from Get-DscConfiguration' { - $Current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $CurrentConfig} - $Current.IsSingleInstance | Should -Be 'Yes' - $Current.Ensure | Should -Be 'Present' + $Current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq $CurrentConfig } + $Current.IsSingleInstance | Should -Be 'Yes' + $Current.Ensure | Should -Be 'Present' $Current.UserAuthentication | Should -Be 'NonSecure' } diff --git a/tests/Integration/DSC_RemoteDesktopAdmin.Config.ps1 b/tests/Integration/DSC_RemoteDesktopAdmin.config.ps1 similarity index 67% rename from tests/Integration/DSC_RemoteDesktopAdmin.Config.ps1 rename to tests/Integration/DSC_RemoteDesktopAdmin.config.ps1 index 57f63e7b..0a0061c9 100644 --- a/tests/Integration/DSC_RemoteDesktopAdmin.Config.ps1 +++ b/tests/Integration/DSC_RemoteDesktopAdmin.config.ps1 @@ -1,6 +1,7 @@ -configuration setToDenied +Configuration setToDenied { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { RemoteDesktopAdmin RemoteDesktopAdmin { @@ -10,9 +11,10 @@ configuration setToDenied } } -configuration setToAllowed +Configuration setToAllowed { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { RemoteDesktopAdmin RemoteDesktopAdmin { @@ -22,28 +24,30 @@ configuration setToAllowed } } -configuration setToAllowedSecure +Configuration setToAllowedSecure { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { RemoteDesktopAdmin RemoteDesktopAdmin { - IsSingleInstance = 'Yes' - Ensure = 'Present' - UserAuthentication = 'Secure' + IsSingleInstance = 'Yes' + Ensure = 'Present' + UserAuthentication = 'Secure' } } } -configuration setToAllowedNonSecure +Configuration setToAllowedNonSecure { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { RemoteDesktopAdmin RemoteDesktopAdmin { - IsSingleInstance = 'Yes' - Ensure = 'Present' - UserAuthentication = 'NonSecure' + IsSingleInstance = 'Yes' + Ensure = 'Present' + UserAuthentication = 'NonSecure' } } } diff --git a/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 b/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 index cdd656a0..5d049666 100644 --- a/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 +++ b/tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1 @@ -175,21 +175,21 @@ try } It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $currentConfig} - $current.TaskName | Should -Be 'Test task once cross timezone' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - $current.ScheduleType | Should -Be 'Once' - $current.RepeatInterval | Should -Be '00:15:00' - $current.RepetitionDuration | Should -Be '23:00:00' - $current.ActionWorkingPath | Should -Be (Get-Location).Path - $current.Enable | Should -BeTrue - $current.RandomDelay | Should -Be '01:00:00' + $current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq $currentConfig } + $current.TaskName | Should -Be 'Test task once cross timezone' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + $current.ScheduleType | Should -Be 'Once' + $current.RepeatInterval | Should -Be '00:15:00' + $current.RepetitionDuration | Should -Be '23:00:00' + $current.ActionWorkingPath | Should -Be (Get-Location).Path + $current.Enable | Should -BeTrue + $current.RandomDelay | Should -Be '01:00:00' $current.DisallowHardTerminate | Should -BeTrue - $current.RunOnlyIfIdle | Should -BeFalse - $current.Priority | Should -Be 9 - $current.RunLevel | Should -Be 'Limited' - $current.ExecutionTimeLimit | Should -Be '00:00:00' + $current.RunOnlyIfIdle | Should -BeFalse + $current.Priority | Should -Be 9 + $current.RunLevel | Should -Be 'Limited' + $current.ExecutionTimeLimit | Should -Be '00:00:00' } AfterAll { @@ -227,15 +227,15 @@ try $expectedStartTime = '2018-10-01T01:00:00' It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $currentConfig} - $current.TaskName | Should -Be 'Test task sync across time zone disabled' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - $current.ScheduleType | Should -Be 'Once' - $current.StartTime | Should -Be (Get-Date -Date $expectedStartTime) + $current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq $currentConfig } + $current.TaskName | Should -Be 'Test task sync across time zone disabled' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + $current.ScheduleType | Should -Be 'Once' + $current.StartTime | Should -Be (Get-Date -Date $expectedStartTime) $current.SynchronizeAcrossTimeZone | Should -BeFalse - $current.ActionWorkingPath | Should -Be (Get-Location).Path - $current.Enable | Should -BeTrue + $current.ActionWorkingPath | Should -Be (Get-Location).Path + $current.Enable | Should -BeTrue } It "Should have the trigger startBoundary set to $expectedStartTime" { @@ -274,15 +274,15 @@ try $expectedStartTime = '2018-10-01T01:00:00' + (Get-Date -Format 'zzz') It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript {$_.ConfigurationName -eq $currentConfig} - $current.TaskName | Should -Be 'Test task sync across time zone enabled' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - $current.ScheduleType | Should -Be 'Once' - $current.StartTime | Should -Be (Get-Date -Date $expectedStartTime) + $current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq $currentConfig } + $current.TaskName | Should -Be 'Test task sync across time zone enabled' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + $current.ScheduleType | Should -Be 'Once' + $current.StartTime | Should -Be (Get-Date -Date $expectedStartTime) $current.SynchronizeAcrossTimeZone | Should -BeTrue - $current.ActionWorkingPath | Should -Be (Get-Location).Path - $current.Enable | Should -BeTrue + $current.ActionWorkingPath | Should -Be (Get-Location).Path + $current.Enable | Should -BeTrue } It "Should have the trigger startBoundary set to $expectedStartTime" { @@ -326,12 +326,12 @@ try } It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { + $current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq $currentConfig } - $current.TaskName | Should -Be 'Test task builtin' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.Enable | Should -BeFalse + $current.TaskName | Should -Be 'Test task builtin' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.Enable | Should -BeFalse } } @@ -365,12 +365,12 @@ try } It 'Should have set the resource and all the parameters should match' { - $current = Get-DscConfiguration | Where-Object -FilterScript { + $current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq $currentConfig } - $current.TaskName | Should -Be 'Test task builtin' - $current.TaskPath | Should -Be '\ComputerManagementDsc\' - $current.Ensure | Should -Be 'Absent' + $current.TaskName | Should -Be 'Test task builtin' + $current.TaskPath | Should -Be '\ComputerManagementDsc\' + $current.Ensure | Should -Be 'Absent' } } } diff --git a/tests/Integration/DSC_ScheduledTask.Config.ps1 b/tests/Integration/DSC_ScheduledTask.config.ps1 similarity index 99% rename from tests/Integration/DSC_ScheduledTask.Config.ps1 rename to tests/Integration/DSC_ScheduledTask.config.ps1 index 7a477483..90bea108 100644 --- a/tests/Integration/DSC_ScheduledTask.Config.ps1 +++ b/tests/Integration/DSC_ScheduledTask.config.ps1 @@ -1,6 +1,7 @@ Configuration ScheduledTaskOnceCrossTimezone { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnceAdd @@ -25,6 +26,7 @@ Configuration ScheduledTaskOnceCrossTimezone Configuration ScheduledTaskOnceSynchronizeAcrossTimeZoneDisabled { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnceSynchronizeAcrossTimeZoneDisabled @@ -44,6 +46,7 @@ Configuration ScheduledTaskOnceSynchronizeAcrossTimeZoneDisabled Configuration ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled @@ -63,6 +66,7 @@ Configuration ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled Configuration ScheduledTaskOnceAdd { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnceAdd @@ -87,6 +91,7 @@ Configuration ScheduledTaskOnceAdd Configuration ScheduledTaskDailyAdd { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskDailyAdd @@ -109,6 +114,7 @@ Configuration ScheduledTaskDailyAdd Configuration ScheduledTaskDailyIndefinitelyAdd { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskDailyAdd @@ -131,6 +137,7 @@ Configuration ScheduledTaskDailyIndefinitelyAdd Configuration ScheduledTaskWeeklyAdd { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskWeeklyAdd @@ -153,6 +160,7 @@ Configuration ScheduledTaskWeeklyAdd Configuration ScheduledTaskLogonAdd { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnceAdd @@ -170,6 +178,7 @@ Configuration ScheduledTaskLogonAdd Configuration ScheduledTaskStartupAdd { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnceAdd @@ -187,6 +196,7 @@ Configuration ScheduledTaskStartupAdd Configuration ScheduledTaskExecuteAsAdd { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { $executeAsCredential = New-Object ` @@ -209,6 +219,7 @@ Configuration ScheduledTaskExecuteAsAdd Configuration ScheduledTaskExecuteAsGroupAdd { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { $executeAsCredential = New-Object ` @@ -231,6 +242,7 @@ Configuration ScheduledTaskExecuteAsGroupAdd Configuration ScheduledTaskOnEventAdd { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnEventAdd @@ -250,6 +262,7 @@ Configuration ScheduledTaskOnEventAdd Configuration ScheduledTaskOnceMod { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnceMod @@ -269,6 +282,7 @@ Configuration ScheduledTaskOnceMod Configuration ScheduledTaskDailyMod { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskDailyMod @@ -288,6 +302,7 @@ Configuration ScheduledTaskDailyMod Configuration ScheduledTaskDailyIndefinitelyMod { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskDailyMod @@ -307,6 +322,7 @@ Configuration ScheduledTaskDailyIndefinitelyMod Configuration ScheduledTaskWeeklyMod { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskWeeklyMod @@ -326,6 +342,7 @@ Configuration ScheduledTaskWeeklyMod Configuration ScheduledTaskLogonMod { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskLogonMod @@ -343,6 +360,7 @@ Configuration ScheduledTaskLogonMod Configuration ScheduledTaskStartupMod { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskStartupMod @@ -360,6 +378,7 @@ Configuration ScheduledTaskStartupMod Configuration ScheduledTaskExecuteAsMod { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskExecuteAsMod @@ -376,6 +395,7 @@ Configuration ScheduledTaskExecuteAsMod Configuration ScheduledTaskExecuteAsGroupMod { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskLogonMod @@ -392,6 +412,7 @@ Configuration ScheduledTaskExecuteAsGroupMod Configuration ScheduledTaskOnEventMod { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnEventMod @@ -411,6 +432,7 @@ Configuration ScheduledTaskOnEventMod Configuration ScheduledTaskOnceDel { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnceDel @@ -430,6 +452,7 @@ Configuration ScheduledTaskOnceDel Configuration ScheduledTaskDailyDel { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskDailyDel @@ -450,6 +473,7 @@ Configuration ScheduledTaskDailyDel Configuration ScheduledTaskDailyIndefinitelyDel { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskDailyDel @@ -470,6 +494,7 @@ Configuration ScheduledTaskDailyIndefinitelyDel Configuration ScheduledTaskWeeklyDel { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskWeeklyDel @@ -490,6 +515,7 @@ Configuration ScheduledTaskWeeklyDel Configuration ScheduledTaskLogonDel { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskLogonDel @@ -508,6 +534,7 @@ Configuration ScheduledTaskLogonDel Configuration ScheduledTaskStartupDel { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskStartupDel @@ -526,6 +553,7 @@ Configuration ScheduledTaskStartupDel Configuration ScheduledTaskExecuteAsDel { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskLogonDel @@ -542,6 +570,7 @@ Configuration ScheduledTaskExecuteAsDel Configuration ScheduledTaskExecuteAsGroupDel { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskLogonDel @@ -558,6 +587,7 @@ Configuration ScheduledTaskExecuteAsGroupDel Configuration ScheduledTaskOnEventDel { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskOnEventDel @@ -577,6 +607,7 @@ Configuration ScheduledTaskOnEventDel Configuration ScheduledTaskDisableBuiltIn { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskDisableBuiltIn @@ -591,6 +622,7 @@ Configuration ScheduledTaskDisableBuiltIn Configuration ScheduledTaskRemoveBuiltIn { Import-DscResource -ModuleName ComputerManagementDsc + node 'localhost' { ScheduledTask ScheduledTaskRemoveBuiltIn diff --git a/tests/Integration/DSC_SmbServerConfiguration.Config.ps1 b/tests/Integration/DSC_SmbServerConfiguration.config.ps1 similarity index 98% rename from tests/Integration/DSC_SmbServerConfiguration.Config.ps1 rename to tests/Integration/DSC_SmbServerConfiguration.config.ps1 index 4ba3202e..b6596410 100644 --- a/tests/Integration/DSC_SmbServerConfiguration.Config.ps1 +++ b/tests/Integration/DSC_SmbServerConfiguration.config.ps1 @@ -1,5 +1,5 @@ # Integration Test Config Template Version: 1.0.0 -configuration DSC_SmbServerConfiguration_config +Configuration DSC_SmbServerConfiguration_config { Import-DscResource -ModuleName ComputerManagementDsc diff --git a/tests/Integration/DSC_SmbShare.config.ps1 b/tests/Integration/DSC_SmbShare.config.ps1 index a9d2d571..1b06f48f 100644 --- a/tests/Integration/DSC_SmbShare.config.ps1 +++ b/tests/Integration/DSC_SmbShare.config.ps1 @@ -6,7 +6,7 @@ $configFile = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path, 'j if (Test-Path -Path $configFile) { <# - Allows reading the configuration data from a JSON file + Allows reading the Configuration data from a JSON file for real testing scenarios outside of the CI. #> $ConfigurationData = Get-Content -Path $configFile | ConvertFrom-Json diff --git a/tests/Integration/DSC_SystemLocale.config.ps1 b/tests/Integration/DSC_SystemLocale.config.ps1 index ed33d466..b322c4e2 100644 --- a/tests/Integration/DSC_SystemLocale.config.ps1 +++ b/tests/Integration/DSC_SystemLocale.config.ps1 @@ -1,4 +1,4 @@ -configuration DSC_SystemLocale_Config { +Configuration DSC_SystemLocale_Config { Import-DscResource -ModuleName ComputerManagementDsc node localhost { diff --git a/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 b/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 index f58cec2f..fe6e9d93 100644 --- a/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 +++ b/tests/Integration/DSC_TimeZone.Integration.Tests.ps1 @@ -67,7 +67,7 @@ try $current = Get-DscConfiguration | Where-Object -FilterScript { $_.ConfigurationName -eq "$($script:dscResourceName)_Config" } - $current.TimeZone | Should -Be $configData.AllNodes[0].TimeZone + $current.TimeZone | Should -Be $configData.AllNodes[0].TimeZone $current.IsSingleInstance | Should -Be $configData.AllNodes[0].IsSingleInstance } } diff --git a/tests/Integration/DSC_TimeZone.config.ps1 b/tests/Integration/DSC_TimeZone.config.ps1 index fbdc33af..f5e00075 100644 --- a/tests/Integration/DSC_TimeZone.config.ps1 +++ b/tests/Integration/DSC_TimeZone.config.ps1 @@ -1,8 +1,10 @@ -configuration DSC_TimeZone_Config { +Configuration DSC_TimeZone_Config { Import-DscResource -ModuleName ComputerManagementDsc - node localhost { - TimeZone Integration_Test { + node localhost + { + TimeZone Integration_Test + { TimeZone = $Node.TimeZone IsSingleInstance = $Node.IsSingleInstance } diff --git a/tests/Integration/DSC_VirtualMemory.Config.ps1 b/tests/Integration/DSC_VirtualMemory.config.ps1 similarity index 70% rename from tests/Integration/DSC_VirtualMemory.Config.ps1 rename to tests/Integration/DSC_VirtualMemory.config.ps1 index f1c00c4e..5671e2ff 100644 --- a/tests/Integration/DSC_VirtualMemory.Config.ps1 +++ b/tests/Integration/DSC_VirtualMemory.config.ps1 @@ -1,10 +1,11 @@ Configuration setToAuto { Import-DscResource -ModuleName ComputerManagementDsc - node "localhost" { + node 'localhost' + { VirtualMemory vMem { - Type = 'AutoManagePagingFile' + Type = 'AutoManagePagingFile' Drive = 'C' } } @@ -13,11 +14,13 @@ Configuration setToAuto Configuration setToCustom { Import-DscResource -ModuleName ComputerManagementDsc - node "localhost" { + + node 'localhost' + { VirtualMemory vMem { - Type = 'CustomSize' - Drive = 'C' + Type = 'CustomSize' + Drive = 'C' InitialSize = 128 MaximumSize = 1024 } @@ -27,10 +30,12 @@ Configuration setToCustom Configuration setToSystemManaged { Import-DscResource -ModuleName ComputerManagementDsc - node "localhost" { + + node 'localhost' + { VirtualMemory vMem { - Type = 'SystemManagedSize' + Type = 'SystemManagedSize' Drive = 'C' } } @@ -39,10 +44,12 @@ Configuration setToSystemManaged Configuration setToNone { Import-DscResource -ModuleName ComputerManagementDsc - node "localhost" { + + node 'localhost' + { VirtualMemory vMem { - Type = 'NoPagingFile' + Type = 'NoPagingFile' Drive = 'C' } } diff --git a/tests/Integration/DSC_WindowsCapability.Config.ps1 b/tests/Integration/DSC_WindowsCapability.config.ps1 similarity index 80% rename from tests/Integration/DSC_WindowsCapability.Config.ps1 rename to tests/Integration/DSC_WindowsCapability.config.ps1 index 9f3dd265..1083ef78 100644 --- a/tests/Integration/DSC_WindowsCapability.Config.ps1 +++ b/tests/Integration/DSC_WindowsCapability.config.ps1 @@ -1,9 +1,10 @@ # Integration Test Config Template Version: 1.0.0 -configuration DSC_WindowsCapability_Config +Configuration DSC_WindowsCapability_Config { Import-DscResource -ModuleName ComputerManagementDsc - node $AllNodes.NodeName { + node $AllNodes.NodeName + { WindowsCapability TestInstallation { Name = $Node.Name diff --git a/tests/Integration/DSC_WindowsEventLog.config.ps1 b/tests/Integration/DSC_WindowsEventLog.config.ps1 index 50b53f8b..6e090a97 100644 --- a/tests/Integration/DSC_WindowsEventLog.config.ps1 +++ b/tests/Integration/DSC_WindowsEventLog.config.ps1 @@ -1,5 +1,5 @@ # Integration Test Config Template Version: 1.0.0 -configuration DSC_WindowsEventLog_Default +Configuration DSC_WindowsEventLog_Default { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -16,7 +16,7 @@ configuration DSC_WindowsEventLog_Default } } -configuration DSC_WindowsEventLog_RetainSize +Configuration DSC_WindowsEventLog_RetainSize { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -31,22 +31,22 @@ configuration DSC_WindowsEventLog_RetainSize } } -configuration DSC_WindowsEventLog_AutobackupLogRetention +Configuration DSC_WindowsEventLog_AutobackupLogRetention { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' { WindowsEventLog Integration_Test { - LogName = 'Application' - IsEnabled = $true - LogMode = 'AutoBackup' - LogRetentionDays = '30' + LogName = 'Application' + IsEnabled = $true + LogMode = 'AutoBackup' + LogRetentionDays = '30' } } } -configuration DSC_WindowsEventLog_CircularLogPath +Configuration DSC_WindowsEventLog_CircularLogPath { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -62,7 +62,7 @@ configuration DSC_WindowsEventLog_CircularLogPath } } -configuration DSC_WindowsEventLog_EnableLog +Configuration DSC_WindowsEventLog_EnableLog { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -77,20 +77,20 @@ configuration DSC_WindowsEventLog_EnableLog } } -configuration DSC_WindowsEventLog_DisableLog +Configuration DSC_WindowsEventLog_DisableLog { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' { WindowsEventLog Integration_Test { - LogName = 'Microsoft-Windows-CAPI2/Operational' - IsEnabled = $false + LogName = 'Microsoft-Windows-CAPI2/Operational' + IsEnabled = $false } } } -configuration DSC_WindowsEventLog_CircularSecurityDescriptor +Configuration DSC_WindowsEventLog_CircularSecurityDescriptor { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' @@ -106,30 +106,30 @@ configuration DSC_WindowsEventLog_CircularSecurityDescriptor } } -configuration DSC_WindowsEventLog_EnableBackupLog +Configuration DSC_WindowsEventLog_EnableBackupLog { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' { WindowsEventLog Integration_Test { - LogName = 'Microsoft-Windows-Backup' - IsEnabled = $true - LogMode = 'AutoBackup' - LogRetentionDays = '30' + LogName = 'Microsoft-Windows-Backup' + IsEnabled = $true + LogMode = 'AutoBackup' + LogRetentionDays = '30' } } } -configuration DSC_WindowsEventLog_DisableBackupLog +Configuration DSC_WindowsEventLog_DisableBackupLog { Import-DscResource -ModuleName ComputerManagementDsc node 'localhost' { WindowsEventLog Integration_Test { - LogName = 'Microsoft-Windows-Backup' - IsEnabled = $false + LogName = 'Microsoft-Windows-Backup' + IsEnabled = $false } } } diff --git a/tests/Unit/ComputerManagementDsc.Common.Tests.ps1 b/tests/Unit/ComputerManagementDsc.Common.Tests.ps1 index d2d2538f..3a16ab5c 100644 --- a/tests/Unit/ComputerManagementDsc.Common.Tests.ps1 +++ b/tests/Unit/ComputerManagementDsc.Common.Tests.ps1 @@ -3,10 +3,12 @@ $script:projectPath = "$PSScriptRoot\..\.." | Convert-Path $script:projectName = (Get-ChildItem -Path "$script:projectPath\*\*.psd1" | Where-Object -FilterScript { ($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and $(try - { Test-ModuleManifest -Path $_.FullName -ErrorAction Stop + { + Test-ModuleManifest -Path $_.FullName -ErrorAction Stop } catch - { $false + { + $false }) }).BaseName @@ -1074,8 +1076,8 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Get-TimeZone' - } + $Name -eq 'Get-TimeZone' + } Mock -CommandName Get-CimInstance -MockWith { @{ @@ -1091,8 +1093,8 @@ InModuleScope $script:subModuleName { Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Get-TimeZone' - } -Exactly -Times 1 + $Name -eq 'Get-TimeZone' + } -Exactly -Times 1 Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 } @@ -1102,8 +1104,8 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Get-TimeZone' - } + $Name -eq 'Get-TimeZone' + } Mock -CommandName Get-CimInstance -MockWith { @{ @@ -1119,8 +1121,8 @@ InModuleScope $script:subModuleName { Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Get-TimeZone' - } -Exactly -Times 1 + $Name -eq 'Get-TimeZone' + } -Exactly -Times 1 Assert-MockCalled -CommandName Get-CimInstance -Exactly -Times 1 } @@ -1134,18 +1136,18 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Get-TimeZone' - } -MockWith { - 'Get-TimeZone' - } + $Name -eq 'Get-TimeZone' + } -MockWith { + 'Get-TimeZone' + } Mock ` -CommandName Get-TimeZone ` -MockWith { - @{ - StandardName = 'Pacific Standard Time' - } + @{ + StandardName = 'Pacific Standard Time' } + } It 'Returns "Pacific Standard Time"' { Get-TimeZoneId | Should -Be 'Pacific Standard Time' @@ -1155,8 +1157,8 @@ InModuleScope $script:subModuleName { Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Get-TimeZone' - } -Exactly -Times 1 + $Name -eq 'Get-TimeZone' + } -Exactly -Times 1 Assert-MockCalled -CommandName Get-TimeZone -Exactly -Times 1 } @@ -1186,14 +1188,14 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Add-Type' - } + $Name -eq 'Add-Type' + } Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Set-TimeZone' - } + $Name -eq 'Set-TimeZone' + } Mock -CommandName 'TzUtil.exe' -MockWith { $global:LASTEXITCODE = 0 @@ -1210,14 +1212,14 @@ InModuleScope $script:subModuleName { Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Add-Type' - } -Exactly -Times 1 + $Name -eq 'Add-Type' + } -Exactly -Times 1 Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Set-TimeZone' - } -Exactly -Times 1 + $Name -eq 'Set-TimeZone' + } -Exactly -Times 1 Assert-MockCalled -CommandName TzUtil.exe -Exactly -Times 1 Assert-MockCalled -CommandName Add-Type -Exactly -Times 0 @@ -1228,16 +1230,16 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Add-Type' - } -MockWith { - 'Add-Type' - } + $Name -eq 'Add-Type' + } -MockWith { + 'Add-Type' + } Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Set-TimeZone' - } + $Name -eq 'Set-TimeZone' + } Mock -CommandName 'TzUtil.exe' -MockWith { $global:LASTEXITCODE = 0 @@ -1255,14 +1257,14 @@ InModuleScope $script:subModuleName { Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Add-Type' - } -Exactly -Times 1 + $Name -eq 'Add-Type' + } -Exactly -Times 1 Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Set-TimeZone' - } -Exactly -Times 1 + $Name -eq 'Set-TimeZone' + } -Exactly -Times 1 Assert-MockCalled -CommandName TzUtil.exe -Exactly -Times 0 Assert-MockCalled -CommandName Add-Type -Exactly -Times 0 @@ -1283,16 +1285,16 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Add-Type' - } + $Name -eq 'Add-Type' + } Mock ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Set-TimeZone' - } -MockWith { - 'Set-TimeZone' - } + $Name -eq 'Set-TimeZone' + } -MockWith { + 'Set-TimeZone' + } Mock -CommandName Set-TimeZone @@ -1304,14 +1306,14 @@ InModuleScope $script:subModuleName { Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Add-Type' - } -Exactly -Times 0 + $Name -eq 'Add-Type' + } -Exactly -Times 0 Assert-MockCalled ` -CommandName Get-Command ` -ParameterFilter { - $Name -eq 'Set-TimeZone' - } -Exactly -Times 1 + $Name -eq 'Set-TimeZone' + } -Exactly -Times 1 Assert-MockCalled -CommandName Set-TimeZone -Exactly -Times 1 } @@ -1330,16 +1332,16 @@ InModuleScope $script:subModuleName { } $mockPowerSaverPowerPlan = @{ - 'FriendlyName' = 'Power saver' - 'Guid' = [System.Guid]'a1841308-3541-4fab-bc81-f71556f20b4a' + 'FriendlyName' = 'Power saver' + 'Guid' = [System.Guid]'a1841308-3541-4fab-bc81-f71556f20b4a' } Context 'Only one power plan is available and "PowerPlan" parameter is not specified' { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return $mockBalancedPowerPlan - } + return $mockBalancedPowerPlan + } It 'Should not throw an exception' { { Get-PowerPlan } | Should -Not -Throw @@ -1363,8 +1365,8 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return $mockBalancedPowerPlan - } + return $mockBalancedPowerPlan + } It 'Should not throw an exception' { { Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e' } | Should -Not -Throw @@ -1389,8 +1391,8 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return $mockBalancedPowerPlan - } + return $mockBalancedPowerPlan + } It 'Should not throw an exception' { { Get-PowerPlan -PowerPlan '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } | Should -Not -Throw @@ -1412,8 +1414,8 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return $mockBalancedPowerPlan - } + return $mockBalancedPowerPlan + } It 'Should not throw an exception' { { Get-PowerPlan -PowerPlan 'Balanced' } | Should -Not -Throw @@ -1438,8 +1440,8 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return $mockBalancedPowerPlan - } + return $mockBalancedPowerPlan + } It 'Should not throw an exception' { { Get-PowerPlan -PowerPlan 'High performance' } | Should -Not -Throw @@ -1461,12 +1463,12 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) + } It 'Should not throw an exception' { { Get-PowerPlan } | Should -Not -Throw @@ -1488,15 +1490,15 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) + } It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e'} | Should -Not -Throw + { Get-PowerPlan -PowerPlan '381b4222-f694-41f0-9685-ff5bb260df2e' } | Should -Not -Throw } It 'Should call expected mocks' { @@ -1518,15 +1520,15 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) + } It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan '9c5e7fda-e8bf-4a96-9a85-a7e23a8c635c'} | Should -Not -Throw + { Get-PowerPlan -PowerPlan '9c5e7fda-e8bf-4a96-9a85-a7e23a8c635c' } | Should -Not -Throw } It 'Should call expected mocks' { @@ -1545,15 +1547,15 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) + } It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan 'High performance'} | Should -Not -Throw + { Get-PowerPlan -PowerPlan 'High performance' } | Should -Not -Throw } It 'Should call expected mocks' { @@ -1575,15 +1577,15 @@ InModuleScope $script:subModuleName { Mock ` -CommandName Get-PowerPlanUsingPInvoke ` -MockWith { - return @( - $mockBalancedPowerPlan - $mockHighPerformancePowerPlan - $mockPowerSaverPowerPlan - ) - } + return @( + $mockBalancedPowerPlan + $mockHighPerformancePowerPlan + $mockPowerSaverPowerPlan + ) + } It 'Should not throw an exception' { - { Get-PowerPlan -PowerPlan 'Some unavailable plan'} | Should -Not -Throw + { Get-PowerPlan -PowerPlan 'Some unavailable plan' } | Should -Not -Throw } It 'Should call expected mocks' { diff --git a/tests/Unit/DSC_Computer.Tests.ps1 b/tests/Unit/DSC_Computer.Tests.ps1 index daf37bac..97d7c5f6 100644 --- a/tests/Unit/DSC_Computer.Tests.ps1 +++ b/tests/Unit/DSC_Computer.Tests.ps1 @@ -742,10 +742,10 @@ try } { Set-TargetResource ` - -Name $notComputerName ` - -DomainName 'Contoso.com' ` - -JoinOU 'OU=Computers,DC=contoso,DC=com' ` - -Credential $credential + -Name $notComputerName ` + -DomainName 'Contoso.com' ` + -JoinOU 'OU=Computers,DC=contoso,DC=com' ` + -Credential $credential } | Should -Throw $error Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It @@ -785,7 +785,7 @@ try Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $DomainName -and $NewName } Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It -ParameterFilter { $WorkGroupName } - } + } It 'Changes ComputerName and changes Workgroup to new Workgroup' { Mock -CommandName Get-WMIObject -MockWith { diff --git a/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 b/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 index c7b71106..f4503b88 100644 --- a/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 +++ b/tests/Unit/DSC_OfflineDomainJoin.Tests.ps1 @@ -43,8 +43,8 @@ try $result = Get-TargetResource ` @TestOfflineDomainJoin - $result.IsSingleInstance | Should -Be $testOfflineDomainJoin.IsSingleInstance - $result.RequestFile | Should -Be '' + $result.IsSingleInstance | Should -Be $testOfflineDomainJoin.IsSingleInstance + $result.RequestFile | Should -Be '' } } diff --git a/tests/Unit/DSC_PendingReboot.Tests.ps1 b/tests/Unit/DSC_PendingReboot.Tests.ps1 index f18649ac..dc55587a 100644 --- a/tests/Unit/DSC_PendingReboot.Tests.ps1 +++ b/tests/Unit/DSC_PendingReboot.Tests.ps1 @@ -516,8 +516,8 @@ try Mock -CommandName Get-PendingRebootHashTable ` -MockWith { - $getPendingRebootStateMock - } ` + $getPendingRebootStateMock + } ` -ModuleName 'DSC_PendingReboot' ` -Verifiable } @@ -549,8 +549,8 @@ try Mock -CommandName Get-PendingRebootHashTable ` -MockWith { - $getPendingRebootStateMock - } ` + $getPendingRebootStateMock + } ` -ModuleName 'DSC_PendingReboot' ` -Verifiable } @@ -579,8 +579,8 @@ try Mock -CommandName Get-PendingRebootHashTable ` -MockWith { - $getPendingRebootStateMock - } ` + $getPendingRebootStateMock + } ` -ModuleName 'DSC_PendingReboot' ` -Verifiable } diff --git a/tests/Unit/DSC_PowerPlan.Tests.ps1 b/tests/Unit/DSC_PowerPlan.Tests.ps1 index d1a5586c..9c6e9fc4 100644 --- a/tests/Unit/DSC_PowerPlan.Tests.ps1 +++ b/tests/Unit/DSC_PowerPlan.Tests.ps1 @@ -52,18 +52,18 @@ try Mock ` -CommandName Get-PowerPlan ` -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` -Verifiable Mock ` -CommandName Get-ActivePowerPlan ` -MockWith { - return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } ` + return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } ` -Verifiable } @@ -86,18 +86,18 @@ try Mock ` -CommandName Get-PowerPlan ` -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` -Verifiable Mock ` -CommandName Get-ActivePowerPlan ` -MockWith { - return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' - } ` + return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' + } ` -Verifiable } @@ -146,11 +146,11 @@ try Mock ` -CommandName Get-PowerPlan ` -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` -Verifiable Mock ` @@ -185,15 +185,15 @@ try -Exactly ` -Times 1 ` -Scope It ` - -ParameterFilter {$PowerPlanGuid -eq '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c'} + -ParameterFilter { $PowerPlanGuid -eq '8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' } } } Context 'When the preferred plan does not exist' { BeforeEach { Mock ` - -CommandName Get-PowerPlan ` - -Verifiable + -CommandName Get-PowerPlan ` + -Verifiable } It 'Should throw the expected error (power plan specified as )' -TestCases $testCases { @@ -219,18 +219,18 @@ try Mock ` -CommandName Get-PowerPlan ` -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` -Verifiable Mock ` -CommandName Get-ActivePowerPlan ` -MockWith { - return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } ` + return [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } ` -Verifiable } @@ -251,18 +251,18 @@ try Mock ` -CommandName Get-PowerPlan ` -MockWith { - return @{ - FriendlyName = 'High performance' - Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' - } - } ` + return @{ + FriendlyName = 'High performance' + Guid = [System.Guid]'8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c' + } + } ` -Verifiable Mock ` -CommandName Get-ActivePowerPlan ` -MockWith { - return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' - } ` + return [System.Guid]'381b4222-f694-41f0-9685-ff5bb260df2e' + } ` -Verifiable } diff --git a/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 b/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 index 18a4508f..e56251b7 100644 --- a/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 +++ b/tests/Unit/DSC_RemoteDesktopAdmin.Tests.ps1 @@ -55,11 +55,11 @@ try It 'Should return the correct values when Ensure is Present' { Mock -CommandName Get-ItemProperty ` -ParameterFilter { $Name -eq 'fDenyTSConnections' } ` - -MockWith { @{fDenyTSConnections = 0} } + -MockWith { @{fDenyTSConnections = 0 } } Mock -CommandName Get-ItemProperty ` -ParameterFilter { $Name -eq 'UserAuthentication' } ` - -MockWith { @{UserAuthentication = 0} } + -MockWith { @{UserAuthentication = 0 } } $targetResource = Get-TargetResource -IsSingleInstance 'Yes' $targetResource.Ensure | Should -Be 'Present' @@ -68,11 +68,11 @@ try It 'Should return the correct values when Ensure is Absent' { Mock -CommandName Get-ItemProperty ` -ParameterFilter { $Name -eq 'fDenyTSConnections' } ` - -MockWith { @{fDenyTSConnections = 1} } + -MockWith { @{fDenyTSConnections = 1 } } Mock -CommandName Get-ItemProperty ` -ParameterFilter { $Name -eq 'UserAuthentication' } ` - -MockWith { @{UserAuthentication = 0} } + -MockWith { @{UserAuthentication = 0 } } $targetResource = Get-TargetResource -IsSingleInstance 'Yes' $targetResource.Ensure | Should -Be 'Absent' @@ -81,11 +81,11 @@ try It 'Should return the correct values when UserAuthentication is NonSecure' { Mock -CommandName Get-ItemProperty ` -ParameterFilter { $Name -eq 'fDenyTSConnections' } ` - -MockWith { @{fDenyTSConnections = 0} } + -MockWith { @{fDenyTSConnections = 0 } } Mock -CommandName Get-ItemProperty ` -ParameterFilter { $Name -eq 'UserAuthentication' } ` - -MockWith { @{UserAuthentication = 0} } ` + -MockWith { @{UserAuthentication = 0 } } ` $result = Get-TargetResource -IsSingleInstance 'Yes' $result.UserAuthentication | Should -Be 'NonSecure' @@ -94,11 +94,11 @@ try It 'Should return the correct values when UserAuthentication is Secure' { Mock -CommandName Get-ItemProperty ` -ParameterFilter { $Name -eq 'fDenyTSConnections' } ` - -MockWith { @{fDenyTSConnections = 0} } + -MockWith { @{fDenyTSConnections = 0 } } Mock -CommandName Get-ItemProperty ` -ParameterFilter { $Name -eq 'UserAuthentication' } ` - -MockWith { @{UserAuthentication = 1} } ` + -MockWith { @{UserAuthentication = 1 } } ` $result = Get-TargetResource -IsSingleInstance 'Yes' $result.UserAuthentication | Should -Be 'Secure' diff --git a/tests/Unit/DSC_ScheduledTask.Tests.ps1 b/tests/Unit/DSC_ScheduledTask.Tests.ps1 index ee474602..f2c6d5ff 100644 --- a/tests/Unit/DSC_ScheduledTask.Tests.ps1 +++ b/tests/Unit/DSC_ScheduledTask.Tests.ps1 @@ -98,8 +98,8 @@ try Mock -CommandName Unregister-ScheduledTask $getTargetResourceParameters = @{ - TaskName = 'Test task' - TaskPath = '\Test\' + TaskName = 'Test task' + TaskPath = '\Test\' } } @@ -176,8 +176,8 @@ try Context 'A built-in scheduled task exists and is enabled, but it should be disabled' { $testParameters = $getTargetResourceParameters + @{ - Enable = $false - Verbose = $true + Enable = $false + Verbose = $true } Mock -CommandName Get-ScheduledTask -MockWith { @@ -219,8 +219,8 @@ try Context 'A built-in scheduled task exists, but it should be absent' { $testParameters = $getTargetResourceParameters + @{ - Ensure = 'Absent' - Verbose = $true + Ensure = 'Absent' + Verbose = $true } Mock -CommandName Get-ScheduledTask -MockWith { @@ -981,8 +981,8 @@ try Settings = [pscustomobject] @{ Enabled = $true IdleSettings = @{ - WaitTimeout = "PT$([System.TimeSpan]::Parse($testParameters.IdleWaitTimeout).TotalMinutes)M" - IdleDuration = "PT$([System.TimeSpan]::Parse($testParameters.IdleDuration).TotalMinutes)M" + WaitTimeout = "PT$([System.TimeSpan]::Parse($testParameters.IdleWaitTimeout).TotalMinutes)M" + IdleDuration = "PT$([System.TimeSpan]::Parse($testParameters.IdleDuration).TotalMinutes)M" } ExecutionTimeLimit = "PT$([System.TimeSpan]::Parse($testParameters.ExecutionTimeLimit).TotalMinutes)M" RestartInterval = "PT$([System.TimeSpan]::Parse($testParameters.RestartInterval).TotalMinutes)M" @@ -1159,23 +1159,23 @@ try Context 'A scheduled task path is root or custom' -Fixture { It 'Should return backslash' { - ConvertTo-NormalizedTaskPath -TaskPath '\'| Should -Be '\' + ConvertTo-NormalizedTaskPath -TaskPath '\' | Should -Be '\' } It 'Should add backslash at the end' { - ConvertTo-NormalizedTaskPath -TaskPath '\Test'| Should -Be '\Test\' + ConvertTo-NormalizedTaskPath -TaskPath '\Test' | Should -Be '\Test\' } It 'Should add backslash at the beginning' { - ConvertTo-NormalizedTaskPath -TaskPath 'Test\'| Should -Be '\Test\' + ConvertTo-NormalizedTaskPath -TaskPath 'Test\' | Should -Be '\Test\' } It 'Should add backslash at the beginning and at the end' { - ConvertTo-NormalizedTaskPath -TaskPath 'Test'| Should -Be '\Test\' + ConvertTo-NormalizedTaskPath -TaskPath 'Test' | Should -Be '\Test\' } It 'Should not add backslash' { - ConvertTo-NormalizedTaskPath -TaskPath '\Test\'| Should -Be '\Test\' + ConvertTo-NormalizedTaskPath -TaskPath '\Test\' | Should -Be '\Test\' } } @@ -1217,8 +1217,8 @@ try ) Settings = [pscustomobject] @{ IdleSettings = @{ - WaitTimeout = "PT$([System.TimeSpan]::Parse($testParameters.IdleWaitTimeout).TotalMinutes)M" - IdleDuration = "PT$([System.TimeSpan]::Parse($testParameters.IdleDuration).TotalMinutes)M" + WaitTimeout = "PT$([System.TimeSpan]::Parse($testParameters.IdleWaitTimeout).TotalMinutes)M" + IdleDuration = "PT$([System.TimeSpan]::Parse($testParameters.IdleDuration).TotalMinutes)M" } ExecutionTimeLimit = "PT$([System.TimeSpan]::Parse($testParameters.ExecutionTimeLimit).TotalMinutes)M" RestartInterval = "PT$([System.TimeSpan]::Parse($testParameters.RestartInterval).TotalMinutes)M" @@ -1282,8 +1282,8 @@ try ) Settings = [pscustomobject] @{ IdleSettings = @{ - WaitTimeout = "PT$([System.TimeSpan]::Parse($testParameters.IdleWaitTimeout).TotalMinutes + 1)M" - IdleDuration = "PT$([System.TimeSpan]::Parse($testParameters.IdleDuration).TotalMinutes + 1)M" + WaitTimeout = "PT$([System.TimeSpan]::Parse($testParameters.IdleWaitTimeout).TotalMinutes + 1)M" + IdleDuration = "PT$([System.TimeSpan]::Parse($testParameters.IdleDuration).TotalMinutes + 1)M" } ExecutionTimeLimit = "PT$([System.TimeSpan]::Parse($testParameters.ExecutionTimeLimit).TotalMinutes)M" RestartInterval = "PT$([System.TimeSpan]::Parse($testParameters.RestartInterval).TotalMinutes)M" @@ -1459,8 +1459,8 @@ try Context 'When a built-in scheduled task exists and is enabled, but it should be disabled and the trigger type is not recognized' { $testParameters = $getTargetResourceParameters + @{ - Enable = $false - Verbose = $true + Enable = $false + Verbose = $true } Mock -CommandName Get-ScheduledTask -MockWith { @@ -1520,9 +1520,9 @@ try Execute = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' } Triggers = [pscustomobject] @{ - Delay = 'PT1M' + Delay = 'PT1M' Subscription = $testParameters.EventSubscription - CimClass = @{ + CimClass = @{ CimClassName = 'MSFT_TaskEventTrigger' } } @@ -1591,9 +1591,9 @@ try Execute = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' } Triggers = [pscustomobject] @{ - Delay = 'PT1M' + Delay = 'PT1M' Subscription = '' - CimClass = @{ + CimClass = @{ CimClassName = 'MSFT_TaskEventTrigger' } } @@ -1644,9 +1644,9 @@ try Execute = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' } Triggers = [pscustomobject] @{ - Delay = 'PT1M' + Delay = 'PT1M' Subscription = $testParameters.EventSubscription - CimClass = @{ + CimClass = @{ CimClassName = 'MSFT_TaskEventTrigger' } } @@ -1723,7 +1723,7 @@ try } ) Principal = [pscustomobject] @{ - UserId = $testParameters.BuiltInAccount + UserId = $testParameters.BuiltInAccount LogonType = 'ServiceAccount' } } @@ -1761,7 +1761,7 @@ try It 'Should call Register-ScheduledTask with the name of the Group Managed Service Account' { Set-TargetResource @testParameters Assert-MockCalled -CommandName Register-ScheduledTask -Times 1 -Scope It -ParameterFilter { - $User -eq $null -and $Inputobject.Principal.UserId -eq $testParameters.ExecuteAsGMSA + $User -eq $null -and $Inputobject.Principal.UserId -eq $testParameters.ExecuteAsGMSA } } @@ -1811,12 +1811,12 @@ try Context 'When a scheduled task Group Managed Service Account is changed' { $testParameters = $getTargetResourceParameters + @{ - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'Once' - RepeatInterval = (New-TimeSpan -Minutes 15).ToString() - RepetitionDuration = (New-TimeSpan -Hours 8).ToString() - ExecuteAsGMSA = 'DOMAIN\gMSA$' - Verbose = $true + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'Once' + RepeatInterval = (New-TimeSpan -Minutes 15).ToString() + RepetitionDuration = (New-TimeSpan -Hours 8).ToString() + ExecuteAsGMSA = 'DOMAIN\gMSA$' + Verbose = $true } Mock -CommandName Get-ScheduledTask -MockWith { @@ -1865,7 +1865,7 @@ try } Context 'When a scheduled task is created and synchronize across time zone is disabled' { - $startTimeString = '2018-10-01T01:00:00' + $startTimeString = '2018-10-01T01:00:00' $startTimeStringWithOffset = '2018-10-01T01:00:00' + (Get-Date -Format 'zzz') $testParameters = $getTargetResourceParameters + @{ ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' @@ -1877,14 +1877,14 @@ try Mock -CommandName Get-ScheduledTask -MockWith { @{ - TaskName = $testParameters.TaskName - TaskPath = $testParameters.TaskPath - Actions = @( + TaskName = $testParameters.TaskName + TaskPath = $testParameters.TaskPath + Actions = @( [pscustomobject] @{ Execute = $testParameters.ActionExecutable } ) - Triggers = @( + Triggers = @( [pscustomobject] @{ StartBoundary = $startTimeString CimClass = @{ @@ -1907,14 +1907,14 @@ try Mock -CommandName Get-ScheduledTask -MockWith { @{ - TaskName = $testParameters.TaskName - TaskPath = $testParameters.TaskPath - Actions = @( + TaskName = $testParameters.TaskName + TaskPath = $testParameters.TaskPath + Actions = @( [pscustomobject] @{ Execute = $testParameters.ActionExecutable } ) - Triggers = @( + Triggers = @( [pscustomobject] @{ StartBoundary = $startTimeStringWithOffset CimClass = @{ @@ -1939,7 +1939,7 @@ try } Context 'When a scheduled task is created and synchronize across time zone is enabled' { - $startTimeString = '2018-10-01T01:00:00' + $startTimeString = '2018-10-01T01:00:00' $startTimeStringWithOffset = '2018-10-01T01:00:00' + (Get-Date -Format 'zzz') $testParameters = $getTargetResourceParameters + @{ ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' @@ -1951,14 +1951,14 @@ try Mock -CommandName Get-ScheduledTask -MockWith { @{ - TaskName = $testParameters.TaskName - TaskPath = $testParameters.TaskPath - Actions = @( + TaskName = $testParameters.TaskName + TaskPath = $testParameters.TaskPath + Actions = @( [pscustomobject] @{ Execute = $testParameters.ActionExecutable } ) - Triggers = @( + Triggers = @( [pscustomobject] @{ StartBoundary = $startTimeStringWithOffset CimClass = @{ @@ -1981,14 +1981,14 @@ try Mock -CommandName Get-ScheduledTask -MockWith { @{ - TaskName = $testParameters.TaskName - TaskPath = $testParameters.TaskPath - Actions = @( + TaskName = $testParameters.TaskName + TaskPath = $testParameters.TaskPath + Actions = @( [pscustomobject] @{ Execute = $testParameters.ActionExecutable } ) - Triggers = @( + Triggers = @( [pscustomobject] @{ StartBoundary = $startTimeString CimClass = @{ @@ -2013,7 +2013,7 @@ try } Context 'When a scheduled task is configured to SynchronizeAcrossTimeZone and the ScheduleType is not Once, Daily or Weekly' { - $startTimeString = '2018-10-01T01:00:00' + $startTimeString = '2018-10-01T01:00:00' $testParameters = $getTargetResourceParameters + @{ ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' StartTime = Get-Date -Date $startTimeString @@ -2030,26 +2030,26 @@ try Context 'When a scheduled task is configured with the ScheduleType AtLogon and is in desired state' { $startTimeString = '2018-10-01T01:00:00' $testParameters = $getTargetResourceParameters + @{ - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - StartTime = Get-Date -Date $startTimeString - ScheduleType = 'AtLogon' - Delay = '00:01:00' - Enable = $true - Verbose = $true + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + StartTime = Get-Date -Date $startTimeString + ScheduleType = 'AtLogon' + Delay = '00:01:00' + Enable = $true + Verbose = $true } Mock -CommandName Get-ScheduledTask -MockWith { @{ - TaskName = $testParameters.TaskName - TaskPath = $testParameters.TaskPath - Actions = @( + TaskName = $testParameters.TaskName + TaskPath = $testParameters.TaskPath + Actions = @( [pscustomobject] @{ Execute = $testParameters.ActionExecutable } ) - Triggers = @( + Triggers = @( [pscustomobject] @{ - Delay = 'PT1M' + Delay = 'PT1M' StartBoundary = $startTimeString CimClass = @{ CimClassName = 'MSFT_TaskLogonTrigger' @@ -2078,25 +2078,25 @@ try Context 'When a scheduled task is configured with the ScheduleType AtStartup and is in desired state' { $testParameters = $getTargetResourceParameters + @{ - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'AtStartup' - Delay = '00:01:00' - Enable = $true - Verbose = $true + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'AtStartup' + Delay = '00:01:00' + Enable = $true + Verbose = $true } Mock -CommandName Get-ScheduledTask -MockWith { @{ - TaskName = $testParameters.TaskName - TaskPath = $testParameters.TaskPath - Actions = @( + TaskName = $testParameters.TaskName + TaskPath = $testParameters.TaskPath + Actions = @( [pscustomobject] @{ Execute = $testParameters.ActionExecutable } ) - Triggers = @( + Triggers = @( [pscustomobject] @{ - Delay = 'PT1M' + Delay = 'PT1M' StartBoundary = '' CimClass = @{ CimClassName = 'MSFT_TaskBootTrigger' @@ -2128,12 +2128,12 @@ try https://github.com/dsccommunity/ComputerManagementDsc/issues/258 #> $testParameters = $getTargetResourceParameters + @{ - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - Description = "`t`n`r test description `t`n`r" - ScheduleType = 'AtStartup' - Delay = '00:01:00' - Enable = $true - Verbose = $true + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + Description = "`t`n`r test description `t`n`r" + ScheduleType = 'AtStartup' + Delay = '00:01:00' + Enable = $true + Verbose = $true } Mock -CommandName Get-ScheduledTask -MockWith { @@ -2141,21 +2141,21 @@ try TaskName = $testParameters.TaskName TaskPath = $testParameters.TaskPath Description = 'test description' - Actions = @( + Actions = @( [pscustomobject] @{ Execute = $testParameters.ActionExecutable } ) - Triggers = @( + Triggers = @( [pscustomobject] @{ - Delay = 'PT1M' + Delay = 'PT1M' StartBoundary = '' CimClass = @{ CimClassName = 'MSFT_TaskBootTrigger' } } ) - Settings = [pscustomobject] @{ + Settings = [pscustomobject] @{ Enabled = $testParameters.Enable } } diff --git a/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 b/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 index 04eec0c6..0361ecc6 100644 --- a/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 +++ b/tests/Unit/DSC_SmbServerConfiguration.Tests.ps1 @@ -342,7 +342,7 @@ try $SmbServerConfiguration.ValidateAliasNotCircular | Should -Not -BeNullOrEmpty $SmbServerConfiguration.ValidateShareScope | Should -Not -BeNullOrEmpty $SmbServerConfiguration.ValidateShareScopeNotAliased | Should -Not -BeNullOrEmpty - $SmbServerConfiguration.ValidateTargetName| Should -Not -BeNullOrEmpty + $SmbServerConfiguration.ValidateTargetName | Should -Not -BeNullOrEmpty } } } diff --git a/tests/Unit/DSC_SmbShare.Tests.ps1 b/tests/Unit/DSC_SmbShare.Tests.ps1 index 922dae46..af2fbd01 100644 --- a/tests/Unit/DSC_SmbShare.Tests.ps1 +++ b/tests/Unit/DSC_SmbShare.Tests.ps1 @@ -343,8 +343,8 @@ try Context 'When the share exists, but on the wrong path and recreate is allowed' { Mock -CommandName Get-TargetResource -MockWith { return @{ - Name = $mockSmbShare.Name - Path = $mockSmbShare.Path + Name = $mockSmbShare.Name + Path = $mockSmbShare.Path Ensure = 'Present' } } @@ -365,8 +365,8 @@ try Context 'When the share exists, but on the wrong path and recreate is not allowed' { Mock -CommandName Get-TargetResource -MockWith { return @{ - Name = $mockSmbShare.Name - Path = $mockSmbShare.Path + Name = $mockSmbShare.Name + Path = $mockSmbShare.Path Ensure = 'Present' } } @@ -388,18 +388,18 @@ try Context 'When the share exists, but on the wrong scope and recreate is allowed' { Mock -CommandName Get-TargetResource -MockWith { return @{ - Name = $mockSmbShare.Name - Path = $mockSmbShare.Path + Name = $mockSmbShare.Name + Path = $mockSmbShare.Path ScopeName = $mockSmbShare.ScopeName - Ensure = 'Present' + Ensure = 'Present' } } $setTargetResourceParameters = @{ - Name = $mockSmbShare.Name - Path = $mockSmbShare.Path + Name = $mockSmbShare.Name + Path = $mockSmbShare.Path ScopeName = 'clustergroup1' - Force = $true + Force = $true } It 'Should drop and recreate the share' { @@ -412,18 +412,18 @@ try Context 'When the share exists, but on the wrong scope and recreate is not allowed' { Mock -CommandName Get-TargetResource -MockWith { return @{ - Name = $mockSmbShare.Name - Path = $mockSmbShare.Path + Name = $mockSmbShare.Name + Path = $mockSmbShare.Path ScopeName = $mockSmbShare.ScopeName - Ensure = 'Present' + Ensure = 'Present' } } $setTargetResourceParameters = @{ - Name = $mockSmbShare.Name - Path = $mockSmbShare.Path + Name = $mockSmbShare.Name + Path = $mockSmbShare.Path ScopeName = 'clustergroup1' - Force = $false + Force = $false } It 'Should display a warning with the message the share cannot be updated' { @@ -441,14 +441,14 @@ try Context 'When no member are provided in any of the access permission collections' { BeforeAll { $testTargetResourceParameters = @{ - Name = $mockShareName - Path = 'TestDrive:\Temp' - FullAccess = @() - ChangeAccess = @() - ReadAccess = @() - NoAccess = @() - Ensure = 'Present' - Verbose = $true + Name = $mockShareName + Path = 'TestDrive:\Temp' + FullAccess = @() + ChangeAccess = @() + ReadAccess = @() + NoAccess = @() + Ensure = 'Present' + Verbose = $true } } From c87bf562f7b46778262afcbf1754f12aa56935a0 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 31 Jan 2020 18:56:20 +1300 Subject: [PATCH 30/30] Changes as per PR comments part 2 --- tests/Integration/ComputerManagementDsc.Common.Tests.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Integration/ComputerManagementDsc.Common.Tests.ps1 b/tests/Integration/ComputerManagementDsc.Common.Tests.ps1 index 33dfe358..c40aad94 100644 --- a/tests/Integration/ComputerManagementDsc.Common.Tests.ps1 +++ b/tests/Integration/ComputerManagementDsc.Common.Tests.ps1 @@ -3,10 +3,12 @@ $script:projectPath = "$PSScriptRoot\..\.." | Convert-Path $script:projectName = (Get-ChildItem -Path "$script:projectPath\*\*.psd1" | Where-Object -FilterScript { ($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and $(try - { Test-ModuleManifest -Path $_.FullName -ErrorAction Stop + { + Test-ModuleManifest -Path $_.FullName -ErrorAction Stop } catch - { $false + { + $false }) }).BaseName