A DSC resource module that contains helper resources not fitting elsewhere
MIT License
A DSC resource module that contains helper resources not fitting elsewhere. All of the resources in this repository are provided AS IS.
To install xDscHelper module either
Install-Module xDscHelper
in an elevated PowerShell sessionRun Get-DSCResource
to see that xDscHelper is among the DSC Resources listed
Requirements This module requires at least PowerShell v4.0, which ships in Windows 8.1 or Windows Server 2012R2.
The module xDscHelper contains the following resources:
This example for xWaitForItem waits for a hypothetic configuration file created by another system, process or product which a local service depends on:
configuration conf
{
Import-DscResource -ModuleName xDscHelper
node localhost
{
# Wait for a third party product or another system to create a file you need
xWaitForItem configFile
{
Path = 'C:\ConfigFileFromOtherSystem.ini'
Type = 'File'
MinimumLength = 1
}
# Use it as a dependency
Service myService
{
Name = 'IniNeedingService'
Path = 'C:\Svc\My.exe'
DependsOn = '[xWaitForItem]configFile'
}
}
}
This example for xWaitForItem waits for a folder to fully replicate it's contents:
configuration conf
{
Import-DscResource -ModuleName xDscHelper
node localhost
{
# Wait for e.g folder replication
xWaitForItem folderContents
{
Path = 'C:\SomeReplicatedFolder'
Type = 'Directory'
ChildItemCount = 25
}
# Use it as a dependency
Service myService
{
Name = 'FileNeedingService'
Path = 'C:\Svc\My.exe'
DependsOn = '[xWaitForItem]folderContents'
}
}
}
This example for xMaintenanceWindow defines a maintenance window for the second tuesday of each month from 10 pm to 6 am and uses it as a dependency for other resources:
configuration conf
{
Import-DscResource -ModuleName xDscHelper
node localhost
{
xMaintenanceWindow patchday
{
ScheduleStart = (Get-Date).Date.AddHours(22)
ScheduleEnd = (Get-Date).Date.AddHours(6)
ScheduleType = 'Monthly'
DayOfWeek = 'Tuesday'
DayOfMonth = 2
}
Package 1
{
DependsOn = '[xMaintenanceWindow]patchday'
...
}
Package 2
{
DependsOn = '[xMaintenanceWindow]patchday'
...
}
Package 3
{
DependsOn = '[xMaintenanceWindow]patchday'
...
}
}
}