Skip to content

Commit 02eed65

Browse files
authored
Merge pull request #4727 from MicrosoftDocs/staging
Merging latest changes to live
2 parents a02ccbe + 36ccb8e commit 02eed65

File tree

1,593 files changed

+19894
-14431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,593 files changed

+19894
-14431
lines changed

developer/cmdlet/defining-default-methods-for-objects.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,29 @@ ms.topic: "article"
99
ms.assetid: 53fe744a-485f-4c21-9623-1cb546372211
1010
caps.latest.revision: 9
1111
---
12+
1213
# Defining Default Methods for Objects
1314

14-
When you extend .NET Framework objects, you can add code methods and script methods to the objects. The XML that is used to define these methods is described in the following sections.
15+
When you extend .NET Framework objects, you can add code methods and script methods to the objects.
16+
The XML that is used to define these methods is described in the following sections.
1517

1618
> [!NOTE]
17-
> The examples in the following sections are from the Types.ps1xml types file in the Windows PowerShell installation directory (`$pshome`).
19+
> The examples in the following sections are from the `Types.ps1xml` types file in the Windows
20+
> PowerShell installation directory (`$PSHOME`). For more information, see [About Types.ps1xml](/powershell/module/microsoft.powershell.core/about/about_types.ps1xml).
1821
19-
## Code Methods
22+
## Code methods
2023

2124
A code method references a static method of a .NET Framework object.
2225

23-
In the following example, the **ConvertLargeIntegerToInt64** method is added to the [System.Xml.Xmlnode?Displayproperty=Fullname](/dotnet/api/System.Xml.XmlNode) type. The [PSCodeMethod](/dotnet/api/system.management.automation.pscodemethod) element defines the extended method as a code method. The [Name](/dotnet/api/system.management.automation.psmemberinfo.name?view=pscore-6.2.0#System_Management_Automation_PSMemberInfo_Name) element specifies the name of the extended method. And, the [CodeReference](/dotnet/api/system.management.automation.pscodemethod.codereference?view=pscore-6.2.0#System_Management_Automation_PSCodeMethod_CodeReference) element specifies the static method. (You can also add the [PSCodeMethod](/dotnet/api/system.management.automation.pscodemethod) element to the members of the [PSMemberSets](/dotnet/api/system.management.automation.psmemberset?view=pscore-6.2.0) element.)
26+
In the following example, the **ToString** method is added to the [System.Xml.XmlNode](/dotnet/api/System.Xml.XmlNode)
27+
type. The [PSCodeMethod](/dotnet/api/system.management.automation.pscodemethod) element defines the
28+
extended method as a code method. The
29+
[Name](/dotnet/api/system.management.automation.psmemberinfo.name?view=pscore-6.2.0#System_Management_Automation_PSMemberInfo_Name)
30+
element specifies the name of the extended method. And, the
31+
[CodeReference](/dotnet/api/system.management.automation.pscodemethod.codereference?view=pscore-6.2.0#System_Management_Automation_PSCodeMethod_CodeReference)
32+
element specifies the static method. You can also add the [PSCodeMethod](/dotnet/api/system.management.automation.pscodemethod)
33+
element to the members of the [PSMemberSets](/dotnet/api/system.management.automation.psmemberset?view=pscore-6.2.0)
34+
element.
2435

2536
```xml
2637
<Type>
@@ -29,17 +40,26 @@ In the following example, the **ConvertLargeIntegerToInt64** method is added to
2940
<CodeMethod>
3041
<Name>ToString</Name>
3142
<CodeReference>
32-
<TypeName>Microsoft.PowerShell.ToStringCodemethods</TypeName>
43+
<TypeName>Microsoft.PowerShell.ToStringCodeMethods</TypeName>
3344
<MethodName>XmlNode</MethodName>
3445
</CodeReference>
3546
</CodeMethod>
3647
</Members>
3748
</Type>
3849
```
3950

40-
## Script Methods
51+
## Script methods
4152

42-
A script method defines a method whose value is the output of a script. In the following example, the **ConvertToDateTime** method is added to the [System.Management.Managementobject?Displayproperty=Fullname](/dotnet/api/System.Management.ManagementObject) type. The [PSScriptMethod](/dotnet/api/system.management.automation.psscriptmethod?view=pscore-6.2.0) element defines the extended method as a script method. The [Name](/dotnet/api/system.management.automation.psmemberinfo.name?view=pscore-6.2.0#System_Management_Automation_PSMemberInfo_Name) element specifies the name of the extended method. And, the [Script](/dotnet/api/system.management.automation.psscriptmethod.script?view=pscore-6.2.0#System_Management_Automation_PSScriptMethod_Script) element specifies the script that generates the method value. (You can also add the [PSScriptMethod](/dotnet/api/system.management.automation.psscriptmethod?view=pscore-6.2.0) element to the members of the [PSMemberSets](/dotnet/api/system.management.automation.psmemberset?view=pscore-6.2.0) element.)
53+
A script method defines a method whose value is the output of a script. In the following example,
54+
the **ConvertToDateTime** method is added to the [System.Management.ManagementObject](/dotnet/api/System.Management.ManagementObject)
55+
type. The [PSScriptMethod](/dotnet/api/system.management.automation.psscriptmethod?view=pscore-6.2.0)
56+
element defines the extended method as a script method. The
57+
[Name](/dotnet/api/system.management.automation.psmemberinfo.name?view=pscore-6.2.0#System_Management_Automation_PSMemberInfo_Name)
58+
element specifies the name of the extended method. And, the
59+
[Script](/dotnet/api/system.management.automation.psscriptmethod.script?view=pscore-6.2.0#System_Management_Automation_PSScriptMethod_Script)
60+
element specifies the script that generates the method value. You can also add the [PSScriptMethod](/dotnet/api/system.management.automation.psscriptmethod?view=pscore-6.2.0)
61+
element to the members of the [PSMemberSets](/dotnet/api/system.management.automation.psmemberset?view=pscore-6.2.0)
62+
element.
4363

4464
```xml
4565
<Type>
@@ -55,6 +75,6 @@ A script method defines a method whose value is the output of a script. In the f
5575
</Type>
5676
```
5777

58-
## See Also
78+
## See also
5979

6080
[Writing a Windows PowerShell Cmdlet](./writing-a-windows-powershell-cmdlet.md)
Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,56 @@
11
---
22
title: "How to Import Cmdlets Using Modules | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "09/13/2016"
4+
ms.date: "08/28/2019"
55
ms.reviewer: ""
66
ms.suite: ""
77
ms.tgt_pltfrm: ""
88
ms.topic: "article"
99
ms.assetid: a41d9e5f-de6f-47b7-9601-c108609320d0
1010
caps.latest.revision: 8
1111
---
12+
1213
# How to Import Cmdlets Using Modules
1314

14-
This topic describes how to import cmdlets to a Windows PowerShell session by using a binary module.
15+
This article describes how to import cmdlets to a PowerShell session by using a binary module.
1516

1617
> [!NOTE]
17-
> The members of modules can include cmdlets, providers, functions, variables, aliases, and much more. Snap-ins can contain only cmdlets and providers.
18+
> The members of modules can include cmdlets, providers, functions, variables, aliases, and much
19+
> more. Snap-ins can contain only cmdlets and providers.
1820
1921
## How to load cmdlets using a module
2022

21-
1. Create a module folder that has the same name as the assembly file in which the cmdlets are implemented. In this procedure, the module folder is created in the `system32` folder.
23+
1. Create a module folder that has the same name as the assembly file in which the cmdlets are
24+
implemented. In this procedure, the module folder is created in the Windows `system32` folder.
2225

2326
`%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\mymodule`
2427

25-
2. Make sure that the `PSModulePath` environment variable includes the path to your new module folder. By default, the system folder is already added to the `PSModulePath` environment variable.
28+
1. Make sure that the `PSModulePath` environment variable includes the path to your new module
29+
folder. By default, the system folder is already added to the `PSModulePath` environment
30+
variable. To view the `PSModulePath`, type: `$env:PSModulePath`.
2631

27-
3. Copy the cmdlet assembly into the module folder.
32+
1. Copy the cmdlet assembly into the module folder.
2833

29-
4. Run the following command to add the cmdlets to the session:
34+
1. Add a module manifest file (`.psd1`) in the module's root folder. PowerShell uses the module
35+
manifest to import your module. For more information, see [How to Write a PowerShell Module Manifest](../module/how-to-write-a-powershell-module-manifest.md).
3036

31-
`import-module [Module_Name]`
37+
1. Run the following command to add the cmdlets to the session:
3238

33-
This procedure can be used to test your cmdlets. It adds all the cmdlets in the assembly to the session. For more information about modules, the different types of modules, the different ways to load modules, and how to restrict the elements of a module that are exported, see [Writing a Windows PowerShell Module](../module/writing-a-windows-powershell-module.md).
39+
`Import-Module [Module_Name]`
3440

35-
## See Also
41+
This procedure can be used to test your cmdlets. It adds all the cmdlets in the assembly to the
42+
session. For more information about modules, see [Writing a Windows PowerShell Module](../module/writing-a-windows-powershell-module.md).
3643

37-
[Writing a Windows PowerShell Cmdlet](./writing-a-windows-powershell-cmdlet.md)
44+
## See also
45+
46+
[How to Write a PowerShell Module Manifest](../module/how-to-write-a-powershell-module-manifest.md)
47+
48+
[Importing a PowerShell Module](../module/importing-a-powershell-module.md)
3849

39-
[Installing Modules](../module/installing-a-powershell-module.md)
50+
[Import-Module](/powershell/module/Microsoft.PowerShell.Core/Import-Module)
51+
52+
[Installing Modules](../module/installing-a-powershell-module.md)
53+
54+
[Modifying the PSModulePath Installation Path](../module/modifying-the-psmodulepath-installation-path.md)
55+
56+
[Writing a Windows PowerShell Cmdlet](./writing-a-windows-powershell-cmdlet.md)

dsc/configurations/import-dscresource.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ This usage has the following benefits:
7373
7474
When authoring the DSC configuration in ISE, PowerShell provides IntelliSence for resources and resource properties. Resource definitions under the `$pshome` module path are loaded automatically. When you import resources using the `Import-DSCResource` keyword, the specified resource definitions are added and Intellisense is expanded to include the imported resource's schema.
7575
76-
![Resource Intellisense](/media/resource-intellisense.png)
76+
![Resource Intellisense](../media/resource-intellisense.png)
7777
7878
> [!NOTE]
7979
> Beginning in PowerShell 5.0, tab completion was added to the ISE for DSC resources and their properties. For more information, see [Resources](../resources/resources.md).
@@ -132,11 +132,11 @@ Installing and using multiple versions of resources side by side was not support
132132
133133
In the image below, two versions of the **xPSDesiredStateConfiguration** module are installed.
134134
135-
![Multiple Resource Versions Fixed](/media/multiple-resource-versions-broken.md)
135+
![Multiple Resource Versions Fixed](../media/multiple-resource-versions-broken.png)
136136
137137
Copy the contents of your desired module version to the top level of the module directory.
138138
139-
![Multiple Resource Versions Fixed](/media/multiple-resource-versions-fixed.md)
139+
![Multiple Resource Versions Fixed](../media/multiple-resource-versions-fixed.png)
140140
141141
### Resource location
142142

dsc/managing-nodes/metaConfig.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ A **ConfigurationRepositoryWeb** defines the following properties.
129129
|ProxyURL*|string|The URL of the http proxy to use when communicating with the configuration service.|
130130
|ProxyCredential*|pscredential|Credential to use for the http proxy.|
131131

132-
>!NOTE
133-
>\* Supported in Windows versions 1809 and later.
132+
> [!NOTE]
133+
> * Supported in Windows versions 1809 and later.
134134
135135
An example script to simplify configuring the ConfigurationRepositoryWeb value for on-premises nodes
136136
is available - see [Generating DSC metaconfigurations](https://docs.microsoft.com/azure/automation/automation-dsc-onboarding#generating-dsc-metaconfigurations)
@@ -158,8 +158,8 @@ A **ResourceRepositoryWeb** defines the following properties.
158158
|ProxyURL*|string|The URL of the http proxy to use when communicating with the configuration service.|
159159
|ProxyCredential*|pscredential|Credential to use for the http proxy.|
160160

161-
>!NOTE
162-
>\* Supported in Windows versions 1809 and later.
161+
> [!NOTE]
162+
> * Supported in Windows versions 1809 and later.
163163
164164
An example script to simplify configuring the ResourceRepositoryWeb value for on-premises nodes
165165
is available - see [Generating DSC metaconfigurations](https://docs.microsoft.com/azure/automation/automation-dsc-onboarding#generating-dsc-metaconfigurations)
@@ -188,8 +188,8 @@ The report server role is not compatible with SMB based pull service.
188188
|ProxyURL*|string|The URL of the http proxy to use when communicating with the configuration service.|
189189
|ProxyCredential*|pscredential|Credential to use for the http proxy.|
190190

191-
>!NOTE
192-
>\* Supported in Windows versions 1809 and later.
191+
> [!NOTE]
192+
> * Supported in Windows versions 1809 and later.
193193
194194
An example script to simplify configuring the ReportServerWeb value for on-premises nodes
195195
is available - see [Generating DSC metaconfigurations](https://docs.microsoft.com/azure/automation/automation-dsc-onboarding#generating-dsc-metaconfigurations)

dsc/resources/get-test-set.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title: Get-Test-Set
88

99
>Applies To: Windows PowerShell 4.0, Windows PowerShell 5.0
1010
11-
![Get, Test, and Set](/media/get-test-set.png)
11+
![Get, Test, and Set](../media/get-test-set.png)
1212

1313
PowerShell Desired State Configuration is constructed around a **Get**, **Test**, and **Set** process. DSC [resources](resources.md) each contains methods to complete each of these operations. In a [Configuration](../configurations/configurations.md), you define resource blocks to fill in keys that become parameters for a resource's **Get**, **Test**, and **Set** methods.
1414

0 commit comments

Comments
 (0)