From 1451eb9102f771d1649c88d8a90437d4146fcd0d Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Sun, 17 Feb 2019 12:12:46 +1300 Subject: [PATCH] Converted Examples to format required for Publishing --- .MetaTestOptIn.json | 4 +- CHANGELOG.md | 4 ++ .../ComputerManagementDsc.psd1 | 2 +- ...r_RenameComputerAndSetWorkgroup_Config.ps1 | 37 +++++++++++++ .../1-RenameComputerAndSetWorkgroup.ps1 | 25 --------- .../Computer/2-Computer_JoinDomain_Config.ps1 | 47 ++++++++++++++++ .../Resources/Computer/2-JoinDomain.ps1 | 32 ----------- ...Computer_RenameComputerInDomain_Config.ps1 | 47 ++++++++++++++++ .../Computer/3-RenameComputerInDomain.ps1 | 32 ----------- ...puter_RenameComputerInWorkgroup_Config.ps1 | 36 +++++++++++++ .../Computer/4-RenameComputerInWorkgroup.ps1 | 24 --------- ...er_UnjoinDomainAndJoinWorkgroup_Config.ps1 | 47 ++++++++++++++++ .../5-UnjoinDomainAndJoinWorkgroup.ps1 | 32 ----------- ...tComputerDescriptionInWorkgroup_Config.ps1 | 36 +++++++++++++ .../6-SetComputerDescriptionInWorkgroup.ps1 | 24 --------- ...Computer_JoinDomainSpecifyingDC_Config.ps1 | 48 +++++++++++++++++ .../Computer/7-JoinDomainSpecifyingDC.ps1 | 33 ------------ .../1-JoinDomainUsingODJBlob.ps1 | 25 --------- ...mainJoin_JoinDomainUsingODJBlob_Config.ps1 | 37 +++++++++++++ .../1-PowerPlan_SetPowerPlan_Config.ps1 | 36 +++++++++++++ .../Resources/PowerPlan/1-SetPowerPlan.ps1 | 24 --------- ...cy_SetPowerShellExecutionPolicy_Config.ps1 | 36 +++++++++++++ .../1-SetPowerShellExecutionPolicy.ps1 | 18 ------- ...xecutionPolicyForMultipleScopes_Config.ps1 | 42 +++++++++++++++ ...rshellExecutionPolicyForMultipleScopes.ps1 | 24 --------- .../1-CreateScheduledTaskOnce.ps1 | 40 -------------- ...ledTask_CreateScheduledTaskOnce_Config.ps1 | 52 ++++++++++++++++++ ...owerShellTaskOnceAsUserInteractiveOnly.ps1 | 38 ------------- ...llTaskOnceAsUserInteractiveOnly_Config.ps1 | 53 +++++++++++++++++++ .../ScheduledTask/11-DisableABuiltInTask.ps1 | 26 --------- ...heduledTask_DisableABuiltInTask_Config.ps1 | 38 +++++++++++++ .../ScheduledTask/12-DeleteABuiltInTask.ps1 | 26 --------- ...cheduledTask_DeleteABuiltInTask_Config.ps1 | 38 +++++++++++++ .../13-CreateScheduledTasksOnEvent.ps1 | 33 ------------ ...ask_CreateScheduledTasksOnEvent_Config.ps1 | 45 ++++++++++++++++ ...llTaskOnceAsGroupManagedServiceAccount.ps1 | 37 ------------- ...nceAsGroupManagedServiceAccount_Config.ps1 | 52 ++++++++++++++++++ ...skOnceSynchronizeAcrossTimeZoneEnabled.ps1 | 32 ----------- ...ynchronizeAcrossTimeZoneEnabled_Config.ps1 | 44 +++++++++++++++ .../2-CreateScheduledTaskDaily.ps1 | 37 ------------- ...edTask_CreateScheduledTaskDaily_Config.ps1 | 49 +++++++++++++++++ ...-CreateScheduledTasksDailyIndefinitely.ps1 | 31 ----------- ...ScheduledTasksDailyIndefinitely_Config.ps1 | 43 +++++++++++++++ .../4-CreateScheduledTasksWeekly.ps1 | 37 ------------- ...Task_CreateScheduledTasksWeekly_Config.ps1 | 49 +++++++++++++++++ .../5-CreateScheduledTasksAtLogon.ps1 | 30 ----------- ...ask_CreateScheduledTasksAtLogon_Config.ps1 | 42 +++++++++++++++ .../6-CreateScheduledTasksAtStartup.ps1 | 31 ----------- ...k_CreateScheduledTasksAtStartup_Config.ps1 | 42 +++++++++++++++ .../7-RunPowerShellTaskEvery15Minutes.ps1 | 30 ----------- ...RunPowerShellTaskEvery15Minutes_Config.ps1 | 42 +++++++++++++++ ...werShellTaskEvery15MinutesIndefinitely.ps1 | 30 ----------- ...lTaskEvery15MinutesIndefinitely_Config.ps1 | 42 +++++++++++++++ ...ellTaskOnceAsUserWithHighestPriveleges.ps1 | 38 ------------- ...OnceAsUserWithHighestPriveleges_Config.ps1 | 53 +++++++++++++++++++ .../Resources/TimeZone/1-SetTimeZone.ps1 | 25 --------- .../1-TimeZone_SetTimeZone_Config.ps1 | 37 +++++++++++++ .../VirtualMemory/1-SetVirtualMemory.ps1 | 27 ---------- ...-VirtualMemory_SetVirtualMemory_Config.ps1 | 39 ++++++++++++++ .../1-SetWindowsEventlogSize.ps1 | 27 ---------- ...Eventlog_SetWindowsEventlogSize_Config.ps1 | 39 ++++++++++++++ .../2-SetWindowsEventlogLogMode.ps1 | 29 ---------- ...ntlog_SetWindowsEventlogLogMode_Config.ps1 | 41 ++++++++++++++ .../3-EnableWindowsEventLog.ps1 | 28 ---------- ...sEventlog_EnableWindowsEventLog_Config.ps1 | 40 ++++++++++++++ .../4-SetWindowsEventlogLogMode.ps1 | 27 ---------- ...ntlog_SetWindowsEventlogLogMode_Config.ps1 | 39 ++++++++++++++ ...5-SetWindowsEventlogSecurityDescriptor.ps1 | 29 ---------- ...ndowsEventlogSecurityDescriptor_Config.ps1 | 41 ++++++++++++++ .../6-DisableWindowsEventlog.ps1 | 24 --------- ...Eventlog_DisableWindowsEventlog_Config.ps1 | 36 +++++++++++++ 71 files changed, 1453 insertions(+), 1007 deletions(-) create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/1-RenameComputerAndSetWorkgroup.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/2-JoinDomain.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/3-RenameComputerInDomain.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/4-RenameComputerInWorkgroup.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/5-UnjoinDomainAndJoinWorkgroup.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/6-SetComputerDescriptionInWorkgroup.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/Computer/7-JoinDomainSpecifyingDC.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-JoinDomainUsingODJBlob.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-SetPowerPlan.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPowerShellExecutionPolicy_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-SetPowerShellExecutionPolicy.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPowershellExecutionPolicyForMultipleScopes_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-SetPowershellExecutionPolicyForMultipleScopes.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-CreateScheduledTaskOnce.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-RunPowerShellTaskOnceAsUserInteractiveOnly.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-DisableABuiltInTask.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-DeleteABuiltInTask.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-CreateScheduledTasksOnEvent.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-RunPowerShellTaskOnceAsGroupManagedServiceAccount.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-CreateScheduledTaskDaily.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-CreateScheduledTasksDailyIndefinitely.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-CreateScheduledTasksWeekly.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-CreateScheduledTasksAtLogon.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-CreateScheduledTasksAtStartup.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-RunPowerShellTaskEvery15Minutes.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-RunPowerShellTaskEvery15MinutesIndefinitely.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-RunPowerShellTaskOnceAsUserWithHighestPriveleges.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-SetTimeZone.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-SetVirtualMemory.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-SetWindowsEventlogSize.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-SetWindowsEventlogLogMode.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-EnableWindowsEventLog.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-SetWindowsEventlogLogMode.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-SetWindowsEventlogSecurityDescriptor.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 delete mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-DisableWindowsEventlog.ps1 create mode 100644 Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json index 20cf7f9a..5ae00fae 100644 --- a/.MetaTestOptIn.json +++ b/.MetaTestOptIn.json @@ -2,5 +2,7 @@ "Common Tests - Validate Markdown Files", "Common Tests - Validate Example Files", "Common Tests - Validate Module Files", - "Common Tests - Validate Script Files" + "Common Tests - Validate Script Files", + "Common Tests - Validate Example Files To Be Published", + "Common Tests - Validate Markdown Links" ] diff --git a/CHANGELOG.md b/CHANGELOG.md index ceb88f49..b7f5b378 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ - 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 diff --git a/Modules/ComputerManagementDsc/ComputerManagementDsc.psd1 b/Modules/ComputerManagementDsc/ComputerManagementDsc.psd1 index 74c2da66..a00af1d8 100644 --- a/Modules/ComputerManagementDsc/ComputerManagementDsc.psd1 +++ b/Modules/ComputerManagementDsc/ComputerManagementDsc.psd1 @@ -12,7 +12,7 @@ Author = 'Microsoft Corporation' CompanyName = 'Microsoft Corporation' # Copyright statement for this module -Copyright = '(c) 2018 Microsoft Corporation. All rights reserved.' +Copyright = '(c) Microsoft Corporation. All rights reserved.' # Description of the functionality provided by this module Description = 'The ComputerManagementDsc module is originally part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit. This version has been modified for use in Azure. This module contains the xComputer and xDisk resources. These DSC Resources allow you to perform computer management tasks, like joining a domain or initializing disks. diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 new file mode 100644 index 00000000..b551ac12 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/Computer/1-Computer_RenameComputerAndSetWorkgroup_Config.ps1 @@ -0,0 +1,37 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 594bfeff-8e83-4cc4-8141-f3b39795c85b +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This configuration will set the computer name to 'Server01' + and make it part of 'ContosoWorkgroup' Workgroup. +#> +Configuration Computer_RenameComputerAndSetWorkgroup_Config +{ + Import-DscResource -Module ComputerManagementDsc + + Node localhost + { + Computer NewNameAndWorkgroup + { + Name = 'Server01' + WorkGroupName = 'ContosoWorkgroup' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/1-RenameComputerAndSetWorkgroup.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/1-RenameComputerAndSetWorkgroup.ps1 deleted file mode 100644 index 65046cf2..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/Computer/1-RenameComputerAndSetWorkgroup.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -<# - .EXAMPLE - This configuration will set the computer name to 'Server01' - and make it part of 'ContosoWorkgroup' Workgroup. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -Module ComputerManagementDsc - - Node $NodeName - { - Computer NewNameAndWorkgroup - { - Name = 'Server01' - WorkGroupName = 'ContosoWorkgroup' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 new file mode 100644 index 00000000..57aafc02 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/Computer/2-Computer_JoinDomain_Config.ps1 @@ -0,0 +1,47 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID a8b9b735-a13d-4901-8edd-a2eb3a589183 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This configuration sets the machine name to 'Server01' and + joins the 'Contoso' domain. + Note: this requires an AD credential to join the domain. +#> +Configuration Computer_JoinDomain_Config +{ + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullorEmpty()] + [System.Management.Automation.PSCredential] + $Credential + ) + + Import-DscResource -Module ComputerManagementDsc + + Node localhost + { + Computer JoinDomain + { + Name = 'Server01' + DomainName = 'Contoso' + Credential = $Credential # Credential to join to domain + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/2-JoinDomain.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/2-JoinDomain.ps1 deleted file mode 100644 index a21c0987..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/Computer/2-JoinDomain.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -<# - .EXAMPLE - This configuration sets the machine name to 'Server01' and - joins the 'Contoso' domain. - Note: this requires an AD credential to join the domain. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost', - - [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] - [System.Management.Automation.PSCredential] - $Credential - ) - - Import-DscResource -Module ComputerManagementDsc - - Node $NodeName - { - Computer JoinDomain - { - Name = 'Server01' - DomainName = 'Contoso' - Credential = $Credential # Credential to join to domain - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 new file mode 100644 index 00000000..c26ea420 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/Computer/3-Computer_RenameComputerInDomain_Config.ps1 @@ -0,0 +1,47 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 7e77ef8f-69ac-4e86-8a95-e38d3350118f +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example will change the machines name 'Server01' while remaining + joined to the current domain. + Note: this requires a credential for renaming the machine on the + domain. +#> +Configuration Computer_RenameComputerInDomain_Config +{ + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullorEmpty()] + [System.Management.Automation.PSCredential] + $Credential + ) + + Import-DscResource -Module ComputerManagementDsc + + Node localhost + { + Computer NewName + { + Name = 'Server01' + Credential = $Credential # Domain credential + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/3-RenameComputerInDomain.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/3-RenameComputerInDomain.ps1 deleted file mode 100644 index ddc6c9ea..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/Computer/3-RenameComputerInDomain.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -<# - .EXAMPLE - This example will change the machines name 'Server01' while remaining - joined to the current domain. - Note: this requires a credential for renaming the machine on the - domain. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost', - - [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] - [System.Management.Automation.PSCredential] - $Credential - ) - - Import-DscResource -Module ComputerManagementDsc - - Node $NodeName - { - Computer NewName - { - Name = 'Server01' - Credential = $Credential # Domain credential - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 new file mode 100644 index 00000000..6d99e6bc --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/Computer/4-Computer_RenameComputerInWorkgroup_Config.ps1 @@ -0,0 +1,36 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 7a5bc1c3-5229-48ec-9145-816d02e4544d +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example will set the machine name to 'Server01' while remaining + in the workgroup. +#> +Configuration Computer_RenameComputerInWorkgroup_Config +{ + Import-DscResource -Module ComputerManagementDsc + + Node localhost + { + Computer NewName + { + Name = 'Server01' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/4-RenameComputerInWorkgroup.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/4-RenameComputerInWorkgroup.ps1 deleted file mode 100644 index 2c3dfdf6..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/Computer/4-RenameComputerInWorkgroup.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -<# - .EXAMPLE - This example will set the machine name to 'Server01' while remaining - in the workgroup. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -Module ComputerManagementDsc - - Node $NodeName - { - Computer NewName - { - Name = 'Server01' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 new file mode 100644 index 00000000..2d880fbc --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/Computer/5-Computer_UnjoinDomainAndJoinWorkgroup_Config.ps1 @@ -0,0 +1,47 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 9625caff-9065-4d04-9585-934998d81591 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example switches the computer 'Server01' from a domain and joins it + to the 'ContosoWorkgroup' Workgroup. + Note: this requires a credential. +#> +Configuration Computer_UnjoinDomainAndJoinWorkgroup_Config +{ + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullorEmpty()] + [System.Management.Automation.PSCredential] + $Credential + ) + + Import-DscResource -Module ComputerManagementDsc + + Node localhost + { + Computer JoinWorkgroup + { + Name = 'Server01' + WorkGroupName = 'ContosoWorkgroup' + Credential = $Credential # Credential to unjoin from domain + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/5-UnjoinDomainAndJoinWorkgroup.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/5-UnjoinDomainAndJoinWorkgroup.ps1 deleted file mode 100644 index 2bf402e8..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/Computer/5-UnjoinDomainAndJoinWorkgroup.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -<# - .EXAMPLE - This example switches the computer 'Server01' from a domain and joins it - to the 'ContosoWorkgroup' Workgroup. - Note: this requires a credential. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost', - - [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] - [System.Management.Automation.PSCredential] - $Credential - ) - - Import-DscResource -Module ComputerManagementDsc - - Node $NodeName - { - Computer JoinWorkgroup - { - Name = 'Server01' - WorkGroupName = 'ContosoWorkgroup' - Credential = $Credential # Credential to unjoin from domain - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 new file mode 100644 index 00000000..6a9c8d6d --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/Computer/6-Computer_SetComputerDescriptionInWorkgroup_Config.ps1 @@ -0,0 +1,36 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 315d9349-c340-4c6d-970e-8e5d2bb5b12b +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example will set the computer description. +#> +Configuration Computer_SetComputerDescriptionInWorkgroup_Config +{ + Import-DscResource -Module ComputerManagementDsc + + Node localhost + { + Computer NewDescription + { + Name = 'localhost' + Description = 'This is my computer.' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/6-SetComputerDescriptionInWorkgroup.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/6-SetComputerDescriptionInWorkgroup.ps1 deleted file mode 100644 index 171fd0b8..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/Computer/6-SetComputerDescriptionInWorkgroup.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -<# - .EXAMPLE - This example will set the computer description -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -Module ComputerManagementDsc - - Node $NodeName - { - Computer NewDescription - { - Name = 'localhost' - Description = 'This is my computer.' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 new file mode 100644 index 00000000..0ef74f61 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/Computer/7-Computer_JoinDomainSpecifyingDC_Config.ps1 @@ -0,0 +1,48 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 5964d0b3-be15-455e-8233-4f655150de79 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This configuration sets the machine name to 'Server01' and + joins the 'Contoso' domain using the domain controller 'dc1.contoso.com'. + Note: this requires an AD credential to join the domain. +#> +Configuration Computer_JoinDomainSpecifyingDC_Config +{ + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullorEmpty()] + [System.Management.Automation.PSCredential] + $Credential + ) + + Import-DscResource -Module ComputerManagementDsc + + Node localhost + { + Computer JoinDomain + { + Name = 'Server01' + DomainName = 'Contoso' + Credential = $Credential # Credential to join to domain + Server = 'dc1.contoso.com' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/Computer/7-JoinDomainSpecifyingDC.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/Computer/7-JoinDomainSpecifyingDC.ps1 deleted file mode 100644 index 9f68b5bb..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/Computer/7-JoinDomainSpecifyingDC.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -<# - .EXAMPLE - This configuration sets the machine name to 'Server01' and - joins the 'Contoso' domain using the domain controller 'dc1.contoso.com'. - Note: this requires an AD credential to join the domain. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost', - - [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] - [System.Management.Automation.PSCredential] - $Credential - ) - - Import-DscResource -Module ComputerManagementDsc - - Node $NodeName - { - Computer JoinDomain - { - Name = 'Server01' - DomainName = 'Contoso' - Credential = $Credential # Credential to join to domain - Server = 'dc1.contoso.com' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-JoinDomainUsingODJBlob.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-JoinDomainUsingODJBlob.ps1 deleted file mode 100644 index ff51b6cf..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-JoinDomainUsingODJBlob.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -<# - .EXAMPLE - This example will join the computer to a domain using the ODJ - request file C:\ODJ\ODJRequest.txt. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - OfflineDomainJoin ODJ - { - IsSingleInstance = 'Yes' - RequestFile = 'C:\ODJ\ODJBlob.txt' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 new file mode 100644 index 00000000..cd7e208b --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/OfflineDomainJoin/1-OfflineDomainJoin_JoinDomainUsingODJBlob_Config.ps1 @@ -0,0 +1,37 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID fc143221-396c-4407-9aa8-c5878326e4ff +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example will join the computer to a domain using the ODJ + request file C:\ODJ\ODJRequest.txt. +#> +Configuration OfflineDomainJoin_JoinDomainUsingODJBlob_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + OfflineDomainJoin ODJ + { + IsSingleInstance = 'Yes' + RequestFile = 'C:\ODJ\ODJBlob.txt' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 new file mode 100644 index 00000000..9142e10f --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-PowerPlan_SetPowerPlan_Config.ps1 @@ -0,0 +1,36 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 547354f3-f5d1-4c76-8988-72887938e852 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This examples sets the active power plan to the 'High performance' plan. +#> +Configuration PowerPlan_SetPowerPlan_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + PowerPlan SetPlanHighPerformance + { + IsSingleInstance = 'Yes' + Name = 'High performance' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-SetPowerPlan.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-SetPowerPlan.ps1 deleted file mode 100644 index 1878f988..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/PowerPlan/1-SetPowerPlan.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -<# - .EXAMPLE - This examples sets the active power plan to the 'High performance' plan. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - PowerPlan SetPlanHighPerformance - { - IsSingleInstance = 'Yes' - Name = 'High performance' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPowerShellExecutionPolicy_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPowerShellExecutionPolicy_Config.ps1 new file mode 100644 index 00000000..ca1f105a --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-PowerShellExecutionPolicy_SetPowerShellExecutionPolicy_Config.ps1 @@ -0,0 +1,36 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID d878a4e7-da0b-4099-b8e3-3442717b4c97 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example shows how to configure powershell's execution policy for the specified execution policy scope. +#> +Configuration PowerShellExecutionPolicy_SetPowerShellExecutionPolicy_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + PowerShellExecutionPolicy ExecutionPolicy + { + ExecutionPolicyScope = 'CurrentUser' + ExecutionPolicy = 'RemoteSigned' + } # End of PowershellExecutionPolicy Resource + } # End of Node +} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-SetPowerShellExecutionPolicy.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-SetPowerShellExecutionPolicy.ps1 deleted file mode 100644 index cbb4c7cd..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/1-SetPowerShellExecutionPolicy.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -<# -.EXAMPLE - This example shows how to configure powershell's execution policy for the specified execution policy scope. -#> - -Configuration Example -{ - Import-DscResource -ModuleName ComputerManagementDsc - - Node localhost - { - PowerShellExecutionPolicy ExecutionPolicy - { - ExecutionPolicyScope = 'CurrentUser' - ExecutionPolicy = 'RemoteSigned' - } # End of PowershellExecutionPolicy Resource - } # End of Node -} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPowershellExecutionPolicyForMultipleScopes_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPowershellExecutionPolicyForMultipleScopes_Config.ps1 new file mode 100644 index 00000000..ec45ea88 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-PowerShellExecutionPolicy_SetPowershellExecutionPolicyForMultipleScopes_Config.ps1 @@ -0,0 +1,42 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 6900f247-5477-4821-9718-480f485db688 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example shows how to configure multiple powershell's execution policy for a specified execution policy scope. +#> +Configuration PowerShellExecutionPolicy_SetPowershellExecutionPolicyForMultipleScopes_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + PowerShellExecutionPolicy ExecutionPolicyCurrentUser + { + ExecutionPolicyScope = 'CurrentUser' + ExecutionPolicy = 'RemoteSigned' + } # End of ExecutionPolicyCurrentUser Resource + + PowerShellExecutionPolicy ExecutionPolicyLocalMachine + { + ExecutionPolicyScope = 'LocalMachine' + ExecutionPolicy = 'RemoteSigned' + } # End of ExecutionPolicyLocalMachine Resource + } # End of Node +} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-SetPowershellExecutionPolicyForMultipleScopes.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-SetPowershellExecutionPolicyForMultipleScopes.ps1 deleted file mode 100644 index 0bf07d6d..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/PowerShellExecutionPolicy/2-SetPowershellExecutionPolicyForMultipleScopes.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -<# -.EXAMPLE - This example shows how to configure multiple powershell's execution policy for a specified execution policy scope. -#> - -Configuration Example -{ - Import-DscResource -ModuleName ComputerManagementDsc - - Node localhost - { - PowerShellExecutionPolicy ExecutionPolicyCurrentUser - { - ExecutionPolicyScope = 'CurrentUser' - ExecutionPolicy = 'RemoteSigned' - } # End of ExecutionPolicyCurrentUser Resource - - PowerShellExecutionPolicy ExecutionPolicyLocalMachine - { - ExecutionPolicyScope = 'LocalMachine' - ExecutionPolicy = 'RemoteSigned' - } # End of ExecutionPolicyLocalMachine Resource - } # End of Node -} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-CreateScheduledTaskOnce.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-CreateScheduledTaskOnce.ps1 deleted file mode 100644 index 3a030f53..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-CreateScheduledTaskOnce.ps1 +++ /dev/null @@ -1,40 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task Once' in the folder - task folder 'MyTasks' that starts a new powershell process once at 00:00 repeating - every 15 minutes for 8 hours. The task is delayed by a random amount up to 1 hour - each time. The task will run even if the previous task is still running and it - will prevent hard termintaing of the previously running task instance. The task - execution will have no time limit. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask ScheduledTaskOnceAdd - { - TaskName = 'Test task Once' - TaskPath = '\MyTasks' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'Once' - RepeatInterval = '00:15:00' - RepetitionDuration = '08:00:00' - ExecutionTimeLimit = '00:00:00' - ActionWorkingPath = (Get-Location).Path - Enable = $true - RandomDelay = '01:00:00' - DisallowHardTerminate = $true - RunOnlyIfIdle = $false - Priority = 9 - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 new file mode 100644 index 00000000..bf96ef2a --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/1-ScheduledTask_CreateScheduledTaskOnce_Config.ps1 @@ -0,0 +1,52 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 4310a6c2-9f34-4ebc-8895-feda5286e532 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task Once' in the folder + task folder 'MyTasks' that starts a new powershell process once at 00:00 repeating + every 15 minutes for 8 hours. The task is delayed by a random amount up to 1 hour + each time. The task will run even if the previous task is still running and it + will prevent hard termintaing of the previously running task instance. The task + execution will have no time limit. +#> +Configuration ScheduledTask_CreateScheduledTaskOnce_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask ScheduledTaskOnceAdd + { + TaskName = 'Test task Once' + TaskPath = '\MyTasks' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'Once' + RepeatInterval = '00:15:00' + RepetitionDuration = '08:00:00' + ExecutionTimeLimit = '00:00:00' + ActionWorkingPath = (Get-Location).Path + Enable = $true + RandomDelay = '01:00:00' + DisallowHardTerminate = $true + RunOnlyIfIdle = $false + Priority = 9 + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-RunPowerShellTaskOnceAsUserInteractiveOnly.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-RunPowerShellTaskOnceAsUserInteractiveOnly.ps1 deleted file mode 100644 index 1e78bf56..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-RunPowerShellTaskOnceAsUserInteractiveOnly.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task interactive' in the folder - task folder 'MyTasks' that starts a new powershell process once. The task will - execute using the credential passed into the $Credential parameter, but only when - the user contained in the $Credential is logged on. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost', - - [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] - [System.Management.Automation.PSCredential] - $Credential - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask MaintenanceScriptExample - { - TaskName = 'Test task Interactive' - TaskPath = '\MyTasks' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'Once' - ActionWorkingPath = (Get-Location).Path - Enable = $true - ExecuteAsCredential = $Credential - LogonType = 'Interactive' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 new file mode 100644 index 00000000..176d5ec0 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/10-ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config.ps1 @@ -0,0 +1,53 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 0323fac5-e026-4f41-a9be-9fdcd0967b60 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task interactive' in the folder + task folder 'MyTasks' that starts a new powershell process once. The task will + execute using the credential passed into the $Credential parameter, but only when + the user contained in the $Credential is logged on. +#> +Configuration ScheduledTask_RunPowerShellTaskOnceAsUserInteractiveOnly_Config +{ + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullorEmpty()] + [System.Management.Automation.PSCredential] + $Credential + ) + + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask MaintenanceScriptExample + { + TaskName = 'Test task Interactive' + TaskPath = '\MyTasks' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'Once' + ActionWorkingPath = (Get-Location).Path + Enable = $true + ExecuteAsCredential = $Credential + LogonType = 'Interactive' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-DisableABuiltInTask.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-DisableABuiltInTask.ps1 deleted file mode 100644 index 7bc92988..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-DisableABuiltInTask.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -<# - .EXAMPLE - This example disables the built-in scheduled task called - 'CreateExplorerShellUnelevatedTask'. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask DisableCreateExplorerShellUnelevatedTask - { - TaskName = 'CreateExplorerShellUnelevatedTask' - TaskPath = '\' - Enable = $false - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 new file mode 100644 index 00000000..b2ee1706 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/11-ScheduledTask_DisableABuiltInTask_Config.ps1 @@ -0,0 +1,38 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID c3422e70-79ea-4afa-9558-1fcbe18dd0bd +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example disables the built-in scheduled task called + 'CreateExplorerShellUnelevatedTask'. +#> +Configuration ScheduledTask_DisableABuiltInTask_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask DisableCreateExplorerShellUnelevatedTask + { + TaskName = 'CreateExplorerShellUnelevatedTask' + TaskPath = '\' + Enable = $false + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-DeleteABuiltInTask.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-DeleteABuiltInTask.ps1 deleted file mode 100644 index 6d0499a0..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-DeleteABuiltInTask.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -<# - .EXAMPLE - This example deletes the built-in scheduled task called - 'CreateExplorerShellUnelevatedTask'. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask DeleteCreateExplorerShellUnelevatedTask - { - TaskName = 'CreateExplorerShellUnelevatedTask' - TaskPath = '\' - Ensure = 'Absent' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 new file mode 100644 index 00000000..4b322f27 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/12-ScheduledTask_DeleteABuiltInTask_Config.ps1 @@ -0,0 +1,38 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 8bed07fe-c88f-4a22-bdd8-8ec95cf8739b +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example deletes the built-in scheduled task called + 'CreateExplorerShellUnelevatedTask'. +#> +Configuration ScheduledTask_DeleteABuiltInTask_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask DeleteCreateExplorerShellUnelevatedTask + { + TaskName = 'CreateExplorerShellUnelevatedTask' + TaskPath = '\' + Ensure = 'Absent' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-CreateScheduledTasksOnEvent.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-CreateScheduledTasksOnEvent.ps1 deleted file mode 100644 index c34b22b6..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-CreateScheduledTasksOnEvent.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'TriggerOnServiceFailures' in the folder - root folder. The task is delayed by exactly 30 seconds each time. The task will run when - an error event 7001 of source Service Control Manager is generated in the system log. - When a service crashes, it waits for 30 seconds and then starts a new PowerShell instance, - in which the file c:\temp\seeme.txt get's created with the value 'Worked!' -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask ServiceEventManager - { - TaskName = 'TriggerOnServiceFailures' - Ensure = 'Present' - ScheduleType = 'OnEvent' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ActionArguments = '-Command Set-Content -Path c:\temp\seeme.txt -Value ''Worked!''' - EventSubscription = '' - Delay = '00:00:30' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 new file mode 100644 index 00000000..4f690ffd --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/13-ScheduledTask_CreateScheduledTasksOnEvent_Config.ps1 @@ -0,0 +1,45 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID cff7293a-5b43-491c-9628-d6eca35c8bfd +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'TriggerOnServiceFailures' in the folder + root folder. The task is delayed by exactly 30 seconds each time. The task will run when + an error event 7001 of source Service Control Manager is generated in the system log. + When a service crashes, it waits for 30 seconds and then starts a new PowerShell instance, + in which the file c:\temp\seeme.txt get's created with the value 'Worked!' +#> +Configuration ScheduledTask_CreateScheduledTasksOnEvent_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask ServiceEventManager + { + TaskName = 'TriggerOnServiceFailures' + Ensure = 'Present' + ScheduleType = 'OnEvent' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ActionArguments = '-Command Set-Content -Path c:\temp\seeme.txt -Value ''Worked!''' + EventSubscription = '' + Delay = '00:00:30' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-RunPowerShellTaskOnceAsGroupManagedServiceAccount.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-RunPowerShellTaskOnceAsGroupManagedServiceAccount.ps1 deleted file mode 100644 index 33061ff0..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-RunPowerShellTaskOnceAsGroupManagedServiceAccount.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task Run As gMSA' - in the folder task folder 'MyTasks' that starts a new powershell process once. - The task will run as the user passed into the ExecuteAsGMSA parameter. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost', - - # Group Managed Service Account must be in the form of DOMAIN\gMSA$ or user@domain.fqdn (UPN) - [Parameter()] - [ValidatePattern('^\w+\\\w+\$$|\w+@\w+\.\w+')] - [System.String] - $GroupManagedServiceAccount = 'DOMAIN\gMSA$' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask MaintenanceScriptExample - { - TaskName = 'Test task Run As gMSA' - TaskPath = '\MyTasks' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'Once' - ActionWorkingPath = (Get-Location).Path - Enable = $true - ExecuteAsGMSA = $GroupManagedServiceAccount - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 new file mode 100644 index 00000000..6924e46d --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/14-ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config.ps1 @@ -0,0 +1,52 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID cc614ca9-5994-48fb-9528-46107b3eea91 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task Run As gMSA' + in the folder task folder 'MyTasks' that starts a new powershell process once. + The task will run as the user passed into the ExecuteAsGMSA parameter. +#> +Configuration ScheduledTask_RunPowerShellTaskOnceAsGroupManagedServiceAccount_Config +{ + param + ( + # Group Managed Service Account must be in the form of DOMAIN\gMSA$ or user@domain.fqdn (UPN) + [Parameter()] + [ValidatePattern('^\w+\\\w+\$$|\w+@\w+\.\w+')] + [System.String] + $GroupManagedServiceAccount = 'DOMAIN\gMSA$' + ) + + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask MaintenanceScriptExample + { + TaskName = 'Test task Run As gMSA' + TaskPath = '\MyTasks' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'Once' + ActionWorkingPath = (Get-Location).Path + Enable = $true + ExecuteAsGMSA = $GroupManagedServiceAccount + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled.ps1 deleted file mode 100644 index 263c901f..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task sync across time zone enabled' - in the folder 'MyTasks' that starts a new powershell process once 2018-10-01 01:00 - The task will have the option Synchronize across time zone enabled. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled - { - TaskName = 'Test task sync across time zone enabled' - TaskPath = '\MyTasks\' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'Once' - StartTime = '2018-10-01T01:00:00' - SynchronizeAcrossTimeZone = $true - ActionWorkingPath = (Get-Location).Path - Enable = $true - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 new file mode 100644 index 00000000..3ebe8e0d --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/15-ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config.ps1 @@ -0,0 +1,44 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID ee32fb99-4150-4616-a46c-d2132ffb5205 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task sync across time zone enabled' + in the folder 'MyTasks' that starts a new powershell process once 2018-10-01 01:00 + The task will have the option Synchronize across time zone enabled. +#> +Configuration ScheduledTask_CreateScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabled + { + TaskName = 'Test task sync across time zone enabled' + TaskPath = '\MyTasks\' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'Once' + StartTime = '2018-10-01T01:00:00' + SynchronizeAcrossTimeZone = $true + ActionWorkingPath = (Get-Location).Path + Enable = $true + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-CreateScheduledTaskDaily.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-CreateScheduledTaskDaily.ps1 deleted file mode 100644 index 55dea61e..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-CreateScheduledTaskDaily.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task Daily' in the folder - task folder 'MyTasks' that starts a new powershell process every day at 00:00 repeating - every 15 minutes for 8 hours. If the task fails it will be restarted after 5 minutes - and it will be restarted a maximum of two times. It will only run if the network - is connected and will wake the machine up to execute the task. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask ScheduledTaskDailyAdd - { - TaskName = 'Test task Daily' - TaskPath = '\MyTasks' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'Daily' - DaysInterval = 1 - RepeatInterval = '00:15:00' - RepetitionDuration = '08:00:00' - RestartCount = 2 - RestartInterval = '00:05:00' - RunOnlyIfNetworkAvailable = $true - WakeToRun = $true - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 new file mode 100644 index 00000000..6ba8a35c --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/2-ScheduledTask_CreateScheduledTaskDaily_Config.ps1 @@ -0,0 +1,49 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID ce544d27-c44f-44d9-a771-1ae9b22b180c +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task Daily' in the folder + task folder 'MyTasks' that starts a new powershell process every day at 00:00 repeating + every 15 minutes for 8 hours. If the task fails it will be restarted after 5 minutes + and it will be restarted a maximum of two times. It will only run if the network + is connected and will wake the machine up to execute the task. +#> +Configuration ScheduledTask_CreateScheduledTaskDaily_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask ScheduledTaskDailyAdd + { + TaskName = 'Test task Daily' + TaskPath = '\MyTasks' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'Daily' + DaysInterval = 1 + RepeatInterval = '00:15:00' + RepetitionDuration = '08:00:00' + RestartCount = 2 + RestartInterval = '00:05:00' + RunOnlyIfNetworkAvailable = $true + WakeToRun = $true + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-CreateScheduledTasksDailyIndefinitely.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-CreateScheduledTasksDailyIndefinitely.ps1 deleted file mode 100644 index 61c455eb..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-CreateScheduledTasksDailyIndefinitely.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task Daily Indefinitely' in the folder - task folder 'MyTasks' that starts a new powershell process every day at 00:00 repeating - every 15 minutes indefinitely. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask ScheduledTaskDailyIndefinitelyAdd - { - TaskName = 'Test task Daily Indefinitely' - TaskPath = '\MyTasks' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'Daily' - DaysInterval = 1 - RepeatInterval = '00:15:00' - RepetitionDuration = 'Indefinitely' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 new file mode 100644 index 00000000..047bb1dc --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/3-ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config.ps1 @@ -0,0 +1,43 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID ae57d854-a9ae-4b3b-808d-3f23423beb29 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task Daily Indefinitely' in the folder + task folder 'MyTasks' that starts a new powershell process every day at 00:00 repeating + every 15 minutes indefinitely. +#> +Configuration ScheduledTask_CreateScheduledTasksDailyIndefinitely_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask ScheduledTaskDailyIndefinitelyAdd + { + TaskName = 'Test task Daily Indefinitely' + TaskPath = '\MyTasks' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'Daily' + DaysInterval = 1 + RepeatInterval = '00:15:00' + RepetitionDuration = 'Indefinitely' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-CreateScheduledTasksWeekly.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-CreateScheduledTasksWeekly.ps1 deleted file mode 100644 index e329f7c8..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-CreateScheduledTasksWeekly.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task Weekly' in the folder - task folder 'MyTasks' that starts a new powershell process every week on - Monday, Wednesday and Saturday at 00:00 repeating every 15 minutes for 8 hours. - The task will be hidden and will be allowed to start if the machine is running - on batteries. The task will be compatible with Windows 8. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask ScheduledTaskWeeklyAdd - { - TaskName = 'Test task Weekly' - TaskPath = '\MyTasks' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'Weekly' - WeeksInterval = 1 - DaysOfWeek = 'Monday', 'Wednesday', 'Saturday' - RepeatInterval = '00:15:00' - RepetitionDuration = '08:00:00' - AllowStartIfOnBatteries = $true - Compatibility = 'Win8' - Hidden = $true - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 new file mode 100644 index 00000000..5e7b5112 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/4-ScheduledTask_CreateScheduledTasksWeekly_Config.ps1 @@ -0,0 +1,49 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 8817eedf-02f5-4477-8b2d-55fa73f33902 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task Weekly' in the folder + task folder 'MyTasks' that starts a new powershell process every week on + Monday, Wednesday and Saturday at 00:00 repeating every 15 minutes for 8 hours. + The task will be hidden and will be allowed to start if the machine is running + on batteries. The task will be compatible with Windows 8. +#> +Configuration ScheduledTask_CreateScheduledTasksWeekly_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask ScheduledTaskWeeklyAdd + { + TaskName = 'Test task Weekly' + TaskPath = '\MyTasks' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'Weekly' + WeeksInterval = 1 + DaysOfWeek = 'Monday', 'Wednesday', 'Saturday' + RepeatInterval = '00:15:00' + RepetitionDuration = '08:00:00' + AllowStartIfOnBatteries = $true + Compatibility = 'Win8' + Hidden = $true + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-CreateScheduledTasksAtLogon.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-CreateScheduledTasksAtLogon.ps1 deleted file mode 100644 index ab03b9f7..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-CreateScheduledTasksAtLogon.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task Logon' in the folder - task folder 'MyTasks' that starts a new powershell process when the machine - is logged on repeating every 15 minutes for 8 hours. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask ScheduledTaskLogonAdd - { - TaskName = 'Test task Logon' - TaskPath = '\MyTasks' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'AtLogOn' - RepeatInterval = '00:15:00' - RepetitionDuration = '08:00:00' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 new file mode 100644 index 00000000..f436230f --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/5-ScheduledTask_CreateScheduledTasksAtLogon_Config.ps1 @@ -0,0 +1,42 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 282cba27-4cf3-43b8-86f2-f6ef0f8b4489 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task Logon' in the folder + task folder 'MyTasks' that starts a new powershell process when the machine + is logged on repeating every 15 minutes for 8 hours. +#> +Configuration ScheduledTask_CreateScheduledTasksAtLogon_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask ScheduledTaskLogonAdd + { + TaskName = 'Test task Logon' + TaskPath = '\MyTasks' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'AtLogOn' + RepeatInterval = '00:15:00' + RepetitionDuration = '08:00:00' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-CreateScheduledTasksAtStartup.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-CreateScheduledTasksAtStartup.ps1 deleted file mode 100644 index 8bbdc879..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-CreateScheduledTasksAtStartup.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task Startup' in the folder - task folder 'MyTasks' that starts a new powershell process when the machine - is started up repeating every 15 minutes for 8 hours. - -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask ScheduledTaskStartupAdd - { - TaskName = 'Test task Startup' - TaskPath = '\MyTasks' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'AtStartup' - RepeatInterval = '00:15:00' - RepetitionDuration = '08:00:00' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 new file mode 100644 index 00000000..dd786617 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/6-ScheduledTask_CreateScheduledTasksAtStartup_Config.ps1 @@ -0,0 +1,42 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID d5cfbf76-5123-48bb-a856-5ea44504b4eb +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task Startup' in the folder + task folder 'MyTasks' that starts a new powershell process when the machine + is started up repeating every 15 minutes for 8 hours. +#> +Configuration ScheduledTask_CreateScheduledTasksAtStartup_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask ScheduledTaskStartupAdd + { + TaskName = 'Test task Startup' + TaskPath = '\MyTasks' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'AtStartup' + RepeatInterval = '00:15:00' + RepetitionDuration = '08:00:00' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-RunPowerShellTaskEvery15Minutes.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-RunPowerShellTaskEvery15Minutes.ps1 deleted file mode 100644 index 34ddc812..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-RunPowerShellTaskEvery15Minutes.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# - .EXAMPLE - This example will create a scheduled task that will call PowerShell.exe every 15 - minutes for 4 days to run a script saved locally. The task will start immediately. - The script will be called as the local system account. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask MaintenanceScriptExample - { - TaskName = "Custom maintenance tasks" - ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" - ActionArguments = "-File `"C:\scripts\my custom script.ps1`"" - ScheduleType = 'Once' - RepeatInterval = '00:15:00' - RepetitionDuration = '4.00:00:00' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 new file mode 100644 index 00000000..3f095da9 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/7-ScheduledTask_RunPowerShellTaskEvery15Minutes_Config.ps1 @@ -0,0 +1,42 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 6a249767-c480-453f-9e10-1ed7ef465d87 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example will create a scheduled task that will call PowerShell.exe every 15 + minutes for 4 days to run a script saved locally. The task will start immediately. + The script will be called as the local system account. +#> +Configuration ScheduledTask_RunPowerShellTaskEvery15Minutes_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask MaintenanceScriptExample + { + TaskName = "Custom maintenance tasks" + ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" + ActionArguments = "-File `"C:\scripts\my custom script.ps1`"" + ScheduleType = 'Once' + RepeatInterval = '00:15:00' + RepetitionDuration = '4.00:00:00' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-RunPowerShellTaskEvery15MinutesIndefinitely.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-RunPowerShellTaskEvery15MinutesIndefinitely.ps1 deleted file mode 100644 index d4df2e4b..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-RunPowerShellTaskEvery15MinutesIndefinitely.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# - .EXAMPLE - This example will create a scheduled task that will call PowerShell.exe every 15 - minutes indefinitely to run a script saved locally. The task will start immediately. - The script will be called as the local system account. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask MaintenanceScriptExample - { - TaskName = "Custom maintenance tasks" - ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" - ActionArguments = "-File `"C:\scripts\my custom script.ps1`"" - ScheduleType = 'Once' - RepeatInterval = '00:15:00' - RepetitionDuration = 'Indefinitely' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 new file mode 100644 index 00000000..7cb24823 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/8-ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config.ps1 @@ -0,0 +1,42 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID dffe47fd-73f7-47d2-8604-f381e6c18f26 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example will create a scheduled task that will call PowerShell.exe every 15 + minutes indefinitely to run a script saved locally. The task will start immediately. + The script will be called as the local system account. +#> +Configuration ScheduledTask_RunPowerShellTaskEvery15MinutesIndefinitely_Config +{ + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask MaintenanceScriptExample + { + TaskName = "Custom maintenance tasks" + ActionExecutable = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe" + ActionArguments = "-File `"C:\scripts\my custom script.ps1`"" + ScheduleType = 'Once' + RepeatInterval = '00:15:00' + RepetitionDuration = 'Indefinitely' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-RunPowerShellTaskOnceAsUserWithHighestPriveleges.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-RunPowerShellTaskOnceAsUserWithHighestPriveleges.ps1 deleted file mode 100644 index 882cb50e..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-RunPowerShellTaskOnceAsUserWithHighestPriveleges.ps1 +++ /dev/null @@ -1,38 +0,0 @@ -<# - .EXAMPLE - This example creates a scheduled task called 'Test task Run As Highest Privilege' - in the folder task folder 'MyTasks' that starts a new powershell process once. - The task will run as the credential passed into the $Credential parameter, running - with the highest privileges. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost', - - [Parameter(Mandatory = $true)] - [ValidateNotNullorEmpty()] - [System.Management.Automation.PSCredential] - $Credential - ) - - Import-DscResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - ScheduledTask MaintenanceScriptExample - { - TaskName = 'Test task Run As Highest Privilege' - TaskPath = '\MyTasks' - ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - ScheduleType = 'Once' - ActionWorkingPath = (Get-Location).Path - Enable = $true - ExecuteAsCredential = $Credential - RunLevel = 'Highest' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 new file mode 100644 index 00000000..81b67a47 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/ScheduledTask/9-ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config.ps1 @@ -0,0 +1,53 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 718e81fa-c553-4715-8f5d-734fb8a02204 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example creates a scheduled task called 'Test task Run As Highest Privilege' + in the folder task folder 'MyTasks' that starts a new powershell process once. + The task will run as the credential passed into the $Credential parameter, running + with the highest privileges. +#> +Configuration ScheduledTask_RunPowerShellTaskOnceAsUserWithHighestPriveleges_Config +{ + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullorEmpty()] + [System.Management.Automation.PSCredential] + $Credential + ) + + Import-DscResource -ModuleName ComputerManagementDsc + + Node localhost + { + ScheduledTask MaintenanceScriptExample + { + TaskName = 'Test task Run As Highest Privilege' + TaskPath = '\MyTasks' + ActionExecutable = 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + ScheduleType = 'Once' + ActionWorkingPath = (Get-Location).Path + Enable = $true + ExecuteAsCredential = $Credential + RunLevel = 'Highest' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-SetTimeZone.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-SetTimeZone.ps1 deleted file mode 100644 index d714fb91..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-SetTimeZone.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -<# - .EXAMPLE - This example sets the current time zone on the node - to 'Tonga Standard Time'. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DSCResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - TimeZone TimeZoneExample - { - IsSingleInstance = 'Yes' - TimeZone = 'Tonga Standard Time' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 new file mode 100644 index 00000000..184f1a82 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/TimeZone/1-TimeZone_SetTimeZone_Config.ps1 @@ -0,0 +1,37 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID d39a7d09-4baa-44d2-bcb4-b37ae3f2e16b +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + This example sets the current time zone on the node + to 'Tonga Standard Time'. +#> +Configuration TimeZone_SetTimeZone_Config +{ + Import-DSCResource -ModuleName ComputerManagementDsc + + Node localhost + { + TimeZone TimeZoneExample + { + IsSingleInstance = 'Yes' + TimeZone = 'Tonga Standard Time' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-SetVirtualMemory.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-SetVirtualMemory.ps1 deleted file mode 100644 index 4a1b07e8..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-SetVirtualMemory.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -<# - .EXAMPLE - Example script that sets the paging file to reside on - drive C with the custom size 2048MB -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DSCResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - VirtualMemory PagingSettings - { - Type = 'CustomSize' - Drive = 'C' - InitialSize = '2048' - MaximumSize = '2048' - } - } -} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 new file mode 100644 index 00000000..3b178a11 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/VirtualMemory/1-VirtualMemory_SetVirtualMemory_Config.ps1 @@ -0,0 +1,39 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 8ea6bdd3-8822-4e6e-9957-d8576a45c55a +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + Example script that sets the paging file to reside on + drive C with the custom size 2048MB. +#> +Configuration VirtualMemory_SetVirtualMemory_Config +{ + Import-DSCResource -ModuleName ComputerManagementDsc + + Node localhost + { + VirtualMemory PagingSettings + { + Type = 'CustomSize' + Drive = 'C' + InitialSize = '2048' + MaximumSize = '2048' + } + } +} diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-SetWindowsEventlogSize.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-SetWindowsEventlogSize.ps1 deleted file mode 100644 index f3b98959..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-SetWindowsEventlogSize.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -<# - .EXAMPLE - Example script that sets the application Windows Event Log - to a maximum size 4096MB, the logmode to 'Circular' and ensure that it is enabled. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DSCResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - WindowsEventLog ApplicationEventlogSize - { - LogName = 'Application' - IsEnabled = $true - LogMode = 'Circular' - MaximumSizeInBytes = 4096KB - } # End of Windows Event Log Resource - } # End of Node -} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 new file mode 100644 index 00000000..d481b56b --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/1-WindowsEventlog_SetWindowsEventlogSize_Config.ps1 @@ -0,0 +1,39 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID f8fb71fd-9f4a-4ae5-93b8-53362752e37d +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + Example script that sets the application Windows Event Log + to a maximum size 4096MB, the logmode to 'Circular' and ensure that it is enabled. +#> +Configuration WindowsEventlog_SetWindowsEventlogSize_Config +{ + Import-DSCResource -ModuleName ComputerManagementDsc + + Node localhost + { + WindowsEventLog ApplicationEventlogSize + { + LogName = 'Application' + IsEnabled = $true + LogMode = 'Circular' + MaximumSizeInBytes = 4096KB + } # End of Windows Event Log Resource + } # End of Node +} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-SetWindowsEventlogLogMode.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-SetWindowsEventlogLogMode.ps1 deleted file mode 100644 index 807a50cc..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-SetWindowsEventlogLogMode.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -<# - .EXAMPLE - Example script that sets the application Windows Event Log - to mode AutoBackup and logsize to a maximum size of 2048MB - with a logfile retention for 10 days and ensure it is enabled. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DSCResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - WindowsEventLog ApplicationEventlogMode - { - LogName = 'Microsoft-Windows-MSPaint/Admin' - IsEnabled = $true - LogMode = 'AutoBackup' - LogRetentionDays = '10' - MaximumSizeInBytes = 2048kb - } # End of Windows Event Log Resource - } # End of Node -} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 new file mode 100644 index 00000000..7c437c81 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/2-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 @@ -0,0 +1,41 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 5e3f845c-58ce-4e46-baaf-2422d30176ca +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + Example script that sets the application Windows Event Log + to mode AutoBackup and logsize to a maximum size of 2048MB + with a logfile retention for 10 days and ensure it is enabled. +#> +Configuration WindowsEventlog_SetWindowsEventlogLogMode_Config +{ + Import-DSCResource -ModuleName ComputerManagementDsc + + Node localhost + { + WindowsEventLog ApplicationEventlogMode + { + LogName = 'Microsoft-Windows-MSPaint/Admin' + IsEnabled = $true + LogMode = 'AutoBackup' + LogRetentionDays = '10' + MaximumSizeInBytes = 2048kb + } # End of Windows Event Log Resource + } # End of Node +} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-EnableWindowsEventLog.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-EnableWindowsEventLog.ps1 deleted file mode 100644 index 57e5843a..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-EnableWindowsEventLog.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -<# - .EXAMPLE - Example script that sets the Dsc Analytic Windows Event Log - to size maximum size 4096MB, with logmode 'Retain' and ensure it is enabled. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DSCResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - WindowsEventLog Enable-DscAnalytic - { - LogName = 'Microsoft-Windows-Dsc/Analytic' - IsEnabled = $True - LogMode = 'Retain' - MaximumSizeInBytes = 4096kb - LogFilePath = "%SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-DSC%4Analytic.evtx" - } # End of Windows Event Log Resource - } # End of Node -} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 new file mode 100644 index 00000000..ddd51c02 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/3-WindowsEventlog_EnableWindowsEventLog_Config.ps1 @@ -0,0 +1,40 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID f05286e4-e357-40f8-ba62-e49d4d50eb0f +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + Example script that sets the Dsc Analytic Windows Event Log + to size maximum size 4096MB, with logmode 'Retain' and ensure it is enabled. +#> +Configuration WindowsEventlog_EnableWindowsEventLog_Config +{ + Import-DSCResource -ModuleName ComputerManagementDsc + + Node localhost + { + WindowsEventLog Enable-DscAnalytic + { + LogName = 'Microsoft-Windows-Dsc/Analytic' + IsEnabled = $True + LogMode = 'Retain' + MaximumSizeInBytes = 4096kb + LogFilePath = "%SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-DSC%4Analytic.evtx" + } # End of Windows Event Log Resource + } # End of Node +} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-SetWindowsEventlogLogMode.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-SetWindowsEventlogLogMode.ps1 deleted file mode 100644 index a218b89a..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-SetWindowsEventlogLogMode.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -<# - .EXAMPLE - Example script that sets the application Windows Event Log - logmode to 'Autobackup' with 30 days retention and ensure it is enabled. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DSCResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - WindowsEventLog ApplicationEventlogSize - { - LogName = 'Application' - IsEnabled = $true - LogMode = 'AutoBackup' - LogRetentionDays = 30 - } # End of Windows Event Log Resource - } # End of Node -} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 new file mode 100644 index 00000000..135dd66d --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/4-WindowsEventlog_SetWindowsEventlogLogMode_Config.ps1 @@ -0,0 +1,39 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 1e24ee07-cb2f-489b-af15-ebf6ffa864fe +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + Example script that sets the application Windows Event Log + logmode to 'Autobackup' with 30 days retention and ensure it is enabled. +#> +Configuration WindowsEventlog_SetWindowsEventlogLogMode_Config +{ + Import-DSCResource -ModuleName ComputerManagementDsc + + Node localhost + { + WindowsEventLog ApplicationEventlogSize + { + LogName = 'Application' + IsEnabled = $true + LogMode = 'AutoBackup' + LogRetentionDays = 30 + } # End of Windows Event Log Resource + } # End of Node +} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-SetWindowsEventlogSecurityDescriptor.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-SetWindowsEventlogSecurityDescriptor.ps1 deleted file mode 100644 index a7a95e6a..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-SetWindowsEventlogSecurityDescriptor.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -<# - .EXAMPLE - Example script that sets the application Windows Event Log - logmode to 'Circular' with 30 days retention, - with a Security Desriptor and ensure it is enabled. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DSCResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - WindowsEventLog ApplicationEventlogSize - { - LogName = 'Application' - IsEnabled = $true - LogMode = 'Circular' - MaximumSizeInBytes = 2048kb - SecurityDescriptor = 'O:BAG:SYD:(A;;0x7;;;BA)(A;;0x7;;;SO)(A;;0x3;;;IU)(A;;0x3;;;SU)(A;;0x3;;;S-1-5-3)(A;;0x3;;;S-1-5-33)(A;;0x1;;;S-1-5-32-573)' - } # End of Windows Event Log Resource - } # End of Node -} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 new file mode 100644 index 00000000..003835d4 --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/5-WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config.ps1 @@ -0,0 +1,41 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 07323d21-39a0-4f62-bed7-7acc943f9234 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + Example script that sets the application Windows Event Log + logmode to 'Circular' with 30 days retention, + with a Security Desriptor and ensure it is enabled. +#> +Configuration WindowsEventlog_SetWindowsEventlogSecurityDescriptor_Config +{ + Import-DSCResource -ModuleName ComputerManagementDsc + + Node localhost + { + WindowsEventLog ApplicationEventlogSize + { + LogName = 'Application' + IsEnabled = $true + LogMode = 'Circular' + MaximumSizeInBytes = 2048kb + SecurityDescriptor = 'O:BAG:SYD:(A;;0x7;;;BA)(A;;0x7;;;SO)(A;;0x3;;;IU)(A;;0x3;;;SU)(A;;0x3;;;S-1-5-3)(A;;0x3;;;S-1-5-33)(A;;0x1;;;S-1-5-32-573)' + } # End of Windows Event Log Resource + } # End of Node +} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-DisableWindowsEventlog.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-DisableWindowsEventlog.ps1 deleted file mode 100644 index 3c91c682..00000000 --- a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-DisableWindowsEventlog.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -<# - .EXAMPLE - Example script that disables the given Windows Event Log. -#> -Configuration Example -{ - param - ( - [Parameter()] - [System.String[]] - $NodeName = 'localhost' - ) - - Import-DSCResource -ModuleName ComputerManagementDsc - - Node $NodeName - { - WindowsEventLog Enable-DscAnalytic - { - LogName = 'Microsoft-Windows-Dsc/Analytic' - IsEnabled = $false - } # End of Windows Event Log Resource - } # End of Node -} # End of Configuration diff --git a/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 new file mode 100644 index 00000000..61ee8b5f --- /dev/null +++ b/Modules/ComputerManagementDsc/Examples/Resources/WindowsEventlog/6-WindowsEventlog_DisableWindowsEventlog_Config.ps1 @@ -0,0 +1,36 @@ +<#PSScriptInfo +.VERSION 1.0.0 +.GUID 1d426e51-df3b-4723-96ac-e7d790744f69 +.AUTHOR Microsoft Corporation +.COMPANYNAME Microsoft Corporation +.COPYRIGHT (c) Microsoft Corporation. All rights reserved. +.TAGS DSCConfiguration +.LICENSEURI https://github.com/PowerShell/ComputerManagementDsc/blob/master/LICENSE +.PROJECTURI https://github.com/PowerShell/ComputerManagementDsc +.ICONURI +.EXTERNALMODULEDEPENDENCIES +.REQUIREDSCRIPTS +.EXTERNALSCRIPTDEPENDENCIES +.RELEASENOTES First version. +.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core +#> + +#Requires -module ComputerManagementDsc + +<# + .DESCRIPTION + Example script that disables the given Windows Event Log. +#> +Configuration WindowsEventlog_DisableWindowsEventlog_Config +{ + Import-DSCResource -ModuleName ComputerManagementDsc + + Node localhost + { + WindowsEventLog Enable-DscAnalytic + { + LogName = 'Microsoft-Windows-Dsc/Analytic' + IsEnabled = $false + } # End of Windows Event Log Resource + } # End of Node +} # End of Configuration