You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that the resource properties have been created, we can call the **New-xDscResource** cmdlet to create the resource. The **New-xDscResource** cmdlet takes the list of properties as parameters. It also takes the path where the module should be created, the name of the new resource, and the name of the module in which it is contained. The following PowerShell command creates the resource.
The **New-xDscResource** cmdlet creates the MOF schema, a skeleton resource script, the required directory structure for your new resource, and a manifest for the module that exposes the new resource.
@@ -50,10 +50,10 @@ The MOF schema file is at **C:\Program Files\WindowsPowerShell\Modules\Demo_DSCM
#Write-Verbose "Use this cmdlet to deliver information about command processing."
112
+
#Write-Verbose "Use this cmdlet to deliver information about command processing."
113
113
114
-
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
114
+
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
115
115
116
-
#Include this line if the resource requires a system reboot.
117
-
#$global:DSCMachineStatus = 1
116
+
#Include this line if the resource requires a system reboot.
117
+
#$global:DSCMachineStatus = 1
118
118
119
119
120
120
}
121
121
122
122
123
123
function Test-TargetResource
124
124
{
125
-
[CmdletBinding()]
126
-
[OutputType([System.Boolean])]
127
-
param
128
-
(
129
-
[parameter(Mandatory = $true)]
130
-
[System.String]
131
-
$UserName,
125
+
[CmdletBinding()]
126
+
[OutputType([System.Boolean])]
127
+
param
128
+
(
129
+
[parameter(Mandatory = $true)]
130
+
[System.String]
131
+
$UserName,
132
132
133
-
[ValidateSet("Present","Absent")]
134
-
[System.String]
135
-
$Ensure,
133
+
[ValidateSet("Present","Absent")]
134
+
[System.String]
135
+
$Ensure,
136
136
137
-
[System.Management.Automation.PSCredential]
138
-
$DomainAdminCredential,
137
+
[System.Management.Automation.PSCredential]
138
+
$DomainAdminCredential,
139
139
140
-
[System.Management.Automation.PSCredential]
141
-
$Password
142
-
)
140
+
[System.Management.Automation.PSCredential]
141
+
$Password
142
+
)
143
143
144
-
#Write-Verbose "Use this cmdlet to deliver information about command processing."
144
+
#Write-Verbose "Use this cmdlet to deliver information about command processing."
145
145
146
-
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
146
+
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
147
147
148
148
149
-
<#
150
-
$result = [System.Boolean]
149
+
<#
150
+
$result = [System.Boolean]
151
151
152
-
$result
153
-
#>
152
+
$result
153
+
#>
154
154
}
155
155
156
156
@@ -164,8 +164,8 @@ If you need to add or modify the parameter list of the resource, you can call th
164
164
For example, suppose you want to include the last log in time for the user in our resource. Rather than writing the resource again completely, you can call the **New-xDscResourceProperty** to create the new property, and then call **Update-xDscResource** and add your new property to the properties list.
165
165
166
166
```powershell
167
-
PS C:\> $lastLogon = New-xDscResourceProperty –Name LastLogon –Type Hashtable –Attribute Write –Description “For mapping users to their last log on time”
0 commit comments