diff --git a/.MetaTestOptIn.json b/.MetaTestOptIn.json new file mode 100644 index 00000000..a74f3590 --- /dev/null +++ b/.MetaTestOptIn.json @@ -0,0 +1,3 @@ +[ + "Common Tests - Validate Markdown Files" +] diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 00000000..411198f0 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,26 @@ +codecov: + notify: + require_ci_to_pass: no + # dev should be the baseline for reporting + branch: dev + +comment: + layout: "reach, diff" + behavior: default + +coverage: + range: 50..80 + round: down + precision: 0 + + status: + project: + default: + # Set the overall project code coverage requirement to 70% + target: 70 + patch: + default: + # Set the pull request requirement to not regress overall coverage by more than 5% + # and let codecov.io set the goal for the code changed in the patch. + target: auto + threshold: 5 diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..9e37faa7 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,10 @@ +{ + "default": true, + "MD029": { + "style": "one" + }, + "MD013": true, + "MD024": true, + "MD034": true, + "no-hard-tabs": true +} diff --git a/README.md b/README.md index a9bbc2db..74c130c2 100644 --- a/README.md +++ b/README.md @@ -1,188 +1,268 @@ -[![Build status](https://ci.appveyor.com/api/projects/status/cg28qxeco39wgo9l/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xcomputermanagement/branch/master) - # xComputerManagement -The xComputerManagement module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources produced by the PowerShell Team. -This module contains the xComputer resource. -This DSC Resource allows you to rename a computer and add it to a domain or workgroup. - -All of the resources in the DSC Resource Kit are provided AS IS, and are not supported through any Microsoft standard support program or service. -The ""x" in xComputerManagement stands for experimental, which means that these resources will be fix forward and monitored by the module owner(s). +The **xComputerManagement** module contains the following resources: -Please leave comments, feature requests, and bug reports in the Issues tab for this module. +* xComputer - allows you to configure a computer by changing its name and + modifying its domain or workgroup. +* xOfflineDomainJoin - allows you to join computers to an AD Domain using + an [Offline Domain Join](https://technet.microsoft.com/en-us/library/offline-domain-join-djoin-step-by-step(v=ws.10).aspx) + request file. +* xScheduledTask - used to define basic recurring scheduled tasks on the + local computer. +* xPowerPlan - specifies a power plan to activate. +* xVirtualMemory - used to set the properties of the paging file on the + local computer. This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. + +## Branches + +### master -If you would like to modify xComputerManagement module, feel free. -When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). -As specified in the license, you may copy or modify this resource as long as they are used on the Windows Platform. +[![Build status](https://ci.appveyor.com/api/projects/status/cg28qxeco39wgo9l/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xsqlserver/branch/master) +[![codecov](https://codecov.io/gh/PowerShell/xComputerManagement/branch/master/graph/badge.svg)](https://codecov.io/gh/PowerShell/xComputerManagement/branch/master) -PowerShell Blog (this is a good starting point). -There are also great community resources, such as PowerShell.org, or PowerShell Magazine. -For more information on the DSC Resource Kit, check out this blog post. +This is the branch containing the latest release - no contributions should be made +directly to this branch. -## Installation -To install xComputerManagement module +### dev -Unzip the content under $env:ProgramFiles\WindowsPowerShell\Modules folder -To confirm installation: +[![Build status](https://ci.appveyor.com/api/projects/status/cg28qxeco39wgo9l/branch/dev?svg=true)](https://ci.appveyor.com/project/PowerShell/xComputerManagement/branch/dev) +[![codecov](https://codecov.io/gh/PowerShell/xComputerManagement/branch/dev/graph/badge.svg)](https://codecov.io/gh/PowerShell/xComputerManagement/branch/dev) -Run Get-DSCResource to see that xComputer is among the DSC Resources listed -Requirements -This module requires the latest version of PowerShell (v4.0, which ships in Windows 8.1 or Windows Server 2012R2). -To easily use PowerShell 4.0 on older operating systems, install WMF 4.0. -Please read the installation instructions that are present on both the download page and the release notes for WMF 4.0 +This is the development branch to which contributions should be proposed by contributors +as pull requests. This development branch will periodically be merged to the master +branch, and be released to [PowerShell Gallery](https://www.powershellgallery.com/). -## Description -The xComputerManagement module contains the following resources: -* xComputer - allows you to configure a computer by changing its name and modifying its domain or workgroup. -* xOfflineDomainJoin - allows you to join computers to an AD Domain using an [Offline Domain Join](https://technet.microsoft.com/en-us/library/offline-domain-join-djoin-step-by-step(v=ws.10).aspx) request file. +## Contributing + +Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md). ## xComputer + xComputer resource has following properties: * Name: The desired computer name * DomainName: The name of the domain to join -* JoinOU: The distinguished name of the organizational unit that the computer account will be created in +* JoinOU: The distinguished name of the organizational unit that the computer + account will be created in * WorkGroupName: The name of the workgroup * Credential: Credential to be used to join or leave domain -* CurrentOU: A read-only property that specifies the organizational unit that the computer account is currently in +* CurrentOU: A read-only property that specifies the organizational unit that + the computer account is currently in ## xOfflineDomainJoin -xOfflineDomainJoin resource is a [Single Instance](https://msdn.microsoft.com/en-us/powershell/dsc/singleinstance) resource that can only be used once in a configuration and has following properties: + +xOfflineDomainJoin resource is a [Single Instance](https://msdn.microsoft.com/en-us/powershell/dsc/singleinstance) +resource that can only be used once in a configuration and has following properties: * IsSingleInstance: Must be set to 'Yes'. Required. * RequestFile: The full path to the Offline Domain Join request file. Required. ## xScheduledTask -xScheduledTask resource is used to define basic recurring scheduled tasks on the local computer. -Tasks are created to run indefinitly based on the schedule defined. + +xScheduledTask resource is used to define basic recurring scheduled tasks on the +local computer. +Tasks are created to run indefinitely based on the schedule defined. xScheduledTask has the following properties: - * TaskName: The name of the task - * TaskPath: The path to the task - defaults to the root directory - * Description: The task description - * ActionExecutable: The path to the .exe for this task - * ActionArguments: The arguments to pass the executable - * ActionWorkingPath: The working path to specify for the executable - * ScheduleType: When should the task be executed ("Once", "Daily", "Weekly", "AtStartup", "AtLogOn") - * RepeatInterval: How many units (minutes, hours, days) between each run of this task? - * StartTime: The time of day this task should start at - defaults to 12:00 AM. Not valid for AtLogon and AtStartup tasks - * Ensure: Present if the task should exist, false if it should be removed - * Enable: True if the task should be enabled, false if it should be disabled - * ExecuteAsCredential: The credential this task should execute as. If not specified defaults to running as the local system account - * DaysInterval: Specifies the interval between the days in the schedule. An interval of 1 produces a daily schedule. An interval of 2 produces an every-other day schedule. - * RandomDelay: Specifies a random amount of time to delay the start time of the trigger. The delay time is a random time between the time the task triggers and the time that you specify in this setting. - * RepetitionDuration: Specifies how long the repetition pattern repeats after the task starts. - * DaysOfWeek: Specifies an array of the days of the week on which Task Scheduler runs the task. - * WeeksInterval: Specifies the interval between the weeks in the schedule. An interval of 1 produces a weekly schedule. An interval of 2 produces an every-other week schedule. - * User: Specifies the identifier of the user for a trigger that starts a task when a user logs on. - * DisallowDemandStart: Indicates whether the task is prohibited to run on demand or not. Defaults to $false - * DisallowHardTerminate: Indicates whether the task is prohibited to be terminated or not. Defaults to $false - * Compatibility: The task compatibility level. Defaults to Vista. Possible values: "AT","V1","Vista","Win7","Win8" - * AllowStartIfOnBatteries: Indicates whether the task should start if the machine is on batteries or not. Defaults to $false - * Hidden: Indicates that the task is hidden in the Task Scheduler UI. Defaults to $false - * RunOnlyIfIdle: Indicates that Task Scheduler runs the task only when the computer is idle. - * IdleWaitTimeout: Specifies the amount of time that Task Scheduler waits for an idle condition to occur. DateTime ; - * NetworkName: Specifies the name of a network profile that Task Scheduler uses to determine if the task can run. The Task Scheduler UI uses this setting for display purposes. Specify a network name if you specify the RunOnlyIfNetworkAvailable parameter. - * DisallowStartOnRemoteAppSession: Indicates that the task does not start if the task is triggered to run in a Remote Applications Integrated Locally (RAIL) session. - * StartWhenAvailable: Indicates that Task Scheduler can start the task at any time after its scheduled time has passed. - * DontStopIfGoingOnBatteries: Indicates that the task does not stop if the computer switches to battery power. - * WakeToRun: Indicates that Task Scheduler wakes the computer before it runs the task. - * IdleDuration: Specifies the amount of time that the computer must be in an idle state before Task Scheduler runs the task. - * RestartOnIdle: Indicates that Task Scheduler restarts the task when the computer cycles into an idle condition more than once. - * DontStopOnIdleEnd: Indicates that Task Scheduler does not terminate the task if the idle condition ends before the task is completed. - * ExecutionTimeLimit: Specifies the amount of time that Task Scheduler is allowed to complete the task. - * MultipleInstances: Specifies the policy that defines how Task Scheduler handles multiple instances of the task. Possible values: "IgnoreNew","Parallel","Queue" - * Priority: Specifies the priority level of the task. Priority must be an integer from 0 (highest priority) to 10 (lowest priority). The default value is 7. Priority levels 7 and 8 are used for background tasks. Priority levels 4, 5, and 6 are used for interactive tasks. - * RestartCount: Specifies the number of times that Task Scheduler attempts to restart the task. - * RestartInterval: Specifies the amount of time that Task Scheduler attempts to restart the task. - * RunOnlyIfNetworkAvailable: Indicates that Task Scheduler runs the task only when a network is available. Task Scheduler uses the NetworkID parameter and NetworkName parameter that you specify in this cmdlet to determine if the network is available. +* TaskName: The name of the task +* TaskPath: The path to the task - defaults to the root directory +* Description: The task description +* ActionExecutable: The path to the .exe for this task +* ActionArguments: The arguments to pass the executable +* ActionWorkingPath: The working path to specify for the executable +* ScheduleType: When should the task be executed + ("Once", "Daily", "Weekly", "AtStartup", "AtLogOn") +* RepeatInterval: How many units (minutes, hours, days) between each run of this + task? +* StartTime: The time of day this task should start at - defaults to 12:00 AM. + Not valid for AtLogon and AtStartup tasks +* Ensure: Present if the task should exist, false if it should be removed - defaults + to Present. +* Enable: True if the task should be enabled, false if it should be + disabled +* ExecuteAsCredential: The credential this task should execute as. If not + specified defaults to running as the local system account +* DaysInterval: Specifies the interval between the days in the schedule. An + interval of 1 produces a daily schedule. An interval of 2 produces an + every-other day schedule. +* RandomDelay: Specifies a random amount of time to delay the start time of the + trigger. The delay time is a random time between the time the task triggers + and the time that you specify in this setting. +* RepetitionDuration: Specifies how long the repetition pattern repeats after + the task starts. +* DaysOfWeek: Specifies an array of the days of the week on which Task Scheduler + runs the task. +* WeeksInterval: Specifies the interval between the weeks in the schedule. An + interval of 1 produces a weekly schedule. An interval of 2 produces an + every-other week schedule. +* User: Specifies the identifier of the user for a trigger that starts a task + when a user logs on. +* DisallowDemandStart: Indicates whether the task is prohibited to run on demand + or not. Defaults to $false +* DisallowHardTerminate: Indicates whether the task is prohibited to be terminated + or not. Defaults to $false +* Compatibility: The task compatibility level. Defaults to Vista. Possible + values: "AT","V1","Vista","Win7","Win8" +* AllowStartIfOnBatteries: Indicates whether the task should start if the machine + is on batteries or not. Defaults to $false +* Hidden: Indicates that the task is hidden in the Task Scheduler UI. Defaults + to $false +* RunOnlyIfIdle: Indicates that Task Scheduler runs the task only when the + computer is idle. +* IdleWaitTimeout: Specifies the amount of time that Task Scheduler waits for an + idle condition to occur. DateTime ; +* NetworkName: Specifies the name of a network profile that Task Scheduler uses + to determine if the task can run. The Task Scheduler UI uses this setting for + display purposes. Specify a network name if you specify theRunOnlyIfNetworkAvailable + parameter. +* DisallowStartOnRemoteAppSession: Indicates that the task does not start if the + task is triggered to run in a Remote Applications Integrated Locally (RAIL) session. +* StartWhenAvailable: Indicates that Task Scheduler can start the task at any + time after its scheduled time has passed. +* DontStopIfGoingOnBatteries: Indicates that the task does not stop if the + computer switches to battery power. +* WakeToRun: Indicates that Task Scheduler wakes the computer before it runs the + task. +* IdleDuration: Specifies the amount of time that the computer must be in an idle + state before Task Scheduler runs the task. +* RestartOnIdle: Indicates that Task Scheduler restarts the task when the computer + cycles into an idle condition more than once. +* DontStopOnIdleEnd: Indicates that Task Scheduler does not terminate the task if + the idle condition ends before the task is completed. +* ExecutionTimeLimit: Specifies the amount of time that Task Scheduler is allowed + to complete the task. +* MultipleInstances: Specifies the policy that defines how Task Scheduler handles + multiple instances of the task. Possible values: "IgnoreNew","Parallel","Queue" +* Priority: Specifies the priority level of the task. Priority must be an integer + from 0 (highest priority) to 10 (lowest priority). The default value is 7. + Priority levels 7 and 8 are used for background tasks. Priority levels 4, 5, + and 6 are used for interactive tasks. +* RestartCount: Specifies the number of times that Task Scheduler attempts to + restart the task. +* RestartInterval: Specifies the amount of time that Task Scheduler attempts to + restart the task. +* RunOnlyIfNetworkAvailable: Indicates that Task Scheduler runs the task only + when a network is available. Task Scheduler uses the NetworkID parameter and + NetworkName parameter that you specify in this cmdlet to determine if the + network is available. ## xPowerPlan + xPowerPlan resource has following properties: - * IsSingleInstance: Specifies the resource is a single instance, the value must be 'Yes'. - * Name: The name of the power plan to activate. - +* IsSingleInstance: Specifies the resource is a single instance, the value must + be 'Yes'. +* Name: The name of the power plan to activate. + ## xVirtualMemory -xVirtualMemory resource is used to set the properties of the paging file on the local computer. +xVirtualMemory resource is used to set the properties of the paging file on the +local computer. xVirtualMemory has the following properties: -* Type: The type of the paging settings, mandatory, out of "AutoManagePagingFile","CustomSize","SystemManagedSize","NoPagingFile" +* Type: The type of the paging settings, mandatory, out of "AutoManagePagingFile", + "CustomSize","SystemManagedSize","NoPagingFile" * Drive: The drive to enable paging on, mandatory. Ignored for "AutoManagePagingFile" -* InitialSize: The initial size in MB of the paging file. Ignored for Type "AutoManagePagingFile" and "SystemManagedSize" -* MaximumSize: The maximum size in MB of the paging file. Ignored for Type "AutoManagePagingFile" and "SystemManagedSize" +* InitialSize: The initial size in MB of the paging file. Ignored for Type + "AutoManagePagingFile" and "SystemManagedSize" +* MaximumSize: The maximum size in MB of the paging file. Ignored for Type + "AutoManagePagingFile" and "SystemManagedSize" ## Versions ### Unreleased -* xScheduledTask - - Fixed incorrect TaskPath handling [Fix #45](https://github.com/PowerShell/xComputerManagement/issues/45) -* xComputer: Changed comparision that validates if we are in the correct AD Domain to work correctly if FQDN wasn't used +* xComputer: Changed comparison that validates if we are in the correct AD + Domain to work correctly if FQDN wasn't used. +* Updated AppVeyor.yml to use AppVeyor.psm1 module in DSCResource.Tests. +* Removed Markdown.md errors. +* Added CodeCov.io support. +* xScheduledTask + * Fixed incorrect TaskPath handling - [Issue #45](https://github.com/PowerShell/xComputerManagement/issues/45) ### 2.0.0.0 + * Updated resources - - BREAKING CHANGE: xScheduledTask: Added nearly all available parameters for tasks + * BREAKING CHANGE: xScheduledTask: Added nearly all available parameters for tasks +* xVirtualMemory: + * Fixed failing tests. ### 1.10.0.0 -* Added resources - - xVirtualMemory - + +* Added resources: + * xVirtualMemory + ### 1.9.0.0 + * Added resources - - xPowerPlan + * xPowerPlan ### 1.8.0.0 -* Converted AppVeyor.yml to pull Pester from PSGallery instead of Chocolatey. + +* Converted AppVeyor.yml to pull Pester from PSGallery instead of + Chocolatey. * Changed AppVeyor.yml to use default image -* xScheduledTask: Fixed bug with different OS versions returning repeat interval differently +* xScheduledTask: Fixed bug with different OS versions returning repeat interval + differently ### 1.7.0.0 + * Added support for enabling or disabling scheduled tasks * The Name parameter resolves to $env:COMPUTERNAME when the value is localhost ### 1.6.0.0 + * Added the following resources: - * MSFT_xOfflineDomainJoin resource to join computers to an AD Domain using an Offline Domain Join request file. - * MSFT_xScheduledTask resource to control scheduled tasks on the local server + * MSFT_xOfflineDomainJoin resource to join computers to an AD Domain using an + Offline Domain Join request file. + * MSFT_xScheduledTask resource to control scheduled tasks on the local server * MSFT_xOfflineDomainJoin: Corrected localizedData.DomainAlreadyJoinedhMessage name. -* xComputer: Changed credential generation code in tests to avoid triggering PSSA rule PSAvoidUsingConvertToSecureStringWithPlainText. - Renamed unit test file to match the name of Resource file. +* xComputer: Changed credential generation code in tests to avoid triggering + PSSA rule PSAvoidUsingConvertToSecureStringWithPlainText. + Renamed unit test file to match the name of Resource file. ### 1.5.0.0 + * Update Unit tests to use the standard folder structure and test templates. * Added .gitignore to prevent commit of DSCResource.Tests. ### 1.4.0.0 + * Added validation to the Name parameter -* Added the JoinOU parameter which allows you to specify the organizational unit that the computer account will be created in -* Added the CurrentOU read-only property that shows the organizational unit that the computer account is currently in +* Added the JoinOU parameter which allows you to specify the organizational unit + that the computer account will be created in +* Added the CurrentOU read-only property that shows the organizational unit that + the computer account is currently in ### 1.3.0 + * xComputer - * Fixed issue with Test-TargetResource when not specifying Domain or Workgroup name - * Added tests + * Fixed issue with Test-TargetResource when not specifying Domain or + Workgroup name + * Added tests ### 1.2.2 -Added types to Get/Set/Test definitions to allow xResourceDesigner validation to succeed +* Added types to Get/Set/Test definitions to allow xResourceDesigner validation + to succeed ### 1.2 -Added functionality to enable moving computer from one domain to another -Modified Test-DscConfiguration logics when testing domain join +* Added functionality to enable moving computer from one domain to another +* Modified Test-DscConfiguration logics when testing domain join ### 1.0.0.0 -Initial release with the following resources -* xComputer - +* Initial release with the following resources: + * xComputer ## Examples + ### Change the Name and the Workgroup Name This configuration will set a machine name and changes the workgroup it is in. @@ -216,6 +296,7 @@ configuration Sample_xComputer_ChangeNameAndWorkGroup ``` ### Switch from a Workgroup to a Domain + This configuration sets the machine name and joins a domain. Note: this requires a credential. @@ -236,7 +317,7 @@ configuration Sample_xComputer_WorkgroupToDomain [pscredential]$Credential ) - #Import the required DSC Resources + # Import the required DSC Resources Import-DscResource -Module xComputerManagement Node $NodeName @@ -251,22 +332,26 @@ configuration Sample_xComputer_WorkgroupToDomain } -<#**************************** -To save the credential in plain-text in the mof file, use the following configuration data +<# +To save the credential in plain-text in the mof file, use the following +configuration data $ConfigData = @{ - AllNodes = @( - @{ - NodeName = "localhost" - # Allows credential to be saved in plain-text in the the *.mof instance document. - - PSDscAllowPlainTextPassword = $true - } - ) - } - -Sample_xComputer_WorkgroupToDomain -ConfigurationData $ConfigData -MachineName -credential (Get-Credential) -Domain -****************************#> + AllNodes = @( + @{ + NodeName = "localhost" + + # Allows credential to be saved in plain-text in the the *.mof + # instance document. + + PSDscAllowPlainTextPassword = $true + } + ) +} + +Sample_xComputer_WorkgroupToDomain -ConfigurationData $ConfigData ` + -MachineName -credential (Get-Credential) -Domain +#> ``` ### Change the Name while staying on the Domain @@ -288,7 +373,7 @@ function Sample_xComputer_ChangeNameInDomain [pscredential]$Credential ) - #Import the required DSC Resources + # Import the required DSC Resources Import-DscResource -Module xComputerManagement Node $NodeName @@ -301,27 +386,30 @@ function Sample_xComputer_ChangeNameInDomain } } -<#**************************** -To save the credential in plain-text in the mof file, use the following configuration data +<# +To save the credential in plain-text in the mof file, use the following +configuration data $ConfigData = @{ - AllNodes = @( - @{ - NodeName = "localhost"; + AllNodes = @( + @{ + NodeName = "localhost"; - # Allows credential to be saved in plain-text in the the *.mof instance document. + # Allows credential to be saved in plain-text + # in the the *.mof instance document. - PSDscAllowPlainTextPassword = $true; - } - ) - } - -Sample_xComputer_ChangeNameInDomain -ConfigurationData $ConfigData -MachineName -Credential (Get-Credential) + PSDscAllowPlainTextPassword = $true; + } + ) +} -*****************************#> +Sample_xComputer_ChangeNameInDomain -ConfigurationData $ConfigData ` + -MachineName -Credential (Get-Credential) +#> ``` ### Change the Name while staying on the Workgroup + This example will change the machines name while remaining on the workgroup. ```powershell @@ -349,6 +437,7 @@ function Sample_xComputer_ChangeNameInWorkgroup ``` ### Switch from a Domain to a Workgroup + This example switches the computer from a domain to a workgroup. Note: this requires a credential. @@ -369,7 +458,7 @@ function Sample_xComputer_DomainToWorkgroup [pscredential]$Credential ) - #Import the required DSC Resources + # Import the required DSC Resources Import-DscResource -Module xComputerManagement Node $NodeName @@ -383,25 +472,30 @@ function Sample_xComputer_DomainToWorkgroup } } -<#**************************** -To save the credential in plain-text in the mof file, use the following configuration data +<# +To save the credential in plain-text in the mof file, use the following +configuration data $ConfigData = @{ - AllNodes = @( - @{ - NodeName = "localhost"; - # Allows credential to be saved in plain-text in the the *.mof instance document. - - PSDscAllowPlainTextPassword = $true; - } - ) - } - -Sample_xComputer_DomainToWorkgroup -ConfigurationData $ConfigData -MachineName -credential (Get-Credential) -WorkGroup -****************************#> + AllNodes = @( + @{ + NodeName = "localhost"; + + # Allows credential to be saved in plain-text in the the *.mof + # instance document. + + PSDscAllowPlainTextPassword = $true; + } + ) +} + +Sample_xComputer_DomainToWorkgroup -ConfigurationData $ConfigData ` + -MachineName -credential (Get-Credential) -WorkGroup +#> ``` ### Join a Domain using an ODJ Request File + This example will join the computer to a domain using the ODJ request file C:\ODJ\ODJRequest.txt. ```powershell @@ -429,7 +523,9 @@ Start-DscConfiguration -Path Sample_xOfflineDomainJoin -Wait -Verbose -Force ``` ### Run a PowerShell script every 15 minutes on a server -This example will create a scheduled task that will call PowerShell.exe every 15 minutes to run a script saved locally. + +This example will create a scheduled task that will call PowerShell.exe every 15 +minutes to run a script saved locally. The script will be called as the local system account ```powershell @@ -459,7 +555,3 @@ configuration Sample_xScheduledTask Sample_xScheduledTask Start-DscConfiguration -Path Sample_xScheduledTask -Wait -Verbose -Force ``` - - -## Contributing -Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md). diff --git a/Tests/Unit/MSFT_xVirtualMemory.Tests.ps1 b/Tests/Unit/MSFT_xVirtualMemory.Tests.ps1 index d4e55081..1804ed90 100644 --- a/Tests/Unit/MSFT_xVirtualMemory.Tests.ps1 +++ b/Tests/Unit/MSFT_xVirtualMemory.Tests.ps1 @@ -43,7 +43,10 @@ try { Context 'When the system is in the desired present state' { BeforeEach { Mock -CommandName Get-CimInstance -MockWith { - [PSObject] @{ AutomaticManagedPageFile = $false; Name = 'D:\pagefile.sys' } + [PSObject] @{ + AutomaticManagedPageFile = $false + Name = 'D:\pagefile.sys' + } } -ModuleName $script:DSCResourceName -Verifiable } @@ -58,9 +61,10 @@ try { BeforeEach { Mock -CommandName Get-CimInstance -MockWith { [PSObject] @{ - InitialSize = 0 - MaximumSize = 0 - Name = "C:\pagefile.sys" + InitialSize = 0 + MaximumSize = 0 + AutomaticManagedPageFile = $false + Name = "C:\pagefile.sys" } } -ModuleName $script:DSCResourceName -Verifiable } diff --git a/appveyor.yml b/appveyor.yml index 9aef9786..9c42f29d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,14 +3,12 @@ #---------------------------------# version: 1.9.{build}.0 install: - - git clone https://github.com/PowerShell/DscResource.Tests - - ps: | - Push-Location - cd DscResource.Tests - Import-Module .\TestHelper.psm1 -force - Pop-Location - Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force - Install-Module -Name Pester -Repository PSGallery -Force + - git clone https://github.com/PowerShell/DscResource.Tests + + - ps: | + Import-Module "$env:APPVEYOR_BUILD_FOLDER\DscResource.Tests\AppVeyor.psm1" + Invoke-AppveyorInstallTask + #---------------------------------# # build configuration # #---------------------------------# @@ -23,12 +21,10 @@ build: false test_script: - ps: | - $testResultsFile = ".\TestsResults.xml" - $res = Invoke-Pester -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru - (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile)) - if ($res.FailedCount -gt 0) { - throw "$($res.FailedCount) tests failed." - } + Invoke-AppveyorTestScriptTask ` + -ExcludeTag @() ` + -CodeCoverage ` + -CodeCovIo #---------------------------------# # deployment configuration # @@ -36,30 +32,5 @@ test_script: # scripts to run before deployment deploy_script: - - ps: | - # Creating project artifact - $stagingDirectory = (Resolve-Path ..).Path - $manifest = Join-Path $pwd "xComputerManagement.psd1" - (Get-Content $manifest -Raw).Replace("1.9.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest - $zipFilePath = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip" - Add-Type -assemblyname System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::CreateFromDirectory($pwd, $zipFilePath) - - # Creating NuGet package artifact - New-Nuspec -packageName $env:APPVEYOR_PROJECT_NAME -version $env:APPVEYOR_BUILD_VERSION -author "Microsoft" -owners "Microsoft" -licenseUrl "https://github.com/PowerShell/DscResources/blob/master/LICENSE" -projectUrl "https://github.com/$($env:APPVEYOR_REPO_NAME)" -packageDescription $env:APPVEYOR_PROJECT_NAME -tags "DesiredStateConfiguration DSC DSCResourceKit" -destinationPath . - nuget pack ".\$($env:APPVEYOR_PROJECT_NAME).nuspec" -outputdirectory . - $nuGetPackageName = $env:APPVEYOR_PROJECT_NAME + "." + $env:APPVEYOR_BUILD_VERSION + ".nupkg" - $nuGetPackagePath = (Get-ChildItem $nuGetPackageName).FullName - - @( - # You can add other artifacts here - $zipFilePath, - $nuGetPackagePath - ) | % { - Write-Host "Pushing package $_ as Appveyor artifact" - Push-AppveyorArtifact $_ - } - - - - + - ps: | + Invoke-AppveyorAfterTestTask