Ensure that multiple services are running
Description
This example shows how you can use the ServiceSet
composite resource to ensure multiple services
exist and are running.
With Ensure set to Present
, State set to Running
, and Name set tthe array of Dhcp
and MpsSvc
, the resource starts the Dhcp
and MpsSvc
services if they aren't running.
If either service doesn't exist, the resource raises an exception. The ServiceSet
composite
resource can't create services, only manage or remove existing ones. To create a service if it
doesn't exist, use the Service resource.
With Invoke-DscResource
The Invoke-DscResource
cmdlet doesn't support invoking composite resources. Instead, use the
Service resource.
With a Configuration
This snippet shows how you can define a Configuration
with a ServiceSet
resource block to ensure
that the Dhcp
and MpsSvc
services are running.
Configuration Start {
Import-DscResource -ModuleName 'PSDscResources'
Node localhost {
ServiceSet ExampleServiceSet {
Name = @(
'Dhcp'
'MpsSvc'
)
Ensure = 'Present'
State = 'Running'
}
}
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for