Skip to content

Commit efef773

Browse files
authored
Merge pull request #7 from PowerShell/staging
sync origin
2 parents 3a1d191 + 112dbd8 commit efef773

File tree

16 files changed

+884
-823
lines changed

16 files changed

+884
-823
lines changed

dsc/authoringResourceMofDesigner.md

Lines changed: 75 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ Parameter name Description
2828
To create the properties, we use the **New-xDscResourceProperty** cmdlet. The following PowerShell commands create the properties described above.
2929

3030
```powershell
31-
PS C:\> $UserName = New-xDscResourceProperty –Name UserName -Type String -Attribute Key
32-
PS C:\> $Ensure = New-xDscResourceProperty –Name Ensure -Type String -Attribute Write –ValidateSet “Present”, “Absent”
33-
PS C:\> $DomainCredential = New-xDscResourceProperty –Name DomainCredential-Type PSCredential -Attribute Write
34-
PS C:\> $Password = New-xDscResourceProperty –Name Password -Type PSCredential -Attribute Write
31+
$UserName = New-xDscResourceProperty –Name UserName -Type String -Attribute Key
32+
$Ensure = New-xDscResourceProperty –Name Ensure -Type String -Attribute Write –ValidateSet “Present”, “Absent”
33+
$DomainCredential = New-xDscResourceProperty –Name DomainCredential-Type PSCredential -Attribute Write
34+
$Password = New-xDscResourceProperty –Name Password -Type PSCredential -Attribute Write
3535
```
3636

3737
## Create the resource
3838

3939
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.
4040

4141
```powershell
42-
PS C:\> New-xDscResource –Name Demo_ADUser –Property $UserName, $Ensure, $DomainCredential, $Password –Path ‘C:\Program Files\WindowsPowerShell\Modules’ –ModuleName Demo_DSCModule
42+
New-xDscResource –Name Demo_ADUser –Property $UserName, $Ensure, $DomainCredential, $Password –Path ‘C:\Program Files\WindowsPowerShell\Modules’ –ModuleName Demo_DSCModule
4343
```
4444

4545
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
5050
[ClassVersion("1.0.0.0"), FriendlyName("Demo_ADUser")]
5151
class Demo_ADUser : OMI_BaseResource
5252
{
53-
[Key] string UserName;
54-
[Write, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure;
55-
[Write, EmbeddedInstance("MSFT_Credential")] String DomainCredential;
56-
[Write, EmbeddedInstance("MSFT_Credential")] String Password;
53+
[Key] string UserName;
54+
[Write, ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure;
55+
[Write, EmbeddedInstance("MSFT_Credential")] String DomainCredential;
56+
[Write, EmbeddedInstance("MSFT_Credential")] String Password;
5757
};
5858
```
5959

@@ -62,95 +62,95 @@ The resource script is at **C:\Program Files\WindowsPowerShell\Modules\Demo_DSCM
6262
```powershell
6363
function Get-TargetResource
6464
{
65-
[CmdletBinding()]
66-
[OutputType([System.Collections.Hashtable])]
67-
param
68-
(
69-
[parameter(Mandatory = $true)]
70-
[System.String]
71-
$UserName
72-
)
73-
74-
#Write-Verbose "Use this cmdlet to deliver information about command processing."
75-
76-
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
77-
78-
79-
<#
80-
$returnValue = @{
81-
UserName = [System.String]
82-
Ensure = [System.String]
83-
DomainAdminCredential = [System.Management.Automation.PSCredential]
84-
Password = [System.Management.Automation.PSCredential]
85-
}
86-
87-
$returnValue
88-
#>
65+
[CmdletBinding()]
66+
[OutputType([System.Collections.Hashtable])]
67+
param
68+
(
69+
[parameter(Mandatory = $true)]
70+
[System.String]
71+
$UserName
72+
)
73+
74+
#Write-Verbose "Use this cmdlet to deliver information about command processing."
75+
76+
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
77+
78+
79+
<#
80+
$returnValue = @{
81+
UserName = [System.String]
82+
Ensure = [System.String]
83+
DomainAdminCredential = [System.Management.Automation.PSCredential]
84+
Password = [System.Management.Automation.PSCredential]
85+
}
86+
87+
$returnValue
88+
#>
8989
}
9090
9191
9292
function Set-TargetResource
9393
{
94-
[CmdletBinding()]
95-
param
96-
(
97-
[parameter(Mandatory = $true)]
98-
[System.String]
99-
$UserName,
94+
[CmdletBinding()]
95+
param
96+
(
97+
[parameter(Mandatory = $true)]
98+
[System.String]
99+
$UserName,
100100
101-
[ValidateSet("Present","Absent")]
102-
[System.String]
103-
$Ensure,
101+
[ValidateSet("Present","Absent")]
102+
[System.String]
103+
$Ensure,
104104
105-
[System.Management.Automation.PSCredential]
106-
$DomainAdminCredential,
105+
[System.Management.Automation.PSCredential]
106+
$DomainAdminCredential,
107107
108-
[System.Management.Automation.PSCredential]
109-
$Password
110-
)
108+
[System.Management.Automation.PSCredential]
109+
$Password
110+
)
111111
112-
#Write-Verbose "Use this cmdlet to deliver information about command processing."
112+
#Write-Verbose "Use this cmdlet to deliver information about command processing."
113113
114-
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
114+
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
115115
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
118118
119119
120120
}
121121
122122
123123
function Test-TargetResource
124124
{
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,
132132
133-
[ValidateSet("Present","Absent")]
134-
[System.String]
135-
$Ensure,
133+
[ValidateSet("Present","Absent")]
134+
[System.String]
135+
$Ensure,
136136
137-
[System.Management.Automation.PSCredential]
138-
$DomainAdminCredential,
137+
[System.Management.Automation.PSCredential]
138+
$DomainAdminCredential,
139139
140-
[System.Management.Automation.PSCredential]
141-
$Password
142-
)
140+
[System.Management.Automation.PSCredential]
141+
$Password
142+
)
143143
144-
#Write-Verbose "Use this cmdlet to deliver information about command processing."
144+
#Write-Verbose "Use this cmdlet to deliver information about command processing."
145145
146-
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
146+
#Write-Debug "Use this cmdlet to write debug information while troubleshooting."
147147
148148
149-
<#
150-
$result = [System.Boolean]
149+
<#
150+
$result = [System.Boolean]
151151
152-
$result
153-
#>
152+
$result
153+
#>
154154
}
155155
156156
@@ -164,8 +164,8 @@ If you need to add or modify the parameter list of the resource, you can call th
164164
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.
165165

166166
```powershell
167-
PS C:\> $lastLogon = New-xDscResourceProperty –Name LastLogon –Type Hashtable –Attribute Write –Description “For mapping users to their last log on time”
168-
PS C:\> Update-xDscResource –Name ‘Demo_ADUser’ –Property $UserName, $Ensure, $DomainCredential, $Password, $lastLogon -Force
167+
$lastLogon = New-xDscResourceProperty –Name LastLogon –Type Hashtable –Attribute Write –Description “For mapping users to their last log on time”
168+
Update-xDscResource –Name ‘Demo_ADUser’ –Property $UserName, $Ensure, $DomainCredential, $Password, $lastLogon -Force
169169
```
170170

171171
## Testing a resource schema
@@ -178,5 +178,4 @@ The Resource Designer tool exposes one more cmdlet that can be used to test the
178178
[Build Custom Windows PowerShell Desired State Configuration Resources](authoringResource.md)
179179

180180
#### Other Resources
181-
[xDscResourceDesigner Module](https://powershellgallery.com/packages/xDscResourceDesigner)
182-
181+
[xDscResourceDesigner Module](https://powershellgallery.com/packages/xDscResourceDesigner)

reference/3.0/Microsoft.PowerShell.Core/Import-Module.md

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -134,52 +134,43 @@ This command uses an explicit path to identify the module to import.
134134

135135
It also uses the **Verbose** common parameter to get a list of the items imported from the module.
136136
Without the **Verbose**, **PassThru**, or **AsCustomObject** parameter, **Import-Module** does not generate any output when it imports a module.
137+
137138
### Example 5
138139
```
139-
PS C:\> Import-Module BitsTransfer -cmdlet Add-BitsTransferFile, Get-BitsTransfer
140-
PS C:\> Get-Module BitsTransfer
141-
142-
Name : BitsTransfer
143-
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\BitsTransfer.psd1
144-
Description :
145-
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
146-
Version : 1.0.0.0
147-
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer
148-
ModuleType : Manifest
149-
PrivateData :
150-
AccessMode : ReadWrite
151-
ExportedAliases : {}
152-
ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Complete-BitsTransfer, Complete-BitsTransfer],
153-
[Get-BitsTransfer, Get-BitsTransfer], [Remove-BitsTransfer, Remove-BitsTransfer]...}
154-
ExportedFunctions : {}
155-
ExportedVariables : {}
156-
NestedModules : {Microsoft.BackgroundIntelligentTransfer.Management}
140+
PS C:\> Import-Module BitsTransfer -Cmdlet Add-BitsFile, Get-BitsTransfer
141+
PS C:\> (Get-Module BitsTransfer).ExportedCmdlets
142+
143+
Key Value
144+
--- -----
145+
Add-BitsFile Add-BitsFile
146+
Complete-BitsTransfer Complete-BitsTransfer
147+
Get-BitsTransfer Get-BitsTransfer
148+
Remove-BitsTransfer Remove-BitsTransfer
149+
Resume-BitsTransfer Resume-BitsTransfer
150+
Set-BitsTransfer Set-BitsTransfer
151+
Start-BitsTransfer Start-BitsTransfer
152+
Suspend-BitsTransfer Suspend-BitsTransfer
157153
158154
PS C:\> Get-Command -Module BitsTransfer
159155
160-
CommandType Name ModuleName
161-
----------- ---- ----------
162-
Cmdlet Add-BitsFile bitstransfer
163-
Cmdlet Complete-BitsTransfer bitstransfer
164-
Cmdlet Get-BitsTransfer bitstransfer
165-
Cmdlet Remove-BitsTransfer bitstransfer
166-
Cmdlet Resume-BitsTransfer bitstransfer
167-
Cmdlet Set-BitsTransfer bitstransfer
168-
Cmdlet Start-BitsTransfer bitstransfer
169-
Cmdlet Suspend-BitsTransfer bitstransfer
156+
CommandType Name Version Source
157+
----------- ---- ------- ------
158+
Cmdlet Add-BitsFile 2.0.0.0 BitsTransfer
159+
Cmdlet Get-BitsTransfer 2.0.0.0 BitsTransfer
170160
```
171161

172162
This example shows how to restrict the module members that are imported into the session and the effect of this command on the session.
173163

174-
The first command imports only the **Add-BitsTransfer** and **Get-BitsTransfer** cmdlets from the **BitsTransfer** module.
164+
The first command imports only the **Add-BitsFile** and **Get-BitsTransfer** cmdlets from the **BitsTransfer** module.
175165
The command uses the **Cmdlet** parameter to restrict the cmdlets that the module imports.
176166
You can also use the **Alias**, **Variable**, and **Function** parameters to restrict other members that a module imports.
177167

178168
The second command uses the Get-Module cmdlet to get the object that represents the **BitsTransfer** module.
179169
The **ExportedCmdlets** property lists all of the cmdlets that the module exports, even when they were not all imported.
180170

181171
The third command uses the **Module** parameter of the Get-Command cmdlet to get the commands that were imported from the **BitsTransfer** module.
182-
The results confirm that only the **Add-BitsTransfer** and **Get-BitsTransfer** cmdlets were imported.
172+
The results confirm that only the **Add-BitsFile** and **Get-BitsTransfer** cmdlets were imported.
173+
183174
### Example 6
184175
```
185176
PS C:\> Import-Module BitsTransfer -Prefix PS -PassThru

reference/4.0/Microsoft.PowerShell.Core/Import-Module.md

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -143,50 +143,39 @@ Without the **Verbose**, **PassThru**, or **AsCustomObject** parameter, **Import
143143

144144
### Example 5
145145
```
146-
PS C:\> Import-Module BitsTransfer -cmdlet Add-BitsTransferFile, Get-BitsTransfer
147-
PS C:\> Get-Module BitsTransfer
148-
149-
Name : BitsTransfer
150-
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\BitsTransfer.psd1
151-
Description :
152-
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
153-
Version : 1.0.0.0
154-
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer
155-
ModuleType : Manifest
156-
PrivateData :
157-
AccessMode : ReadWrite
158-
ExportedAliases : {}
159-
ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Complete-BitsTransfer, Complete-BitsTransfer],
160-
[Get-BitsTransfer, Get-BitsTransfer], [Remove-BitsTransfer, Remove-BitsTransfer]...}
161-
ExportedFunctions : {}
162-
ExportedVariables : {}
163-
NestedModules : {Microsoft.BackgroundIntelligentTransfer.Management}
146+
PS C:\> Import-Module BitsTransfer -Cmdlet Add-BitsFile, Get-BitsTransfer
147+
PS C:\> (Get-Module BitsTransfer).ExportedCmdlets
148+
149+
Key Value
150+
--- -----
151+
Add-BitsFile Add-BitsFile
152+
Complete-BitsTransfer Complete-BitsTransfer
153+
Get-BitsTransfer Get-BitsTransfer
154+
Remove-BitsTransfer Remove-BitsTransfer
155+
Resume-BitsTransfer Resume-BitsTransfer
156+
Set-BitsTransfer Set-BitsTransfer
157+
Start-BitsTransfer Start-BitsTransfer
158+
Suspend-BitsTransfer Suspend-BitsTransfer
164159
165160
PS C:\> Get-Command -Module BitsTransfer
166161
167-
CommandType Name ModuleName
168-
----------- ---- ----------
169-
Cmdlet Add-BitsFile bitstransfer
170-
Cmdlet Complete-BitsTransfer bitstransfer
171-
Cmdlet Get-BitsTransfer bitstransfer
172-
Cmdlet Remove-BitsTransfer bitstransfer
173-
Cmdlet Resume-BitsTransfer bitstransfer
174-
Cmdlet Set-BitsTransfer bitstransfer
175-
Cmdlet Start-BitsTransfer bitstransfer
176-
Cmdlet Suspend-BitsTransfer bitstransfer
162+
CommandType Name Version Source
163+
----------- ---- ------- ------
164+
Cmdlet Add-BitsFile 2.0.0.0 BitsTransfer
165+
Cmdlet Get-BitsTransfer 2.0.0.0 BitsTransfer
177166
```
178167

179168
This example shows how to restrict the module members that are imported into the session and the effect of this command on the session.
180169

181-
The first command imports only the **Add-BitsTransfer** and **Get-BitsTransfer** cmdlets from the **BitsTransfer** module.
170+
The first command imports only the **Add-BitsFile** and **Get-BitsTransfer** cmdlets from the **BitsTransfer** module.
182171
The command uses the **Cmdlet** parameter to restrict the cmdlets that the module imports.
183172
You can also use the **Alias**, **Variable**, and **Function** parameters to restrict other members that a module imports.
184173

185174
The second command uses the Get-Module cmdlet to get the object that represents the **BitsTransfer** module.
186175
The **ExportedCmdlets** property lists all of the cmdlets that the module exports, even when they were not all imported.
187176

188177
The third command uses the **Module** parameter of the Get-Command cmdlet to get the commands that were imported from the **BitsTransfer** module.
189-
The results confirm that only the **Add-BitsTransfer** and **Get-BitsTransfer** cmdlets were imported.
178+
The results confirm that only the **Add-BitsFile** and **Get-BitsTransfer** cmdlets were imported.
190179

191180
### Example 6
192181
```

0 commit comments

Comments
 (0)