-
Notifications
You must be signed in to change notification settings - Fork 0
/
DesiredStateConfiguration.ps1
109 lines (75 loc) · 2.06 KB
/
DesiredStateConfiguration.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Configuration MyConfig
{
Node NOMAD01 {
Service myBitsSvc
{
Name = "BITS"
State = "Running"
}
}
}
MyConfig
ise .\MyConfig\localhost.mof
#State of the service
Get-Service -Name "BITS" -ComputerName localhost, NOMAD01
Start-DscConfiguration -Path "C:\DSC\119521\MyConfig" -Wait -Verbose -ComputerName localhost, NOMAD01
Test-DscConfiguration
Test-DscConfiguration -CimSession NOMAD01
Get-DscResource
Find-Module | Out-GridView
Find-DscResource | Out-GridView
Find-DscResource -ModuleName *SharePoint*
Find-DscResource -Name *LoopBack*
Find-DscResource | Where-Object Name -Like *LoopBack*
Install-Module cWindowsOS
Get-DscLocalConfigurationManager
Get-DscLocalConfigurationManager -CimSession NOMAD01
Test-DscConfiguration
Get-DscLocalConfigurationStatus
Get-DscConfiguration
Configuration BitsCfg
{
Service myBitsSvc
{
Name = "BITS"
State = "Running"
}
}
#push configuration
$nodeID = [guid]::NewGuid()
Write-Host "EASYNOMADSERVER01 will now be known at $nodeID"
$shareName = "\\EASYNOMADSERVER01\DSCSMBPullServer"
dir $shareName
[DSClocalConfigurationManager()]
Configuration DemoConfigNow
{
param(
# Parameter help description
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty]
[string]
$shareName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty]
[string]
$NodeConfigurationId
)
}
Node EASYNOMADSERVER01
{
Settings{
ConfigurationMode = "ApplyAndAutoCorrect"
RefreshFrequencyMins = 30
ConfigurationModeFrequencyMins = 30
}
ConfigurationRepositoryShare PullConfigServer
{
SourcePath = $shareName
}
}
$mofPath = "C:\DSC\DesiredStateConfiguration"
DemoConfigNew - ShareName $shareName -NodeConfigurationId $nodeID -OutputPath $mofPath
Set-DscLocalConfigurationManager -Path $mofPath -ComputerName EASYNOMADSERVER01
Get-DscLocalConfigurationManager -CimSession EASYNOMADSERVER01
(Get-DscLocalConfigurationManager -CimSession EASYNOMADSERVER01).ConfigurationID
$nodeID