diff --git a/reference/docs-conceptual/developer/hosting/runspace-samples.md b/reference/docs-conceptual/developer/hosting/runspace-samples.md index 39c24fa426b8..b97c2894b868 100644 --- a/reference/docs-conceptual/developer/hosting/runspace-samples.md +++ b/reference/docs-conceptual/developer/hosting/runspace-samples.md @@ -14,36 +14,36 @@ This section includes sample code that shows how to use different types of runsp > For samples of host applications that create custom host interfaces, see [Custom Host Samples](./custom-host-samples.md). [Runspace01 Sample](./runspace01-sample.md) - This sample shows how to use the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) class to run the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) cmdlet synchronously and display its output in a console window. + This sample shows how to use the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) class to run the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) cmdlet synchronously and display its output in a console window. [Runspace02 Sample](./runspace02-sample.md) - This sample shows how to use the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) class to run the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) and [Sort-Object](/powershell/module/Microsoft.PowerShell.Utility/Sort-Object) cmdlets synchronously. The results of these commands is displayed by using a [System.Windows.Forms.Datagridview](/dotnet/api/System.Windows.Forms.DataGridView) control. + This sample shows how to use the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) class to run the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) and [Sort-Object](/powershell/module/Microsoft.PowerShell.Utility/Sort-Object) cmdlets synchronously. The results of these commands is displayed by using a [System.Windows.Forms.DataGridView](/dotnet/api/System.Windows.Forms.DataGridView) control. [Runspace03 Sample](./runspace03-sample.md) - This sample shows how to use the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) class to run a script synchronously, and how to handle non-terminating errors. The script receives a list of process names and then retrieves those processes. The results of the script, including any non-terminating errors that were generated when running the script, are displayed in a console window. + This sample shows how to use the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) class to run a script synchronously, and how to handle non-terminating errors. The script receives a list of process names and then retrieves those processes. The results of the script, including any non-terminating errors that were generated when running the script, are displayed in a console window. [Runspace04 Sample](./runspace04-sample.md) - This sample shows how to use the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) class to run commands, and how to catch terminating errors that are thrown when running the commands. Two commands are run, and the last command is passed a parameter argument that is not valid. As a result no objects are returned and a terminating error is thrown. + This sample shows how to use the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) class to run commands, and how to catch terminating errors that are thrown when running the commands. Two commands are run, and the last command is passed a parameter argument that is not valid. As a result no objects are returned and a terminating error is thrown. [Runspace05 Sample](./runspace05-sample.md) - This sample shows how to add a snap-in to a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object so that the cmdlet of the snap-in is available when the runspace is opened. The snap-in provides a Get-Proc cmdlet (defined by the [GetProcessSample01 Sample](../cmdlet/getprocesssample01-sample.md)) that is run synchronously using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. + This sample shows how to add a snap-in to a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object so that the cmdlet of the snap-in is available when the runspace is opened. The snap-in provides a Get-Proc cmdlet (defined by the [GetProcessSample01 Sample](../cmdlet/getprocesssample01-sample.md)) that is run synchronously using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. [Runspace06 Sample](./runspace06-sample.md) - This sample shows how to add a module to a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object so that the module is loaded when the runspace is opened. The module provides a Get-Proc cmdlet (defined by the [GetProcessSample02 Sample](../cmdlet/getprocesssample02-sample.md)) that is run synchronously using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. + This sample shows how to add a module to a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object so that the module is loaded when the runspace is opened. The module provides a Get-Proc cmdlet (defined by the [GetProcessSample02 Sample](../cmdlet/getprocesssample02-sample.md)) that is run synchronously using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. [Runspace07 Sample](./runspace07-sample.md) - This sample shows how to create a runspace, and then use that runspace to run two cmdlets synchronously by using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. + This sample shows how to create a runspace, and then use that runspace to run two cmdlets synchronously by using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. [Runspace08 Sample](./runspace08-sample.md) - This sample shows how to add commands and arguments to the pipeline of a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object and how to run the commands synchronously. + This sample shows how to add commands and arguments to the pipeline of a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object and how to run the commands synchronously. [Runspace09 Sample](./runspace09-sample.md) - This sample shows how to add a script to the pipeline of a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object and how to run the script asynchronously. Events are used to handle the output of the script. + This sample shows how to add a script to the pipeline of a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object and how to run the script asynchronously. Events are used to handle the output of the script. [Runspace10 Sample](./runspace10-sample.md) - This sample shows how to create a default initial session state, how to add a cmdlet to the [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState), how to create a runspace that uses the initial session state, and how to run the command by using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. + This sample shows how to create a default initial session state, how to add a cmdlet to the [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState), how to create a runspace that uses the initial session state, and how to run the command by using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. [Runspace11 Sample](./runspace11-sample.md) - This shows how to use the [System.Management.Automation.Proxycommand](/dotnet/api/System.Management.Automation.ProxyCommand) class to create a proxy command that calls an existing cmdlet, but restricts the set of available parameters. The proxy command is then added to an initial session state that is used to create a constrained runspace. This means that the user can access the functionality of the cmdlet only through the proxy command. + This shows how to use the [System.Management.Automation.ProxyCommand](/dotnet/api/System.Management.Automation.ProxyCommand) class to create a proxy command that calls an existing cmdlet, but restricts the set of available parameters. The proxy command is then added to an initial session state that is used to create a constrained runspace. This means that the user can access the functionality of the cmdlet only through the proxy command. ## See Also diff --git a/reference/docs-conceptual/developer/hosting/runspace05-sample.md b/reference/docs-conceptual/developer/hosting/runspace05-sample.md index 89f7f4234104..ade3279186fe 100644 --- a/reference/docs-conceptual/developer/hosting/runspace05-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace05-sample.md @@ -6,7 +6,7 @@ title: Runspace05 Sample --- # Runspace05 Sample -This sample shows how to add a snap-in to a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object so that the cmdlet of the snap-in is available when the runspace is opened. The snap-in provides a Get-Proc cmdlet (defined by the [GetProcessSample01 Sample](../cmdlet/getprocesssample01-sample.md)) that is run synchronously by using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +This sample shows how to add a snap-in to a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object so that the cmdlet of the snap-in is available when the runspace is opened. The snap-in provides a Get-Proc cmdlet (defined by the [GetProcessSample01 Sample](../cmdlet/getprocesssample01-sample.md)) that is run synchronously by using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. ## Requirements @@ -16,15 +16,15 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Creating a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. -- Adding the snap-in to the [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Adding the snap-in to the [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. -- Creating a [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object that uses the [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Creating a [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object that uses the [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. -- Adding the snap-in's get-proc cmdlet to the pipeline of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding the snap-in's Get-Proc cmdlet to the pipeline of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. - Running the command synchronously. @@ -32,7 +32,7 @@ This sample demonstrates the following. ## Example -This sample creates a runspace that uses a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to define the elements that are available when the runspace is opened. In this sample, a snap-in that defines a Get-Proc cmdlet is added to the initial session state. +This sample creates a runspace that uses a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to define the elements that are available when the runspace is opened. In this sample, a snap-in that defines a Get-Proc cmdlet is added to the initial session state. ```csharp namespace Microsoft.Samples.PowerShell.Runspaces @@ -63,7 +63,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces /// 2. Adding a snap-in to the initial session state. /// 3. Creating a runspace that uses the initial session state. /// 4. Creating a PowerShell object that uses the runspace. - /// 5. Adding the snap-in's get-proc cmdlet to the PowerShell object. + /// 5. Adding the snap-in's Get-Proc cmdlet to the PowerShell object. /// 6. Using PSObject objects to extract and display properties from /// the objects returned by the cmdlet. /// @@ -87,7 +87,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces using (PowerShell powershell = PowerShell.Create()) { // Add the snap-in cmdlet and specify the runspace. - powershell.AddCommand("GetProcPSSnapIn01\\get-proc"); + powershell.AddCommand("GetProcPSSnapIn01\\Get-Proc"); powershell.Runspace = myRunSpace; // Run the cmdlet synchronously. diff --git a/reference/docs-conceptual/developer/hosting/runspace06-sample.md b/reference/docs-conceptual/developer/hosting/runspace06-sample.md index 774974a5c67a..8dd004651d32 100644 --- a/reference/docs-conceptual/developer/hosting/runspace06-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace06-sample.md @@ -6,7 +6,7 @@ title: Runspace06 Sample --- # Runspace06 Sample -This sample shows how to add a module to a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object so that the module is loaded when the runspace is opened. The module provides a Get-Proc cmdlet (defined by the [GetProcessSample02 Sample](../cmdlet/getprocesssample02-sample.md)) that is run synchronously by using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +This sample shows how to add a module to a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object so that the module is loaded when the runspace is opened. The module provides a Get-Proc cmdlet (defined by the [GetProcessSample02 Sample](../cmdlet/getprocesssample02-sample.md)) that is run synchronously by using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. ## Requirements @@ -16,15 +16,15 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Creating a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. -- Adding the module to the [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Adding the module to the [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. -- Creating a [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object that uses the [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Creating a [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object that uses the [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. -- Adding the module's get-proc cmdlet to the pipeline of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding the module's Get-Proc cmdlet to the pipeline of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. - Running the command synchronously. @@ -32,7 +32,7 @@ This sample demonstrates the following. ## Example -This sample creates a runspace that uses a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to define the elements that are available when the runspace is opened. In this sample, a module that defines a Get-Proc cmdlet is added to the initial session state. +This sample creates a runspace that uses a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to define the elements that are available when the runspace is opened. In this sample, a module that defines a Get-Proc cmdlet is added to the initial session state. ```csharp namespace Microsoft.Samples.PowerShell.Runspaces @@ -63,7 +63,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces /// 2. Adding a module to the initial session state. /// 3. Creating a runspace that uses the initial session state. /// 4. Creating a PowerShell object that uses the runspace. - /// 5. Adding the module's get-proc cmdlet to the PowerShell object. + /// 5. Adding the module's Get-Proc cmdlet to the PowerShell object. /// 6. Running the command synchronously. /// 7. Using PSObject objects to extract and display properties from /// the objects returned by the cmdlet. @@ -85,7 +85,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces using (PowerShell powershell = PowerShell.Create()) { // Add the cmdlet and specify the runspace. - powershell.AddCommand(@"GetProcessSample02\get-proc"); + powershell.AddCommand(@"GetProcessSample02\Get-Proc"); powershell.Runspace = myRunSpace; Collection results = powershell.Invoke(); diff --git a/reference/docs-conceptual/developer/hosting/runspace07-sample.md b/reference/docs-conceptual/developer/hosting/runspace07-sample.md index fb4e7835df94..b117e4f4c747 100644 --- a/reference/docs-conceptual/developer/hosting/runspace07-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace07-sample.md @@ -6,7 +6,7 @@ title: Runspace07 Sample --- # Runspace07 Sample -This sample shows how to create a runspace, and then use that runspace to run two cmdlets synchronously by using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +This sample shows how to create a runspace, and then use that runspace to run two cmdlets synchronously by using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. ## Requirements @@ -16,11 +16,11 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object by using the [System.Management.Automation.Runspaces.Runspacefactory](/dotnet/api/System.Management.Automation.Runspaces.RunspaceFactory) class. +- Creating a [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object by using the [System.Management.Automation.Runspaces.RunspaceFactory](/dotnet/api/System.Management.Automation.Runspaces.RunspaceFactory) class. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. -- Adding cmdlets to the pipeline of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding cmdlets to the pipeline of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. - Running the cmdlets synchronously. @@ -47,7 +47,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces /// /// This sample shows how to create a runspace and how to run commands /// using a PowerShell object. It builds a pipeline that runs the - /// get-process cmdlet, which is piped to the measure-object + /// Get-Process cmdlet, which is piped to the Measure-Object /// cmdlet to count the number of processes running on the system. /// /// The parameter is not used. @@ -83,14 +83,14 @@ namespace Microsoft.Samples.PowerShell.Runspaces // when we're done. using (powershell) { - // Add the get-process cmdlet to the PowerShell object. Notice + // Add the Get-Process cmdlet to the PowerShell object. Notice // we are specify the name of the cmdlet, not a script. - powershell.AddCommand("get-process"); + powershell.AddCommand("Get-Process"); - // Add the measure-object cmdlet to count the number + // Add the Measure-Object cmdlet to count the number // of objects being returned. Commands are always added to the end // of the pipeline. - powershell.AddCommand("measure-object"); + powershell.AddCommand("Measure-Object"); // Run the cmdlets synchronously and save the objects returned. result = powershell.Invoke(); diff --git a/reference/docs-conceptual/developer/hosting/runspace08-sample.md b/reference/docs-conceptual/developer/hosting/runspace08-sample.md index f24fc13b803f..f6c26ef82ed8 100644 --- a/reference/docs-conceptual/developer/hosting/runspace08-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace08-sample.md @@ -6,7 +6,7 @@ title: Runspace08 Sample --- # Runspace08 Sample -This sample shows how to add commands and arguments to the pipeline of a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object and how to run the commands synchronously. +This sample shows how to add commands and arguments to the pipeline of a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object and how to run the commands synchronously. ## Requirements @@ -16,11 +16,11 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object by using the [System.Management.Automation.Runspaces.Runspacefactory](/dotnet/api/System.Management.Automation.Runspaces.RunspaceFactory) class. +- Creating a [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object by using the [System.Management.Automation.Runspaces.RunspaceFactory](/dotnet/api/System.Management.Automation.Runspaces.RunspaceFactory) class. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. -- Adding cmdlets to the pipeline of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding cmdlets to the pipeline of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. - Running the cmdlets synchronously. @@ -28,7 +28,7 @@ This sample demonstrates the following. ## Example -This sample runs the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) and [Sort-Object](/powershell/module/Microsoft.PowerShell.Utility/Sort-Object) cmdlets by using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +This sample runs the [Get-Process](/powershell/module/Microsoft.PowerShell.Management/Get-Process) and [Sort-Object](/powershell/module/Microsoft.PowerShell.Utility/Sort-Object) cmdlets by using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. ```csharp namespace Microsoft.Samples.PowerShell.Runspaces @@ -47,9 +47,9 @@ namespace Microsoft.Samples.PowerShell.Runspaces { /// /// This sample shows how to use a PowerShell object to run commands. The - /// PowerShell object builds a pipeline that include the get-process cmdlet, - /// which is then piped to the sort-object cmdlet. Parameters are added to the - /// sort-object cmdlet to sort the HandleCount property in descending order. + /// PowerShell object builds a pipeline that include the Get-Process cmdlet, + /// which is then piped to the Sort-Object cmdlet. Parameters are added to the + /// Sort-Object cmdlet to sort the HandleCount property in descending order. /// /// Parameter is not used. /// @@ -73,13 +73,13 @@ namespace Microsoft.Samples.PowerShell.Runspaces // when we are done. using (powershell) { - // Add the get-process cmdlet to the pipeline of the PowerShell object. - powershell.AddCommand("get-process"); + // Add the Get-Process cmdlet to the pipeline of the PowerShell object. + powershell.AddCommand("Get-Process"); - // Add the sort-object cmdlet and its parameters to the pipeline of + // Add the Sort-Object cmdlet and its parameters to the pipeline of // the PowerShell object so that we can sort the HandleCount property // in descending order. - powershell.AddCommand("sort-object").AddParameter("descending").AddParameter("property", "handlecount"); + powershell.AddCommand("Sort-Object").AddParameter("Descending").AddParameter("Property", "HandleCount"); // Run the commands of the pipeline synchronously. results = powershell.Invoke(); diff --git a/reference/docs-conceptual/developer/hosting/runspace09-sample.md b/reference/docs-conceptual/developer/hosting/runspace09-sample.md index 692d19c789ac..bf1bae5302fb 100644 --- a/reference/docs-conceptual/developer/hosting/runspace09-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace09-sample.md @@ -6,7 +6,7 @@ title: Runspace09 Sample --- # Runspace09 Sample -This sample shows how to add a script to the pipeline of a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object and how to run the script asynchronously. Events are used to handle the output of the script. +This sample shows how to add a script to the pipeline of a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object and how to run the script asynchronously. Events are used to handle the output of the script. ## Requirements @@ -16,15 +16,15 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object that uses the runspace. -- Adding a script the pipeline of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding a script the pipeline of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. -- Using the [System.Management.Automation.Powershell.Begininvoke*](/dotnet/api/System.Management.Automation.PowerShell.BeginInvoke) method to run the pipeline asynchronously. +- Using the [System.Management.Automation.PowerShell.BeginInvoke*](/dotnet/api/System.Management.Automation.PowerShell.BeginInvoke) method to run the pipeline asynchronously. -- Using the events of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object to process the output of the script. +- Using the events of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object to process the output of the script. -- Using the [System.Management.Automation.Powershell.Stop*](/dotnet/api/System.Management.Automation.PowerShell.Stop) method to interrupt the invocation of the pipeline. +- Using the [System.Management.Automation.PowerShell.Stop*](/dotnet/api/System.Management.Automation.PowerShell.Stop) method to interrupt the invocation of the pipeline. ## Example @@ -71,7 +71,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces { // Add a script to the PowerShell object. The script generates the // numbers from 1 to 10 in half second intervals. - powershell.AddScript("1..10 | foreach {$_ ; start-sleep -milli 500}"); + powershell.AddScript("1..10 | foreach {$_ ; Start-Sleep -Milli 500}"); // Add the event handlers. If we did not care about hooking the DataAdded // event, we would let BeginInvoke create the output stream for us. diff --git a/reference/docs-conceptual/developer/hosting/runspace10-sample.md b/reference/docs-conceptual/developer/hosting/runspace10-sample.md index f2562d27229f..8997babf17de 100644 --- a/reference/docs-conceptual/developer/hosting/runspace10-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace10-sample.md @@ -6,7 +6,7 @@ title: Runspace10 Sample --- # Runspace10 Sample -This sample shows how to create a default initial session state, how to add a cmdlet to the [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState), how to create a runspace that uses the initial session state, and how to run the command by using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +This sample shows how to create a default initial session state, how to add a cmdlet to the [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState), how to create a runspace that uses the initial session state, and how to run the command by using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. ## Requirements @@ -16,21 +16,21 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Creating a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. -- Adding a cmdlet (defined by the Host application) to the [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Adding a cmdlet (defined by the Host application) to the [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. - Creating a [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object that uses the object. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object that uses the [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object that uses the [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object. -- Adding the command to the pipeline of the [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +- Adding the command to the pipeline of the [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. - Extracting properties from the [System.Management.Automation.PSObject](/dotnet/api/System.Management.Automation.PSObject) objects returned by the command. ## Example -This sample creates a runspace that uses a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to define the elements that are available when the runspace is opened. In this sample, the Get-Proc cmdlet (defined by the Host application) is added to the initial session state, and the cmdlet is run synchronously by using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object. +This sample creates a runspace that uses a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to define the elements that are available when the runspace is opened. In this sample, the Get-Proc cmdlet (defined by the Host application) is added to the initial session state, and the cmdlet is run synchronously by using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object. ```csharp namespace Microsoft.Samples.PowerShell.Runspaces @@ -100,8 +100,8 @@ namespace Microsoft.Samples.PowerShell.Runspaces // by Windows PowerShell. InitialSessionState iss = InitialSessionState.CreateDefault(); - // Add the get-proc cmdlet to the InitialSessionState object. - SessionStateCmdletEntry ssce = new SessionStateCmdletEntry("get-proc", typeof(GetProcCommand), null); + // Add the Get-Proc cmdlet to the InitialSessionState object. + SessionStateCmdletEntry ssce = new SessionStateCmdletEntry("Get-Proc", typeof(GetProcCommand), null); iss.Commands.Add(ssce); // Create a Runspace object that uses the InitialSessionState object. @@ -115,8 +115,8 @@ namespace Microsoft.Samples.PowerShell.Runspaces { powershell.Runspace = myRunSpace; - // Add the get-proc cmdlet to the pipeline of the PowerShell object. - powershell.AddCommand("get-proc"); + // Add the Get-Proc cmdlet to the pipeline of the PowerShell object. + powershell.AddCommand("Get-Proc"); Collection results = powershell.Invoke(); diff --git a/reference/docs-conceptual/developer/hosting/runspace11-sample.md b/reference/docs-conceptual/developer/hosting/runspace11-sample.md index ee1089385e56..4fc1c63e0bea 100644 --- a/reference/docs-conceptual/developer/hosting/runspace11-sample.md +++ b/reference/docs-conceptual/developer/hosting/runspace11-sample.md @@ -6,7 +6,7 @@ title: Runspace11 Sample --- # Runspace11 Sample -This sample shows how to use the [System.Management.Automation.Proxycommand](/dotnet/api/System.Management.Automation.ProxyCommand) class to create a proxy command that calls an existing cmdlet, but restricts the set of available parameters. The proxy command is then added to an initial session state that is used to create a constrained runspace. This means that the user can access the functionality of the cmdlet only through the proxy command. +This sample shows how to use the [System.Management.Automation.ProxyCommand](/dotnet/api/System.Management.Automation.ProxyCommand) class to create a proxy command that calls an existing cmdlet, but restricts the set of available parameters. The proxy command is then added to an initial session state that is used to create a constrained runspace. This means that the user can access the functionality of the cmdlet only through the proxy command. ## Requirements @@ -16,21 +16,21 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following. -- Creating a [System.Management.Automation.Commandmetadata](/dotnet/api/System.Management.Automation.CommandMetadata) object that describes the metadata of an existing cmdlet. +- Creating a [System.Management.Automation.CommandMetadata](/dotnet/api/System.Management.Automation.CommandMetadata) object that describes the metadata of an existing cmdlet. -- Creating a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Creating a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. - Modifying the cmdlet metadata to remove a parameter of the cmdlet. -- Adding the cmdlet to the [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object and making the cmdlet private. +- Adding the cmdlet to the [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object and making the cmdlet private. - Creating a proxy function that calls the existing cmdlet, but exposes only a restricted set of parameters. - Adding the proxy function to the initial session state. -- Creating a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object that uses the [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object. +- Creating a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object that uses the [System.Management.Automation.Runspaces.Runspace](/dotnet/api/System.Management.Automation.Runspaces.Runspace) object. -- Calling the private cmdlet and the proxy function using a [System.Management.Automation.Powershell](/dotnet/api/system.management.automation.powershell) object to demonstrate the constrained runspace. +- Calling the private cmdlet and the proxy function using a [System.Management.Automation.PowerShell](/dotnet/api/system.management.automation.powershell) object to demonstrate the constrained runspace. ## Example @@ -49,7 +49,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces #region GetProcCommand /// - /// This class implements the get-proc cmdlet. It has been copied + /// This class implements the Get-Proc cmdlet. It has been copied /// verbatim from the GetProcessSample02.cs sample. /// [Cmdlet(VerbsCommon.Get, "Proc")] @@ -139,8 +139,8 @@ namespace Microsoft.Samples.PowerShell.Runspaces // includes all the elements that are provided by Windows PowerShell. InitialSessionState iss = InitialSessionState.CreateDefault(); - // Add the get-proc cmdlet to the initial session state. - SessionStateCmdletEntry cmdletEntry = new SessionStateCmdletEntry("get-proc", typeof(GetProcCommand), null); + // Add the Get-Proc cmdlet to the initial session state. + SessionStateCmdletEntry cmdletEntry = new SessionStateCmdletEntry("Get-Proc", typeof(GetProcCommand), null); iss.Commands.Add(cmdletEntry); // Make the cmdlet private so that it is not accessible. @@ -152,7 +152,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces iss.LanguageMode = PSLanguageMode.NoLanguage; // Create the proxy command using cmdlet metadata to expose the - // get-proc cmdlet. + // Get-Proc cmdlet. CommandMetadata cmdletMetadata = new CommandMetadata(typeof(GetProcCommand)); // Remove one of the parameters from the command metadata. @@ -166,7 +166,7 @@ namespace Microsoft.Samples.PowerShell.Runspaces // function can be the same as the name of the cmdlet, but to clearly // demonstrate that the original cmdlet is not available a different name is // used for the proxy function. - iss.Commands.Add(new SessionStateFunctionEntry("get-procProxy", bodyOfProxyFunction)); + iss.Commands.Add(new SessionStateFunctionEntry("Get-ProcProxy", bodyOfProxyFunction)); // Create the constrained runspace using the initial session state. using (Runspace myRunspace = RunspaceFactory.CreateRunspace(iss)) @@ -179,14 +179,14 @@ namespace Microsoft.Samples.PowerShell.Runspaces using (PowerShell powershell = PowerShell.Create()) { powershell.Runspace = myRunspace; - powershell.AddCommand("get-proc").AddParameter("Name", "*explore*"); + powershell.AddCommand("Get-Proc").AddParameter("Name", "*explore*"); powershell.Invoke(); } } catch (CommandNotFoundException e) { System.Console.WriteLine( - "Invoking 'get-proc' failed as expected: {0}: {1}", + "Invoking 'Get-Proc' failed as expected: {0}: {1}", e.GetType().FullName, e.Message); } @@ -198,14 +198,14 @@ namespace Microsoft.Samples.PowerShell.Runspaces using (PowerShell powershell = PowerShell.Create()) { powershell.Runspace = myRunspace; - powershell.AddCommand("get-procProxy").AddParameter("Name", "idle"); + powershell.AddCommand("Get-ProcProxy").AddParameter("Name", "idle"); powershell.Invoke(); } } catch (ParameterBindingException e) { System.Console.WriteLine( - "\nInvoking 'get-procProxy -Name idle' failed as expected: {0}: {1}", + "\nInvoking 'Get-ProcProxy -Name idle' failed as expected: {0}: {1}", e.GetType().FullName, e.Message); } @@ -215,10 +215,10 @@ namespace Microsoft.Samples.PowerShell.Runspaces using (PowerShell powershell = PowerShell.Create()) { powershell.Runspace = myRunspace; - powershell.AddCommand("get-procProxy"); + powershell.AddCommand("Get-ProcProxy"); List processes = new List(powershell.Invoke()); System.Console.WriteLine( - "\nInvoking the get-procProxy function called into the get-proc cmdlet and returned {0} processes", + "\nInvoking the Get-ProcProxy function called into the Get-Proc cmdlet and returned {0} processes", processes.Count); } diff --git a/reference/docs-conceptual/developer/hosting/windows-powershell-api-samples.md b/reference/docs-conceptual/developer/hosting/windows-powershell-api-samples.md index 5a2c8b0ade2a..0e1d7969705a 100644 --- a/reference/docs-conceptual/developer/hosting/windows-powershell-api-samples.md +++ b/reference/docs-conceptual/developer/hosting/windows-powershell-api-samples.md @@ -11,7 +11,7 @@ This section includes sample code that shows how to create runspaces that restri ## In This Section [PowerShell01 Sample](./windows-powershell01-sample.md) -This sample shows how to use a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to limit the functionality of a runspace. The output of this sample demonstrates how to restrict the language mode of the runspace, how to mark a cmdlet as private, how to add and remove cmdlets and providers, how to add a proxy command, and more. +This sample shows how to use a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to limit the functionality of a runspace. The output of this sample demonstrates how to restrict the language mode of the runspace, how to mark a cmdlet as private, how to add and remove cmdlets and providers, how to add a proxy command, and more. [PowerShell02 Sample](./windows-powershell02-sample.md) This sample shows how to run commands asynchronously by using the runspaces of a runspace pool. The sample generates a list of commands, and then runs those commands while the Windows PowerShell engine opens a runspace from the pool when it is needed. diff --git a/reference/docs-conceptual/developer/hosting/windows-powershell-host-quickstart.md b/reference/docs-conceptual/developer/hosting/windows-powershell-host-quickstart.md index 4b66476a33d0..4c610bc13b5e 100644 --- a/reference/docs-conceptual/developer/hosting/windows-powershell-host-quickstart.md +++ b/reference/docs-conceptual/developer/hosting/windows-powershell-host-quickstart.md @@ -61,11 +61,11 @@ The previous example executes a single command without any parameters. You can a command by using the [System.Management.Automation.PSCommand.AddParameter](/dotnet/api/System.Management.Automation.PSCommand.AddParameter) method. For example, the following code gets a list of all of the processes that are named -`PowerShell` running on the machine. +`powershell` running on the machine. ```csharp PowerShell.Create().AddCommand("Get-Process") - .AddParameter("Name", "PowerShell") + .AddParameter("Name", "powershell") .Invoke(); ``` @@ -73,7 +73,7 @@ You can add additional parameters by calling the AddParameter method repeatedly. ```csharp PowerShell.Create().AddCommand("Get-ChildItem") - .AddParameter("Path", @"c:\Windows") + .AddParameter("Path", @"C:\Windows") .AddParameter("Filter", "*.exe") .Invoke(); ``` @@ -84,7 +84,7 @@ method. ```csharp IDictionary parameters = new Dictionary(); -parameters.Add("Path", @"c:\Windows"); +parameters.Add("Path", @"C:\Windows"); parameters.Add("Filter", "*.exe"); PowerShell.Create().AddCommand("Get-Process") @@ -98,11 +98,11 @@ PowerShell.Create().AddCommand("Get-Process") You can simulate batching by using the [System.Management.Automation.PowerShell.AddStatement](/dotnet/api/System.Management.Automation.PowerShell.AddStatement) method, which adds an additional statement to the end of the pipeline. The following code gets a -list of running processes with the name `PowerShell`, and then gets the list of running services. +list of running processes with the name `powershell`, and then gets the list of running services. ```csharp PowerShell ps = PowerShell.Create(); -ps.AddCommand("Get-Process").AddParameter("Name", "PowerShell"); +ps.AddCommand("Get-Process").AddParameter("Name", "powershell"); ps.AddStatement().AddCommand("Get-Service"); ps.Invoke(); ``` diff --git a/reference/docs-conceptual/developer/hosting/windows-powershell01-sample.md b/reference/docs-conceptual/developer/hosting/windows-powershell01-sample.md index 532498d885ad..d2fa6bb3758f 100644 --- a/reference/docs-conceptual/developer/hosting/windows-powershell01-sample.md +++ b/reference/docs-conceptual/developer/hosting/windows-powershell01-sample.md @@ -6,7 +6,7 @@ title: Windows PowerShell01 Sample --- # Windows PowerShell01 Sample -This sample shows how to use a [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to limit the functionality of a runspace. The output of this sample demonstrates how to restrict the language mode of the runspace, how to mark a cmdlet as private, how to add and remove cmdlets and providers, how to add a proxy command, and more. This sample concentrates on how to restrict the runspace programmatically. Scripting alternatives to restricting the runspace include the $ExecutionContext.SessionState.LanguageMode and PSSessionConfiguration commands. +This sample shows how to use a [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object to limit the functionality of a runspace. The output of this sample demonstrates how to restrict the language mode of the runspace, how to mark a cmdlet as private, how to add and remove cmdlets and providers, how to add a proxy command, and more. This sample concentrates on how to restrict the runspace programmatically. Scripting alternatives to restricting the runspace include the $ExecutionContext.SessionState.LanguageMode and PSSessionConfiguration commands. ## Requirements @@ -16,17 +16,17 @@ This sample requires Windows PowerShell 2.0. This sample demonstrates the following: -- Restricting the language by setting the [System.Management.Automation.Runspaces.Initialsessionstate.Languagemode](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.LanguageMode) property. +- Restricting the language by setting the [System.Management.Automation.Runspaces.InitialSessionState.LanguageMode](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.LanguageMode) property. -- Adding aliases to the initial session state by using a [System.Management.Automation.Runspaces.Sessionstatealiasentry?Displayproperty=Fullname](/dotnet/api/System.Management.Automation.Runspaces.SessionStateAliasEntry) object. +- Adding aliases to the initial session state by using a [System.Management.Automation.Runspaces.SessionStateAliasEntry](/dotnet/api/System.Management.Automation.Runspaces.SessionStateAliasEntry) object. - Marking commands as private. -- Removing providers from the initial session state by using the [System.Management.Automation.Runspaces.Initialsessionstate.Providers](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.Providers) property. +- Removing providers from the initial session state by using the [System.Management.Automation.Runspaces.InitialSessionState.Providers](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.Providers) property. -- Removing commands from the initial session state by using the [System.Management.Automation.Runspaces.Initialsessionstate.Commands](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.Commands) property. +- Removing commands from the initial session state by using the [System.Management.Automation.Runspaces.InitialSessionState.Commands](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState.Commands) property. -- Adding commands and providers to the [System.Management.Automation.Runspaces.Initialsessionstate](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. +- Adding commands and providers to the [System.Management.Automation.Runspaces.InitialSessionState](/dotnet/api/System.Management.Automation.Runspaces.InitialSessionState) object. ## Example @@ -153,32 +153,32 @@ namespace Sample this.runspace = RunspaceFactory.CreateRunspace(InitialSessionState.CreateDefault()); this.runspace.Open(); - string scriptComment = "get-childitem with a default InitialSessionState will work since the standard \n" + + string scriptComment = "Get-ChildItem with a default InitialSessionState will work since the standard \n" + "PowerShell cmdlets are included in the default InitialSessionState"; - this.RunScript("get-childitem", scriptComment); + this.RunScript("Get-ChildItem", scriptComment); this.runspace.Close(); InitialSessionState defaultSessionState = InitialSessionState.CreateDefault(); - defaultSessionState.Commands.Add(new SessionStateAliasEntry("dir2", "get-childitem")); + defaultSessionState.Commands.Add(new SessionStateAliasEntry("dir2", "Get-ChildItem")); this.runspace = RunspaceFactory.CreateRunspace(defaultSessionState); this.runspace.Open(); this.RunScript("dir2", "An alias, like dir2, can be added to InitialSessionState"); this.runspace.Close(); defaultSessionState = InitialSessionState.CreateDefault(); - int commandIndex = GetIndexOfEntry(defaultSessionState.Commands, "get-childitem"); + int commandIndex = GetIndexOfEntry(defaultSessionState.Commands, "Get-ChildItem"); defaultSessionState.Commands.RemoveItem(commandIndex); this.runspace = RunspaceFactory.CreateRunspace(defaultSessionState); this.runspace.Open(); - scriptComment = "get-childitem was removed from the list of commands so it\nwill no longer be found"; - this.RunScript("get-childitem", scriptComment); + scriptComment = "Get-ChildItem was removed from the list of commands so it\nwill no longer be found"; + this.RunScript("Get-ChildItem", scriptComment); this.runspace.Close(); defaultSessionState = InitialSessionState.CreateDefault(); defaultSessionState.Providers.Clear(); this.runspace = RunspaceFactory.CreateRunspace(defaultSessionState); this.runspace.Open(); - this.RunScript("get-childitem", "There are no providers so get-childitem will not work"); + this.RunScript("Get-ChildItem", "There are no providers so Get-ChildItem will not work"); this.runspace.Close(); // Marks a command as private, and then defines a proxy command @@ -187,21 +187,21 @@ namespace Sample // For a more complete sample of a proxy command, see the Runspace11 // sample. defaultSessionState = InitialSessionState.CreateDefault(); - commandIndex = GetIndexOfEntry(defaultSessionState.Commands, "get-childitem"); + commandIndex = GetIndexOfEntry(defaultSessionState.Commands, "Get-ChildItem"); defaultSessionState.Commands[commandIndex].Visibility = SessionStateEntryVisibility.Private; CommandMetadata getChildItemMetadata = new CommandMetadata( typeof(Microsoft.PowerShell.Commands.GetChildItemCommand)); getChildItemMetadata.Parameters.Remove("Recurse"); string getChildItemBody = ProxyCommand.Create(getChildItemMetadata); - defaultSessionState.Commands.Add(new SessionStateFunctionEntry("get-childitem2", getChildItemBody)); + defaultSessionState.Commands.Add(new SessionStateFunctionEntry("Get-ChildItem2", getChildItemBody)); this.runspace = RunspaceFactory.CreateRunspace(defaultSessionState); this.runspace.Open(); - this.RunScript("get-childitem", "get-childitem is private so it will not be available"); - scriptComment = "get-childitem2 is a proxy to get-childitem. \n" + - "It works even when get-childitem is private."; - this.RunScript("get-childitem2", scriptComment); - scriptComment = "This will fail. Unlike get-childitem, get-childitem2 does not have -Recurse"; - this.RunScript("get-childitem2 -Recurse", scriptComment); + this.RunScript("Get-ChildItem", "Get-ChildItem is private so it will not be available"); + scriptComment = "Get-ChildItem2 is a proxy to Get-ChildItem. \n" + + "It works even when Get-ChildItem is private."; + this.RunScript("Get-ChildItem2", scriptComment); + scriptComment = "This will fail. Unlike Get-ChildItem, Get-ChildItem2 does not have -Recurse"; + this.RunScript("Get-ChildItem2 -Recurse", scriptComment); InitialSessionState cleanSessionState = InitialSessionState.Create(); this.runspace = RunspaceFactory.CreateRunspace(cleanSessionState); @@ -215,9 +215,9 @@ namespace Sample cleanSessionState.LanguageMode = PSLanguageMode.FullLanguage; this.runspace = RunspaceFactory.CreateRunspace(cleanSessionState); this.runspace.Open(); - scriptComment = "get-childitem, standard cmdlets and providers are not present \n" + + scriptComment = "Get-ChildItem, standard cmdlets and providers are not present \n" + "in an InitialSessionState returned from InitialSessionState.Create()"; - this.RunScript("get-childitem", scriptComment); + this.RunScript("Get-ChildItem", scriptComment); this.runspace.Close(); cleanSessionState = InitialSessionState.Create(); @@ -234,9 +234,9 @@ namespace Sample cleanSessionState.LanguageMode = PSLanguageMode.FullLanguage; this.runspace = RunspaceFactory.CreateRunspace(cleanSessionState); this.runspace.Open(); - scriptComment = "get-childitem and the FileSystem provider were explicitly added\n" + - "so get-childitem will work"; - this.RunScript("get-childitem", scriptComment); + scriptComment = "Get-ChildItem and the FileSystem provider were explicitly added\n" + + "so Get-ChildItem will work"; + this.RunScript("Get-ChildItem", scriptComment); this.runspace.Close(); Console.Write("Done..."); diff --git a/reference/docs-conceptual/developer/hosting/windows-powershell02-sample.md b/reference/docs-conceptual/developer/hosting/windows-powershell02-sample.md index fc4ae4d591f9..4254fd3e0eb8 100644 --- a/reference/docs-conceptual/developer/hosting/windows-powershell02-sample.md +++ b/reference/docs-conceptual/developer/hosting/windows-powershell02-sample.md @@ -22,9 +22,9 @@ This sample demonstrates the following: at the same time. - Creating a list of commands. - Running the commands asynchronously. -- Calling the [System.Management.Automation.Runspaces.Runspacepool.Getavailablerunspaces*](/dotnet/api/System.Management.Automation.Runspaces.RunspacePool.GetAvailableRunspaces) +- Calling the [System.Management.Automation.Runspaces.RunspacePool.GetAvailableRunspaces*](/dotnet/api/System.Management.Automation.Runspaces.RunspacePool.GetAvailableRunspaces) method to see how many runspaces are free. -- Capturing the command output with the [System.Management.Automation.Powershell.Endinvoke*](/dotnet/api/System.Management.Automation.PowerShell.EndInvoke) +- Capturing the command output with the [System.Management.Automation.PowerShell.EndInvoke*](/dotnet/api/System.Management.Automation.PowerShell.EndInvoke) method. ## Example diff --git a/reference/docs-conceptual/developer/installing-the-windows-powershell-sdk.md b/reference/docs-conceptual/developer/installing-the-windows-powershell-sdk.md index 5c33215bcd99..f414b66ee347 100644 --- a/reference/docs-conceptual/developer/installing-the-windows-powershell-sdk.md +++ b/reference/docs-conceptual/developer/installing-the-windows-powershell-sdk.md @@ -24,7 +24,7 @@ repository. ### Reference assemblies -Reference assemblies are installed in the following location by default: `c:\Program Files\Reference +Reference assemblies are installed in the following location by default: `C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\V1.0`. > [!NOTE] @@ -134,8 +134,8 @@ description of what each sample does. application also supports displaying prompts that allow the user to specify multiple choices. - Host05 - Shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. This host - application also supports calls to remote computers by using the `Enter-PsSession` and - `Exit-PsSession` cmdlets. + application also supports calls to remote computers by using the `Enter-PSSession` and + `Exit-PSSession` cmdlets. - Host06 - Shows how to build an interactive console-based host application that reads commands from the command line, executes the commands, and then displays the results to the console. In addition, this sample uses the Tokenizer APIs to specify the color of the text that is entered by diff --git a/reference/docs-conceptual/developer/module/how-to-create-a-windows-powershell-snap-in.md b/reference/docs-conceptual/developer/module/how-to-create-a-windows-powershell-snap-in.md index 9143997e952d..5fb71c8c95f5 100644 --- a/reference/docs-conceptual/developer/module/how-to-create-a-windows-powershell-snap-in.md +++ b/reference/docs-conceptual/developer/module/how-to-create-a-windows-powershell-snap-in.md @@ -12,7 +12,7 @@ Snap-in assemblies should be installed in a protected directory, just as they wo ## Windows PowerShell Snap-in Classes -All Windows PowerShell snap-in classes derive from the [System.Management.Automation.PSSnapIn](/dotnet/api/System.Management.Automation.PSSnapIn) or [System.Management.Automation.Custompssnapin](/dotnet/api/System.Management.Automation.CustomPSSnapIn) classes. +All Windows PowerShell snap-in classes derive from the [System.Management.Automation.PSSnapIn](/dotnet/api/System.Management.Automation.PSSnapIn) or [System.Management.Automation.CustomPSSnapIn](/dotnet/api/System.Management.Automation.CustomPSSnapIn) classes. ## Examples @@ -24,7 +24,7 @@ All Windows PowerShell snap-in classes derive from the [System.Management.Automa [System.Management.Automation.PSSnapIn](/dotnet/api/System.Management.Automation.PSSnapIn) -[System.Management.Automation.Custompssnapin](/dotnet/api/System.Management.Automation.CustomPSSnapIn) +[System.Management.Automation.CustomPSSnapIn](/dotnet/api/System.Management.Automation.CustomPSSnapIn) [Registering Cmdlets](./registering-cmdlets.md) diff --git a/reference/docs-conceptual/developer/module/how-to-import-cmdlets-using-modules.md b/reference/docs-conceptual/developer/module/how-to-import-cmdlets-using-modules.md index d5ff0dac9105..a603fdc30816 100644 --- a/reference/docs-conceptual/developer/module/how-to-import-cmdlets-using-modules.md +++ b/reference/docs-conceptual/developer/module/how-to-import-cmdlets-using-modules.md @@ -22,7 +22,7 @@ This article describes how to import cmdlets to a PowerShell session by using a 1. 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. To view the `PSModulePath`, type: `$env:PSModulePath`. + variable. To view the `PSModulePath`, type: `$Env:PSModulePath`. 1. Copy the cmdlet assembly into the module folder. diff --git a/reference/docs-conceptual/developer/module/how-to-write-a-powershell-binary-module.md b/reference/docs-conceptual/developer/module/how-to-write-a-powershell-binary-module.md index 8652fd7514f7..6a88eb13311d 100644 --- a/reference/docs-conceptual/developer/module/how-to-write-a-powershell-binary-module.md +++ b/reference/docs-conceptual/developer/module/how-to-write-a-powershell-binary-module.md @@ -76,7 +76,7 @@ The following procedure describes how to create and install a PowerShell binary The `PSModulePath` global environment variable describes the default paths that PowerShell will use to locate your module. For example, a common path to save a module on a system would be - `%SystemRoot%\users\\Documents\WindowsPowerShell\Modules\`. If you do not use + `%SystemRoot%\Users\\Documents\WindowsPowerShell\Modules\`. If you do not use the default paths, you will need to explicitly state the location of your module during installation. Be sure to create a folder to save your module in, as you may need the folder to store multiple assemblies and files for your solution. diff --git a/reference/docs-conceptual/developer/module/how-to-write-a-powershell-module-manifest.md b/reference/docs-conceptual/developer/module/how-to-write-a-powershell-module-manifest.md index f21ecc650bc5..596e616cdeb2 100644 --- a/reference/docs-conceptual/developer/module/how-to-write-a-powershell-module-manifest.md +++ b/reference/docs-conceptual/developer/module/how-to-write-a-powershell-module-manifest.md @@ -93,7 +93,7 @@ The following table describes the elements you can include in a module manifest. | **Copyright**
Type: `String` | `'(c) . All rights reserved.'` | Copyright statement for this module. If a value isn't specified, `New-ModuleManifest` uses the default with the current user as the ``. To specify an author, use the **Author** parameter.
Example: `Copyright = '2019 AuthorName. All rights reserved.'` | | **Description**
Type: `String` | `` | Description of the functionality provided by this module.
Example: `Description = 'This is the module's description.'` | | **PowerShellVersion**
Type: `Version` | `` | Minimum version of the PowerShell engine required by this module. Valid values are 1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 6.1, 6.2, 7.0 and 7.1.
Example: `PowerShellVersion = '5.0'` | -| **PowerShellHostName**
Type: `String` | `` | Name of the PowerShell host required by this module. This name is provided by PowerShell. To find the name of a host program, in the program, type: `$Host.name`.
Example: `PowerShellHostName = 'ConsoleHost'` | +| **PowerShellHostName**
Type: `String` | `` | Name of the PowerShell host required by this module. This name is provided by PowerShell. To find the name of a host program, in the program, type: `$Host.Name`.
Example: `PowerShellHostName = 'ConsoleHost'` | | **PowerShellHostVersion**
Type: `Version` | `` | Minimum version of the PowerShell host required by this module.
Example: `PowerShellHostVersion = '2.0'` | | **DotNetFrameworkVersion**
Type: `Version` | `` | Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only, such as Windows PowerShell 5.1, and only applies to .NET Framework versions lower than 4.5.
Example: `DotNetFrameworkVersion = '3.5'` | | **CLRVersion**
Type: `Version` | `` | Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only, such as Windows PowerShell 5.1, and only applies to .NET Framework versions lower than 4.5.
Example: `CLRVersion = '3.5'` | diff --git a/reference/docs-conceptual/developer/module/how-to-write-a-powershell-script-module.md b/reference/docs-conceptual/developer/module/how-to-write-a-powershell-script-module.md index cb4b4a42b790..d1d6b00b7855 100644 --- a/reference/docs-conceptual/developer/module/how-to-write-a-powershell-script-module.md +++ b/reference/docs-conceptual/developer/module/how-to-write-a-powershell-script-module.md @@ -18,7 +18,7 @@ To create a script module, save a valid PowerShell script to a `.psm1` file. The directory where it's stored must use the same name. For example, a script named `MyPsScript.psm1` is stored in a directory named `MyPsScript`. -The module's directory needs to be in a path specified in `$env:PSModulePath`. The module's +The module's directory needs to be in a path specified in `$Env:PSModulePath`. The module's directory can contain any resources that are needed to run the script, and a module manifest file that describes to PowerShell how your module works. @@ -43,11 +43,11 @@ The following steps describe how to create a PowerShell module. ```powershell function Show-Calendar { param( - [DateTime] $start = [DateTime]::Today, - [DateTime] $end = $start, - $firstDayOfWeek, - [int[]] $highlightDay, - [string[]] $highlightDate = [DateTime]::Today.ToString('yyyy-MM-dd') + [datetime] $Start = [datetime]::Today, + [datetime] $End = $Start, + $FirstDayOfWeek, + [int[]] $HighlightDay, + [string[]] $HighlightDate = [datetime]::Today.ToString('yyyy-MM-dd') ) #actual code for the function goes here see the end of the topic for the complete code sample @@ -103,7 +103,7 @@ The following steps describe how to create a PowerShell module. 1. To install and run your module, save the module to one of the appropriate PowerShell paths, and use `Import-Module`. - The paths where you can install your module are located in the `$env:PSModulePath` global + The paths where you can install your module are located in the `$Env:PSModulePath` global variable. For example, a common path to save a module on a system would be `%SystemRoot%/users//Documents/PowerShell/Modules/`. Be sure to create a directory for your module that uses the same name as the script module, even if it's only a @@ -135,70 +135,70 @@ member. ```powershell <# - .Synopsis + .SYNOPSIS Displays a visual representation of a calendar. - .Description + .DESCRIPTION Displays a visual representation of a calendar. This function supports multiple months and lets you highlight specific date ranges or days. - .Parameter Start + .PARAMETER Start The first month to display. - .Parameter End + .PARAMETER End The last month to display. - .Parameter FirstDayOfWeek + .PARAMETER FirstDayOfWeek The day of the month on which the week begins. - .Parameter HighlightDay + .PARAMETER HighlightDay Specific days (numbered) to highlight. Used for date ranges like (25..31). Date ranges are specified by the Windows PowerShell range syntax. These dates are enclosed in square brackets. - .Parameter HighlightDate + .PARAMETER HighlightDate Specific days (named) to highlight. These dates are surrounded by asterisks. - .Example + .EXAMPLE # Show a default display of this month. Show-Calendar - .Example + .EXAMPLE # Display a date range. Show-Calendar -Start "March, 2010" -End "May, 2010" - .Example + .EXAMPLE # Highlight a range of days. Show-Calendar -HighlightDay (1..10 + 22) -HighlightDate "2008-12-25" #> function Show-Calendar { param( - [DateTime] $start = [DateTime]::Today, - [DateTime] $end = $start, - $firstDayOfWeek, - [int[]] $highlightDay, - [string[]] $highlightDate = [DateTime]::Today.ToString('yyyy-MM-dd') + [datetime] $Start = [datetime]::Today, + [datetime] $End = $Start, + $FirstDayOfWeek, + [int[]] $HighlightDay, + [string[]] $HighlightDate = [datetime]::Today.ToString('yyyy-MM-dd') ) ## Determine the first day of the start and end months. -$start = New-Object DateTime $start.Year,$start.Month,1 -$end = New-Object DateTime $end.Year,$end.Month,1 +$Start = New-Object DateTime $Start.Year,$Start.Month,1 +$End = New-Object DateTime $End.Year,$End.Month,1 ## Convert the highlighted dates into real dates. -[DateTime[]] $highlightDate = [DateTime[]] $highlightDate +[datetime[]] $HighlightDate = [datetime[]] $HighlightDate ## Retrieve the DateTimeFormat information so that the ## calendar can be manipulated. $dateTimeFormat = (Get-Culture).DateTimeFormat -if($firstDayOfWeek) +if($FirstDayOfWeek) { - $dateTimeFormat.FirstDayOfWeek = $firstDayOfWeek + $dateTimeFormat.FirstDayOfWeek = $FirstDayOfWeek } -$currentDay = $start +$currentDay = $Start ## Process the requested months. -while($start -le $end) +while($Start -le $End) { ## Return to an earlier point in the function if the first day of the month ## is in the middle of the week. @@ -215,7 +215,7 @@ while($start -le $end) ## Continue processing dates until the function reaches the end of the month. ## The function continues until the week is completed with ## days from the next month. - while(($currentDay -lt $start.AddMonths(1)) -or + while(($currentDay -lt $Start.AddMonths(1)) -or ($currentDay.DayOfWeek -ne $dateTimeFormat.FirstDayOfWeek)) { ## Determine the day names to use to label the columns. @@ -229,21 +229,21 @@ while($start -le $end) $displayDay = " {0,2} " -f $currentDay.Day ## Determine whether to highlight a specific date. - if($highlightDate) + if($HighlightDate) { $compareDate = New-Object DateTime $currentDay.Year, $currentDay.Month,$currentDay.Day - if($highlightDate -contains $compareDate) + if($HighlightDate -contains $compareDate) { $displayDay = "*" + ("{0,2}" -f $currentDay.Day) + "*" } } ## Otherwise, highlight as part of a date range. - if($highlightDay -and ($highlightDay[0] -eq $currentDay.Day)) + if($HighlightDay -and ($HighlightDay[0] -eq $currentDay.Day)) { $displayDay = "[" + ("{0,2}" -f $currentDay.Day) + "]" - $null,$highlightDay = $highlightDay + $null,$HighlightDay = $HighlightDay } ## Add the day of the week and the day of the month as note properties. @@ -266,13 +266,13 @@ while($start -le $end) ## Add a centered header. $width = ($calendar.Split("`n") | Measure-Object -Maximum Length).Maximum - $header = "{0:MMMM yyyy}" -f $start + $header = "{0:MMMM yyyy}" -f $Start $padding = " " * (($width - $header.Length) / 2) $displayCalendar = " `n" + $padding + $header + "`n " + $calendar $displayCalendar.TrimEnd() ## Move to the next month. - $start = $start.AddMonths(1) + $Start = $Start.AddMonths(1) } } diff --git a/reference/docs-conceptual/developer/module/importing-a-powershell-module.md b/reference/docs-conceptual/developer/module/importing-a-powershell-module.md index f75389908c16..2b76c9f49801 100644 --- a/reference/docs-conceptual/developer/module/importing-a-powershell-module.md +++ b/reference/docs-conceptual/developer/module/importing-a-powershell-module.md @@ -30,8 +30,8 @@ PowerShell 2.0 uses the appropriately-named [Import-Module](/powershell/module/Microsoft.PowerShell.Core/Import-Module) cmdlet to import modules. When this cmdlet is run, Windows PowerShell searches for the specified module within the directories specified in the `PSModulePath` variable. When the specified directory is found, Windows -PowerShell searches for files in the following order: module manifest files (.psd1), script module -files (.psm1), binary module files (.dll). For more information about adding directories to the +PowerShell searches for files in the following order: module manifest files (`.psd1`), script module +files (`.psm1`), binary module files (.dll). For more information about adding directories to the search, see [about_PSModulePath](/powershell/module/microsoft.powershell.core/about/about_psmodulepath). The following code describes how to import a module: diff --git a/reference/docs-conceptual/developer/module/installing-a-powershell-module.md b/reference/docs-conceptual/developer/module/installing-a-powershell-module.md index 48da1b5da3d6..2ab74f3378f9 100644 --- a/reference/docs-conceptual/developer/module/installing-a-powershell-module.md +++ b/reference/docs-conceptual/developer/module/installing-a-powershell-module.md @@ -8,7 +8,7 @@ title: Installing a PowerShell Module After you have created your PowerShell module, you will likely want to install the module on a system, so that you or others may use it. Generally speaking, this consists of copying the module -files (ie, the .psm1, or the binary assembly, the module manifest, and any other associated files) +files (ie, the `.psm1`, or the binary assembly, the module manifest, and any other associated files) onto a directory on that computer. For a very small project, this may be as simple as copying and pasting the files with Windows Explorer onto a single remote computer; however, for larger solutions you may wish to use a more sophisticated installation process. Regardless of how you get your module @@ -33,7 +33,7 @@ PowerShell modules. Cmdlets rely on the value of this environment variable to fi By default, the **PSModulePath** environment variable value contains the following system and user module directories, but you can add to and edit the value. -- `$PSHOME\Modules` (`%Windir%\System32\WindowsPowerShell\v1.0\Modules`) +- `$PSHOME\Modules` (`%windir%\System32\WindowsPowerShell\v1.0\Modules`) > [!WARNING] > This location is reserved for modules that ship with Windows. Do not install modules to this @@ -209,13 +209,13 @@ C:\Program Files ``` Then, the installer assures the value of the **PSModulePath** environment variable includes the path -of the common files modules subdirectory. +of the `Common Files\Modules` subdirectory. ```powershell -$m = $env:ProgramFiles + '\Common Files\Modules' +$m = $Env:ProgramFiles + '\Common Files\Modules' $p = [Environment]::GetEnvironmentVariable("PSModulePath") $q = $p -split ';' -if ($q -notContains $m) { +if ($q -notcontains $m) { $q += ";$m" } $p = $q -join ';' @@ -229,7 +229,7 @@ To install multiple versions of the same module, use the following procedure. 1. Create a directory for each version of the module. Include the version number in the directory name. 1. Create a module manifest for each version of the module. In the value of the **ModuleVersion** - key in the manifest, enter the module version number. Save the manifest file (.psd1) in the + key in the manifest, enter the module version number. Save the manifest file (`.psd1`) in the version-specific directory for the module. 1. Add the module root folder path to the value of the **PSModulePath** environment variable, as shown in the following examples. diff --git a/reference/docs-conceptual/developer/module/understanding-a-windows-powershell-module.md b/reference/docs-conceptual/developer/module/understanding-a-windows-powershell-module.md index 609418b9b343..b4dbd1e17feb 100644 --- a/reference/docs-conceptual/developer/module/understanding-a-windows-powershell-module.md +++ b/reference/docs-conceptual/developer/module/understanding-a-windows-powershell-module.md @@ -13,8 +13,8 @@ than you would otherwise. The main purpose of a module is to allow the modularization (ie, reuse and abstraction) of Windows PowerShell code. For example, the most basic way of creating a module is to simply save a Windows -PowerShell script as a .psm1 file. Doing so allows you to control (ie, make public or private) the -functions and variables contained in the script. Saving the script as a .psm1 file also allows you +PowerShell script as a `.psm1` file. Doing so allows you to control (ie, make public or private) the +functions and variables contained in the script. Saving the script as a `.psm1` file also allows you to control the scope of certain variables. Finally, you can also use cmdlets such as [Install-Module](/powershell/module/PowershellGet/Install-Module) to organize, install, and use your script as building blocks for larger solutions. @@ -34,12 +34,12 @@ A module is made up of four basic components: reasonably find it. >[!NOTE] - > none of these components, by themselves, are actually necessary. For example, a module can - > technically be only a script stored in a .psm1 file. You can also have a module that is nothing - > but a manifest file, which is used mainly for organizational purposes. You can also write a - > script that dynamically creates a module, and as such doesn't actually need a directory to - > store anything in. The following sections describe the types of modules you can get by mixing - > and matching the different possible parts of a module together. + > None of these components, by themselves, are actually necessary. For example, a module can + > technically be only a script stored in a `.psm1` file. You can also have a module that is + > nothing but a manifest file, which is used mainly for organizational purposes. You can also + > write a script that dynamically creates a module, and as such doesn't actually need a directory + > to store anything in. The following sections describe the types of modules you can get by + > mixing and matching the different possible parts of a module together. ### Script Modules @@ -130,7 +130,7 @@ that others may access it. For example, your module can be stored in the system PowerShell is installed, or it can be stored in a user folder. Generally speaking, you can determine where you should install your module by using one of the paths -stored in the `$ENV:PSModulePath` variable. Using one of these paths means that PowerShell can +stored in the `$Env:PSModulePath` variable. Using one of these paths means that PowerShell can automatically find and load your module when a user makes a call to it in their code. If you store your module somewhere else, you can explicitly let PowerShell know by passing in the location of your module as a parameter when you call `Install-Module`. @@ -159,9 +159,9 @@ exported members, such as its functions and variables, are immediately available remain available until the session is closed. [New-ModuleManifest](/powershell/module/Microsoft.PowerShell.Core/New-ModuleManifest) cmdlet This -cmdlet creates a new module manifest (.psd1) file, populates its values, and saves the manifest file -to the specified path. This cmdlet can also be used to create a module manifest template that can be -filled in manually. +cmdlet creates a new module manifest (`.psd1`) file, populates its values, and saves the manifest +file to the specified path. This cmdlet can also be used to create a module manifest template that +can be filled in manually. [Import-Module](/powershell/module/Microsoft.PowerShell.Core/Import-Module) cmdlet This cmdlet adds one or more modules to the current session. @@ -171,7 +171,7 @@ information about the modules that have been or that can be imported into the cu [Export-ModuleMember](/powershell/module/Microsoft.PowerShell.Core/Export-ModuleMember) cmdlet This cmdlet specifies the module members (such as cmdlets, functions, variables, and aliases) that are -exported from a script module (.psm1) file or from a dynamic module created by using the +exported from a script module (`.psm1`) file or from a dynamic module created by using the `New-Module` cmdlet. [Remove-Module](/powershell/module/Microsoft.PowerShell.Core/Remove-Module) cmdlet This cmdlet @@ -179,13 +179,13 @@ removes modules from the current session. [Test-ModuleManifest](/powershell/module/Microsoft.PowerShell.Core/Test-ModuleManifest) cmdlet This cmdlet verifies that a module manifest accurately describes the components of a module by verifying -that the files that are listed in the module manifest file (.psd1) actually exist in the specified +that the files that are listed in the module manifest file (`.psd1`) actually exist in the specified paths. $PSScriptRoot This variable contains the directory from which the script module is being executed. It enables scripts to use the module path to access other resources. -$env:PSModulePath This environment variable contains a list of the directories in which Windows +$Env:PSModulePath This environment variable contains a list of the directories in which Windows PowerShell modules are stored. Windows PowerShell uses the value of this variable when importing modules automatically and updating Help topics for modules. diff --git a/reference/docs-conceptual/developer/module/writing-a-custom-windows-powershell-snap-in.md b/reference/docs-conceptual/developer/module/writing-a-custom-windows-powershell-snap-in.md index 5bdd3fc0d146..c69a8bb88047 100644 --- a/reference/docs-conceptual/developer/module/writing-a-custom-windows-powershell-snap-in.md +++ b/reference/docs-conceptual/developer/module/writing-a-custom-windows-powershell-snap-in.md @@ -16,7 +16,7 @@ assembly, see [Writing a Windows PowerShell Snap-in](./writing-a-windows-powersh 1. Add the RunInstallerAttribute attribute. 2. Create a public class that derives from the - [System.Management.Automation.Custompssnapin](/dotnet/api/System.Management.Automation.CustomPSSnapIn) + [System.Management.Automation.CustomPSSnapIn](/dotnet/api/System.Management.Automation.CustomPSSnapIn) class. In this example, the class name is "CustomPSSnapinTest". @@ -48,7 +48,7 @@ assembly, see [Writing a Windows PowerShell Snap-in](./writing-a-windows-powersh > Test-HelloWorld and Test-CustomSnapinTest cmdlets". 8. Specify the cmdlets that belong to the custom snap-in (optional) using the - [System.Management.Automation.Runspaces.Cmdletconfigurationentry](/dotnet/api/System.Management.Automation.Runspaces.CmdletConfigurationEntry) + [System.Management.Automation.Runspaces.CmdletConfigurationEntry](/dotnet/api/System.Management.Automation.Runspaces.CmdletConfigurationEntry) class. The information added here includes the name of the cmdlet, its .NET type, and the cmdlet Help file name (the format of the cmdlet Help file name should be `name.dll-help.xml`). diff --git a/reference/docs-conceptual/developer/module/writing-a-windows-powershell-snap-in.md b/reference/docs-conceptual/developer/module/writing-a-windows-powershell-snap-in.md index d2430dee9216..cb0b728d1857 100644 --- a/reference/docs-conceptual/developer/module/writing-a-windows-powershell-snap-in.md +++ b/reference/docs-conceptual/developer/module/writing-a-windows-powershell-snap-in.md @@ -39,12 +39,12 @@ write a snap-in that allows you to select what is registered, see 6. Add a public property for the description of the snap-in (required). In this example, the description is "This is a Windows PowerShell snap-in that registers the - get-proc cmdlet". + Get-Proc cmdlet". 7. Add a public property for the description resource of the snap-in (optional). In this example, the vendor resource is "GetProcPSSnapIn01,This is a Windows PowerShell snap-in - that registers the get-proc cmdlet". + that registers the Get-Proc cmdlet". ## Example @@ -105,7 +105,7 @@ public class GetProcPSSnapIn01 : PSSnapIn { get { - return "This is a PowerShell snap-in that includes the get-proc cmdlet."; + return "This is a PowerShell snap-in that includes the Get-Proc cmdlet."; } } @@ -117,7 +117,7 @@ public class GetProcPSSnapIn01 : PSSnapIn { get { - return "GetProcPSSnapIn01,This is a PowerShell snap-in that includes the get-proc cmdlet."; + return "GetProcPSSnapIn01,This is a PowerShell snap-in that includes the Get-Proc cmdlet."; } } } diff --git a/reference/docs-conceptual/developer/prog-guide/creating-a-basic-windows-powershell-provider.md b/reference/docs-conceptual/developer/prog-guide/creating-a-basic-windows-powershell-provider.md index 5925407a4a9a..3379160594c1 100644 --- a/reference/docs-conceptual/developer/prog-guide/creating-a-basic-windows-powershell-provider.md +++ b/reference/docs-conceptual/developer/prog-guide/creating-a-basic-windows-powershell-provider.md @@ -23,7 +23,7 @@ uninitialize the provider. The first step in creating a Windows PowerShell provider is to define its .NET class. This basic provider defines a class called `AccessDBProvider` that derives from the -[System.Management.Automation.Provider.Cmdletprovider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) +[System.Management.Automation.Provider.CmdletProvider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) base class. It is recommended that you place your provider classes in a `Providers` namespace of your API @@ -40,17 +40,17 @@ Here is the class definition for this basic provider: :::code language="csharp" source="~/../powershell-sdk-samples/SDK-2.0/csharp/AccessDBProviderSample01/AccessDBProviderSample01.cs" range="23-24"::: Right before the class definition, you must declare the -[System.Management.Automation.Provider.Cmdletproviderattribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) +[System.Management.Automation.Provider.CmdletProviderAttribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) attribute, with the syntax [CmdletProvider()]. You can set attribute keywords to further declare the class if necessary. Notice that the -[System.Management.Automation.Provider.Cmdletproviderattribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) +[System.Management.Automation.Provider.CmdletProviderAttribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) attribute declared here includes two parameters. The first attribute parameter specifies the default-friendly name for the provider, which the user can modify later. The second parameter specifies the Windows PowerShell-defined capabilities that the provider exposes to the Windows PowerShell runtime during command processing. The possible values for the provider capabilities are defined by the -[System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) +[System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. Because this is a base provider, it supports no capabilities. > [!NOTE] @@ -60,14 +60,14 @@ enumeration. Because this is a base provider, it supports no capabilities. ## Defining Provider-Specific State Information The -[System.Management.Automation.Provider.Cmdletprovider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) +[System.Management.Automation.Provider.CmdletProvider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) base class and all derived classes are considered stateless because the Windows PowerShell runtime creates provider instances only as required. Therefore, if your provider requires full control and state maintenance for provider-specific data, it must derive a class from the -[System.Management.Automation.Providerinfo](/dotnet/api/System.Management.Automation.ProviderInfo) +[System.Management.Automation.ProviderInfo](/dotnet/api/System.Management.Automation.ProviderInfo) class. Your derived class should define the members necessary to maintain the state so that the provider-specific data can be accessed when the Windows PowerShell runtime calls the -[System.Management.Automation.Provider.Cmdletprovider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) +[System.Management.Automation.Provider.CmdletProvider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) method to initialize the provider. A Windows PowerShell provider can also maintain connection-based state. For more information about @@ -77,19 +77,19 @@ maintaining connection state, see ## Initializing the Provider To initialize the provider, the Windows PowerShell runtime calls the -[System.Management.Automation.Provider.Cmdletprovider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) +[System.Management.Automation.Provider.CmdletProvider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) method when Windows PowerShell is started. For the most part, your provider can use the default implementation of this method, which simply returns the -[System.Management.Automation.Providerinfo](/dotnet/api/System.Management.Automation.ProviderInfo) +[System.Management.Automation.ProviderInfo](/dotnet/api/System.Management.Automation.ProviderInfo) object that describes your provider. However, in the case where you want to add additional initialization information, you should implement your own -[System.Management.Automation.Provider.Cmdletprovider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) +[System.Management.Automation.Provider.CmdletProvider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) method that returns a modified version of the -[System.Management.Automation.Providerinfo](/dotnet/api/System.Management.Automation.ProviderInfo) +[System.Management.Automation.ProviderInfo](/dotnet/api/System.Management.Automation.ProviderInfo) object that is passed to your provider. In general, this method should return the provided -[System.Management.Automation.Providerinfo](/dotnet/api/System.Management.Automation.ProviderInfo) +[System.Management.Automation.ProviderInfo](/dotnet/api/System.Management.Automation.ProviderInfo) object passed to it or a modified -[System.Management.Automation.Providerinfo](/dotnet/api/System.Management.Automation.ProviderInfo) +[System.Management.Automation.ProviderInfo](/dotnet/api/System.Management.Automation.ProviderInfo) object that contains other initialization information. This basic provider does not override this method. However, the following code shows the default implementation of this method: @@ -99,18 +99,18 @@ This basic provider does not override this method. However, the following code s The provider can maintain the state of provider-specific information as described in [Defining Provider-specific Data State](#defining-provider-specific-state-information). In this case, your implementation must override the -[System.Management.Automation.Provider.Cmdletprovider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) +[System.Management.Automation.Provider.CmdletProvider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) method to return an instance of the derived class. ## Start Dynamic Parameters Your provider implementation of the -[System.Management.Automation.Provider.Cmdletprovider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) +[System.Management.Automation.Provider.CmdletProvider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) method might require additional parameters. In this case, the provider should override the -[System.Management.Automation.Provider.Cmdletprovider.Startdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.StartDynamicParameters) +[System.Management.Automation.Provider.CmdletProvider.StartDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.StartDynamicParameters) method and return an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. This basic provider does not override this method. However, the following code shows the default implementation of this method: @@ -120,7 +120,7 @@ This basic provider does not override this method. However, the following code s ## Uninitializing the Provider To free resources that the Windows PowerShell provider uses, your provider should implement its own -[System.Management.Automation.Provider.Cmdletprovider.Stop*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Stop) +[System.Management.Automation.Provider.CmdletProvider.Stop*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Stop) method. This method is called by the Windows PowerShell runtime to uninitialize the provider at the close of a session. diff --git a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-container-provider.md b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-container-provider.md index effc0391323e..3a3078c6390d 100644 --- a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-container-provider.md +++ b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-container-provider.md @@ -37,14 +37,14 @@ container, with the tables and rows of the database defined as items of the cont ## Defining a Windows PowerShell Container Provider Class A Windows PowerShell container provider must define a .NET class that derives from the -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) base class. Here is the class definition for the Windows PowerShell container provider described in this section. :::code language="csharp" source="~/../powershell-sdk-samples/SDK-2.0/csharp/AccessDBProviderSample04/AccessDBProviderSample04.cs" range="34-35"::: Notice that in this class definition, the -[System.Management.Automation.Provider.Cmdletproviderattribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) +[System.Management.Automation.Provider.CmdletProviderAttribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) attribute includes two parameters. The first parameter specifies a user-friendly name for the provider that is used by Windows PowerShell. The second parameter specifies the Windows PowerShell specific capabilities that the provider exposes to the Windows PowerShell runtime during command @@ -54,7 +54,7 @@ processing. For this provider, there are no Windows PowerShell specific capabili As described in [Designing Your Windows PowerShell Provider](./designing-your-windows-powershell-provider.md), the -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class derives from several other classes that provided different provider functionality. A Windows PowerShell container provider, therefore, needs to define all of the functionality provided by those classes. @@ -66,27 +66,27 @@ However, most providers (including the provider described here) can use the defa of this functionality that is provided by Windows PowerShell. To get access to the data store, the provider must implement the methods of the -[System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) +[System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) base class. For more information about implementing these methods, see [Creating a Windows PowerShell Drive Provider](./creating-a-windows-powershell-drive-provider.md). To manipulate the items of a data store, such as getting, setting, and clearing items, the provider must implement the methods provided by the -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) base class. For more information about implementing these methods, see [Creating a Windows PowerShell Item Provider](./creating-a-windows-powershell-item-provider.md). ## Retrieving Child Items To retrieve a child item, the Windows PowerShell container provider must override the -[System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) +[System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) method to support calls from the `Get-ChildItem` cmdlet. This method retrieves child items from the data store and writes them to the pipeline as objects. If the `recurse` parameter of the cmdlet is specified, the method retrieves all children regardless of what level they are at. If the `recurse` parameter is not specified, the method retrieves only a single level of children. Here is the implementation of the -[System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) +[System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) method for this provider. Notice that this method retrieves the child items in all database tables when the path indicates the Access database, and retrieves the child items from the rows of that table if the path indicates a data table. @@ -96,49 +96,49 @@ table if the path indicates a data table. #### Things to Remember About Implementing GetChildItems The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems): +[System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems): - When defining the provider class, a Windows PowerShell container provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) + [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) method needs to ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - The implementation of this method should take into account any form of access to the item that might make the item visible to the user. For example, if a user has write access to a file through the FileSystem provider (supplied by Windows PowerShell), but not read access, the file still exists and - [System.Management.Automation.Provider.Itemcmdletprovider.Itemexists*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.ItemExists) + [System.Management.Automation.Provider.ItemCmdletProvider.ItemExists*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.ItemExists) returns `true`. Your implementation might require the checking of a parent item to see if the child can be enumerated. - When writing multiple items, the - [System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) + [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) method can take some time. You can design your provider to write the items using the - [System.Management.Automation.Provider.Cmdletprovider.Writeitemobject*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WriteItemObject) + [System.Management.Automation.Provider.CmdletProvider.WriteItemObject*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WriteItemObject) method one at a time. Using this technique will present the items to the user in a stream. - Your implementation of - [System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) + [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) is responsible for preventing infinite recursion when there are circular links, and the like. An appropriate terminating exception should be thrown to reflect such a condition. ## Attaching Dynamic Parameters to the Get-ChildItem Cmdlet Sometimes the `Get-ChildItem` cmdlet that calls -[System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) +[System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) requires additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, the Windows PowerShell container provider must implement the -[System.Management.Automation.Provider.Containercmdletprovider.Getchilditemsdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItemsDynamicParameters) +[System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItemsDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItemsDynamicParameters) method. This method retrieves dynamic parameters for the item at the indicated path and returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the `Get-ChildItem` cmdlet. @@ -150,15 +150,15 @@ code is the default implementation of this method. ## Retrieving Child Item Names To retrieve the names of child items, the Windows PowerShell container provider must override the -[System.Management.Automation.Provider.Containercmdletprovider.Getchildnames*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames) +[System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames) method to support calls from the `Get-ChildItem` cmdlet when its `Name` parameter is specified. This method retrieves the names of the child items for the specified path or child item names for all containers if the `returnAllContainers` parameter of the cmdlet is specified. A child name is the -leaf portion of a path. For example, the child name for the path c:\windows\system32\abc.dll is -"abc.dll". The child name for the directory c:\windows\system32 is "system32". +leaf portion of a path. For example, the child name for the path C:\windows\system32\abc.dll is +"abc.dll". The child name for the directory C:\windows\system32 is "system32". Here is the implementation of the -[System.Management.Automation.Provider.Containercmdletprovider.Getchildnames*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames) +[System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames) method for this provider. Notice that the method retrieves table names if the specified path indicates the Access database (drive) and row numbers if the path indicates a table. @@ -167,39 +167,39 @@ indicates the Access database (drive) and row numbers if the path indicates a ta #### Things to Remember About Implementing GetChildNames The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems): +[System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems): - When defining the provider class, a Windows PowerShell container provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) + [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) method needs to ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. > [!NOTE] > An exception to this rule occurs when the `returnAllContainers` parameter of the cmdlet is > specified. In this case, the method should retrieve any child name for a container, even if it > does not match the values of the - > [System.Management.Automation.Provider.Cmdletprovider.Filter*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Filter), - > [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include), + > [System.Management.Automation.Provider.CmdletProvider.Filter*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Filter), + > [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include), > or - > [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + > [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) > properties. - By default, overrides of this method should not retrieve names of objects that are generally hidden from the user unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is specified. If the specified path indicates a container, the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is not required. - Your implementation of - [System.Management.Automation.Provider.Containercmdletprovider.Getchildnames*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames) + [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames) is responsible for preventing infinite recursion when there are circular links, and the like. An appropriate terminating exception should be thrown to reflect such a condition. @@ -208,10 +208,10 @@ The following conditions may apply to your implementation of Sometimes the `Get-ChildItem` cmdlet (with the `Name` parameter) requires additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, the Windows PowerShell container provider must implement the -[System.Management.Automation.Provider.Containercmdletprovider.Getchildnamesdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNamesDynamicParameters) +[System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNamesDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNamesDynamicParameters) method. This method retrieves the dynamic parameters for the item at the indicated path and returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the `Get-ChildItem` cmdlet. @@ -223,13 +223,13 @@ implementation of this method. ## Renaming Items To rename an item, a Windows PowerShell container provider must override the -[System.Management.Automation.Provider.Containercmdletprovider.Renameitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) +[System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) method to support calls from the `Rename-Item` cmdlet. This method changes the name of the item at the specified path to the new name provided. The new name must always be relative to the parent item (container). This provider does not override the -[System.Management.Automation.Provider.Containercmdletprovider.Renameitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) +[System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) method. However, the following is the default implementation. @@ -237,53 +237,53 @@ method. However, the following is the default implementation. #### Things to Remember About Implementing RenameItem The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Containercmdletprovider.Renameitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem): +[System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem): - When defining the provider class, a Windows PowerShell container provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) + [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) method needs to ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - The - [System.Management.Automation.Provider.Containercmdletprovider.Renameitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) method is intended for the modification of the name of an item only, and not for move operations. Your implementation of the method should write an error if the `newName` parameter contains path separators, or might otherwise cause the item to change its parent location. - By default, overrides of this method should not rename objects unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is specified. If the specified path indicates a container, the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is not required. - Your implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Renameitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) method should call - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) and check its return value before making any changes to the data store. This method is used to confirm execution of an operation when a change is made to system state, for example, renaming files. - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) sends the name of the resource to be changed to the user, with the Windows PowerShell runtime taking into account any command line settings or preference variables in determining what should be displayed. After the call to - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) returns `true`, the - [System.Management.Automation.Provider.Containercmdletprovider.Renameitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) method should call the - [System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) + [System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) method. This method sends a message a confirmation message to the user to allow additional feedback to say if the operation should be continued. A provider should call - [System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) + [System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) as an additional check for potentially dangerous system modifications. ## Attaching Dynamic Parameters to the Rename-Item Cmdlet @@ -291,10 +291,10 @@ The following conditions may apply to your implementation of Sometimes the `Rename-Item` cmdlet requires additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, Windows PowerShell container provider must implement the -[System.Management.Automation.Provider.Containercmdletprovider.Renameitemdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItemDynamicParameters) +[System.Management.Automation.Provider.ContainerCmdletProvider.RenameItemDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItemDynamicParameters) method. This method retrieves the parameters for the item at the indicated path and returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the `Rename-Item` cmdlet. @@ -306,7 +306,7 @@ implementation of this method. ## Creating New Items To create new items, a container provider must implement the -[System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) +[System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method to support calls from the `New-Item` cmdlet. This method creates a data item located at the specified path. The `type` parameter of the cmdlet contains the provider-defined type for the new item. For example, the FileSystem provider uses a `type` parameter with a value of "file" or @@ -314,7 +314,7 @@ item. For example, the FileSystem provider uses a `type` parameter with a value new item. Here is the implementation of the -[System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) +[System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method for this provider. ```csharp @@ -341,49 +341,49 @@ protected override void NewItem( string path, string type, object newItemValue ) #### Things to Remember About Implementing NewItem The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem): +[System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem): - The - [System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method should perform a case-insensitive comparison of the string passed in the `type` parameter. It should also allow for least ambiguous matches. For example, for the types "file" and "directory", only the first letter is required to disambiguate. If the `type` parameter indicates a type your provider cannot create, the - [System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method should write an ArgumentException with a message indicating the types the provider can create. - For the `newItemValue` parameter, the implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method is recommended to accept strings at a minimum. It should also accept the type of object that is retrieved by the - [System.Management.Automation.Provider.Itemcmdletprovider.Getitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.GetItem) + [System.Management.Automation.Provider.ItemCmdletProvider.GetItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.GetItem) method for the same path. The - [System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method can use the - [System.Management.Automation.Languageprimitives.Convertto*](/dotnet/api/System.Management.Automation.LanguagePrimitives.ConvertTo) + [System.Management.Automation.LanguagePrimitives.ConvertTo*](/dotnet/api/System.Management.Automation.LanguagePrimitives.ConvertTo) method to convert types to the desired type. - Your implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method should call - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) and check its return value before making any changes to the data store. After the call to - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) returns true, the - [System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method should call the - [System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) + [System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) method as an additional check for potentially dangerous system modifications. ## Attaching Dynamic Parameters to the New-Item Cmdlet Sometimes the `New-Item` cmdlet requires additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, the container provider must implement the -[System.Management.Automation.Provider.Containercmdletprovider.Newitemdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItemDynamicParameters) +[System.Management.Automation.Provider.ContainerCmdletProvider.NewItemDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItemDynamicParameters) method. This method retrieves the parameters for the item at the indicated path and returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the `New-Item` cmdlet. @@ -394,7 +394,7 @@ This provider does not implement this method. However, the following code is the ## Removing Items To remove items, the Windows PowerShell provider must override the -[System.Management.Automation.Provider.Containercmdletprovider.Removeitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) +[System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) method to support calls from the `Remove-Item` cmdlet. This method deletes an item from the data store at the specified path. If the `recurse` parameter of the `Remove-Item` cmdlet is set to `true`, the method removes all child items regardless of their level. If the parameter is set to @@ -402,65 +402,65 @@ store at the specified path. If the `recurse` parameter of the `Remove-Item` cmd This provider does not support item removal. However, the following code is the default implementation of -[System.Management.Automation.Provider.Containercmdletprovider.Removeitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem). +[System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem). #### Things to Remember About Implementing RemoveItem The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem): +[System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem): - When defining the provider class, a Windows PowerShell container provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) + [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) method needs to ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - By default, overrides of this method should not remove objects unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is set to true. If the specified path indicates a container, the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is not required. - Your implementation of - [System.Management.Automation.Provider.Containercmdletprovider.Removeitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) is responsible for preventing infinite recursion when there are circular links, and the like. An appropriate terminating exception should be thrown to reflect such a condition. - Your implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Removeitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) method should call - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) and check its return value before making any changes to the data store. After the call to - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) returns `true`, the - [System.Management.Automation.Provider.Containercmdletprovider.Removeitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) + [System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) method should call the - [System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) + [System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) method as an additional check for potentially dangerous system modifications. ## Attaching Dynamic Parameters to the Remove-Item Cmdlet Sometimes the `Remove-Item` cmdlet requires additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, the container provider must implement the -[System.Management.Automation.Provider.Containercmdletprovider.Removeitemdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItemDynamicParameters) +[System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItemDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItemDynamicParameters) method to handle these parameters. This method retrieves the dynamic parameters for the item at the indicated path and returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the `Remove-Item` cmdlet. This container provider does not implement this method. However, the following code is the default implementation of -[System.Management.Automation.Provider.Containercmdletprovider.Removeitemdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItemDynamicParameters). +[System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItemDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItemDynamicParameters). @@ -468,12 +468,12 @@ implementation of To check to see if child items exist at the specified path, the Windows PowerShell container provider must override the -[System.Management.Automation.Provider.Containercmdletprovider.Haschilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems) +[System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems) method. This method returns `true` if the item has children, and `false` otherwise. For a null or empty path, the method considers any items in the data store to be children and returns `true`. Here is the override for the -[System.Management.Automation.Provider.Containercmdletprovider.Haschilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems) +[System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems) method. If there are more than two path parts created by the ChunkPath helper method, the method returns `false`, since only a database container and a table container are defined. For more information about this helper method, see the ChunkPath method is discussed in @@ -491,11 +491,11 @@ protected override bool HasChildItems( string path ) #### Things to Remember About Implementing HasChildItems The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Containercmdletprovider.Haschilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems): +[System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems): - If the container provider exposes a root that contains interesting mount points, the implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Haschilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems) + [System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.HasChildItems) method should return `true` when a null or an empty string is passed in for the path. ## Copying Items @@ -518,24 +518,24 @@ The following conditions may apply to your implementation of - When defining the provider class, a Windows PowerShell container provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) + [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) method needs to ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - By default, overrides of this method should not copy objects over existing objects unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) - property is set to `true`. For example, the FileSystem provider will not copy c:\temp\abc.txt over - an existing c:\abc.txt file unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + property is set to `true`. For example, the FileSystem provider will not copy C:\temp\abc.txt over + an existing C:\abc.txt file unless the + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is set to `true`. If the path specified in the `copyPath` parameter exists and indicates a container, the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is not required. In this case, [System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem) should copy the item indicated by the `path` parameter to the container indicated by the @@ -549,13 +549,13 @@ The following conditions may apply to your implementation of - Your implementation of the [System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem) method should call - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) and check its return value before making any changes to the data store. After the call to - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) returns true, the [System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem) method should call the - [System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) + [System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) method as an additional check for potentially dangerous system modifications. For more information about calling these methods, see [Rename Items](#renaming-items). @@ -564,17 +564,17 @@ The following conditions may apply to your implementation of Sometimes the `Copy-Item` cmdlet requires additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, the Windows PowerShell container provider must implement the -[System.Management.Automation.Provider.Containercmdletprovider.Copyitemdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.CopyItemDynamicParameters) +[System.Management.Automation.Provider.ContainerCmdletProvider.CopyItemDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.CopyItemDynamicParameters) method to handle these parameters. This method retrieves the parameters for the item at the indicated path and returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the `Copy-Item` cmdlet. This provider does not implement this method. However, the following code is the default implementation of -[System.Management.Automation.Provider.Containercmdletprovider.Copyitemdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.CopyItemDynamicParameters). +[System.Management.Automation.Provider.ContainerCmdletProvider.CopyItemDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.CopyItemDynamicParameters). @@ -616,13 +616,13 @@ uses a fictitious Access database. 2. Run the `Get-ChildItem` cmdlet again to retrieve the data of a table. ```powershell - (Get-ChildItem mydb:customers).data + (Get-ChildItem mydb:customers).Data ``` The following output appears. ```output - TABLE_CAT : c:\PS\northwind + TABLE_CAT : C:\PS\northwind TABLE_SCHEM : TABLE_NAME : Customers TABLE_TYPE : TABLE @@ -649,7 +649,7 @@ uses a fictitious Access database. 4. Reuse `Get-Item` to retrieve the data for the items in row 0. ```powershell - (Get-Item mydb:\customers\0).data + (Get-Item mydb:\customers\0).Data ``` The following output appears. @@ -670,18 +670,18 @@ uses a fictitious Access database. 5. Now use the `New-Item` cmdlet to add a row to an existing table. The `Path` parameter specifies the full path to the row, and must indicate a row number that is greater than the existing number - of rows in the table. The `Type` parameter indicates "row" to specify that type of item to add. + of rows in the table. The `Type` parameter indicates `Row` to specify that type of item to add. Finally, the `Value` parameter specifies a comma-delimited list of column values for the row. ```powershell - New-Item -Path mydb:\Customers\3 -ItemType "row" -Value "3,CustomerFirstName,CustomerLastName,CustomerEmailAddress,CustomerTitle,CustomerCompany,CustomerPhone, CustomerAddress,CustomerCity,CustomerState,CustomerZip,CustomerCountry" + New-Item -Path mydb:\Customers\3 -ItemType "Row" -Value "3,CustomerFirstName,CustomerLastName,CustomerEmailAddress,CustomerTitle,CustomerCompany,CustomerPhone, CustomerAddress,CustomerCity,CustomerState,CustomerZip,CustomerCountry" ``` 6. Verify the correctness of the new item operation as follows. ```none PS mydb:\> cd Customers - PS mydb:\Customers> (Get-Item 3).data + PS mydb:\Customers> (Get-Item 3).Data ``` The following output appears. diff --git a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-content-provider.md b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-content-provider.md index e96197525222..5961ce221c53 100644 --- a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-content-provider.md +++ b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-content-provider.md @@ -22,13 +22,13 @@ contents of items is referred to as a Windows PowerShell content provider. ## Define the Windows PowerShell Content Provider Class A Windows PowerShell content provider must create a .NET class that supports the -[System.Management.Automation.Provider.Icontentcmdletprovider](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider) +[System.Management.Automation.Provider.IContentCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider) interface. Here is the class definition for the item provider described in this section. :::code language="csharp" source="~/../powershell-sdk-samples/SDK-2.0/csharp/AccessDBProviderSample06/AccessDBProviderSample06.cs" range="32-33"::: Note that in this class definition, the -[System.Management.Automation.Provider.Cmdletproviderattribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) +[System.Management.Automation.Provider.CmdletProviderAttribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) attribute includes two parameters. The first parameter specifies a user-friendly name for the provider that is used by Windows PowerShell. The second parameter specifies the Windows PowerShell specific capabilities that the provider exposes to the Windows PowerShell runtime during command @@ -38,7 +38,7 @@ processing. For this provider, there are no added Windows PowerShell specific ca As described in [Design Your Windows PowerShell Provider](./designing-your-windows-powershell-provider.md), the -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class derives from several other classes that provided different provider functionality. A Windows PowerShell content provider, therefore, typically defines all of the functionality provided by those classes. @@ -50,28 +50,28 @@ However, most providers, including the provider described here, can use the defa of this functionality that is provided by Windows PowerShell. To access the data store, the provider must implement the methods of the -[System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) +[System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) base class. For more information about implementing these methods, see [Creating a Windows PowerShell Drive Provider](./creating-a-windows-powershell-drive-provider.md). To manipulate the items of a data store, such as getting, setting, and clearing items, the provider must implement the methods provided by the -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) base class. For more information about implementing these methods, see [Creating a Windows PowerShell Item Provider](./creating-a-windows-powershell-item-provider.md). To work on multi-layer data stores, the provider must implement the methods provided by the -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) base class. For more information about implementing these methods, see [Creating a Windows PowerShell Container Provider](./creating-a-windows-powershell-container-provider.md). To support recursive commands, nested containers, and relative paths, the provider must implement the -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) base class. In addition, this Windows PowerShell content provider can attaches -[System.Management.Automation.Provider.Icontentcmdletprovider](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider) +[System.Management.Automation.Provider.IContentCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider) interface to the -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) base class, and must therefore implement the methods provided by that class. For more information, see implementing those methods, see [Implement a Navigation Windows PowerShell Provider](./creating-a-windows-powershell-navigation-provider.md). @@ -79,7 +79,7 @@ see implementing those methods, see ## Implementing a Content Reader To read content from an item, a provider must implements a content reader class that derives from -[System.Management.Automation.Provider.Icontentreader](/dotnet/api/System.Management.Automation.Provider.IContentReader). +[System.Management.Automation.Provider.IContentReader](/dotnet/api/System.Management.Automation.Provider.IContentReader). The content reader for this provider allows access to the contents of a row in a data table. The content reader class defines a **Read** method that retrieves the data from the indicated row and returns a list representing that data, a **Seek** method that moves the content reader, a **Close** @@ -90,7 +90,7 @@ method that closes the content reader, and a **Dispose** method. ## Implementing a Content Writer To write content to an item, a provider must implement a content writer class derives from -[System.Management.Automation.Provider.Icontentwriter](/dotnet/api/System.Management.Automation.Provider.IContentWriter). +[System.Management.Automation.Provider.IContentWriter](/dotnet/api/System.Management.Automation.Provider.IContentWriter). The content writer class defines a **Write** method that writes the specified row content, a **Seek** method that moves the content writer, a **Close** method that closes the content writer, and a **Dispose** method. @@ -100,12 +100,12 @@ and a **Dispose** method. ## Retrieving the Content Reader To get content from an item, the provider must implement the -[System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentreader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader) +[System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader) to support the `Get-Content` cmdlet. This method returns the content reader for the item located at the specified path. The reader object can then be opened to read the content. Here is the implementation of -[System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentreader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader) +[System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader) for this method for this provider. ```csharp @@ -134,26 +134,26 @@ public IContentReader GetContentReader(string path) #### Things to Remember About Implementing GetContentReader The following conditions may apply to an implementation of -[System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentreader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader): +[System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader): - When defining the provider class, a Windows PowerShell content provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentreader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader) + [System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader) method must ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - By default, overrides of this method should not retrieve a reader for objects that are hidden from the user unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is set to `true`. An error should be written if the path represents an item that is hidden from the user and - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) is set to `false`. ## Attaching Dynamic Parameters to the Get-Content Cmdlet @@ -161,10 +161,10 @@ The following conditions may apply to an implementation of The `Get-Content` cmdlet might require additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, the Windows PowerShell content provider must implement the -[System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentreaderdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReaderDynamicParameters) +[System.Management.Automation.Provider.IContentCmdletProvider.GetContentReaderdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReaderDynamicParameters) method. This method retrieves dynamic parameters for the item at the indicated path and returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the cmdlet. This Windows PowerShell container provider does not implement this method. However, the following @@ -182,12 +182,12 @@ public object GetContentReaderDynamicParameters(string path) ## Retrieving the Content Writer To write content to an item, the provider must implement the -[System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentwriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter) +[System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter) to support the `Set-Content` and `Add-Content` cmdlets. This method returns the content writer for the item located at the specified path. Here is the implementation of -[System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentwriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter) +[System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter) for this method. ```csharp @@ -216,26 +216,26 @@ public IContentWriter GetContentWriter(string path) #### Things to Remember About Implementing GetContentWriter The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentwriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter): +[System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter): - When defining the provider class, a Windows PowerShell content provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentwriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter) + [System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter) method must ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - By default, overrides of this method should not retrieve a writer for objects that are hidden from the user unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is set to `true`. An error should be written if the path represents an item that is hidden from the user and - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) is set to `false`. ## Attaching Dynamic Parameters to the Add-Content and Set-Content Cmdlets @@ -243,11 +243,11 @@ The following conditions may apply to your implementation of The `Add-Content` and `Set-Content` cmdlets might require additional dynamic parameters that are added a runtime. To provide these dynamic parameters, the Windows PowerShell content provider must implement the -[System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentwriterdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriterDynamicParameters) +[System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriterDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriterDynamicParameters) method to handle these parameters. This method retrieves dynamic parameters for the item at the indicated path and returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the cmdlets. @@ -259,12 +259,12 @@ code is the default implementation of this method. ## Clearing Content Your content provider implements the -[System.Management.Automation.Provider.Icontentcmdletprovider.Clearcontent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) +[System.Management.Automation.Provider.IContentCmdletProvider.ClearContent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) method in support of the `Clear-Content` cmdlet. This method removes the contents of the item at the specified path, but leaves the item intact. Here is the implementation of the -[System.Management.Automation.Provider.Icontentcmdletprovider.Clearcontent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) +[System.Management.Automation.Provider.IContentCmdletProvider.ClearContent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) method for this provider. :::code language="csharp" source="~/../powershell-sdk-samples/SDK-2.0/csharp/AccessDBProviderSample06/AccessDBProviderSample06.cs" range="1775-1812"::: @@ -272,61 +272,61 @@ method for this provider. #### Things to Remember About Implementing ClearContent The following conditions may apply to an implementation of -[System.Management.Automation.Provider.Icontentcmdletprovider.Clearcontent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent): +[System.Management.Automation.Provider.IContentCmdletProvider.ClearContent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent): - When defining the provider class, a Windows PowerShell content provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Icontentcmdletprovider.Clearcontent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) + [System.Management.Automation.Provider.IContentCmdletProvider.ClearContent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) method must ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - By default, overrides of this method should not clear the contents of objects that are hidden from the user unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is set to `true`. An error should be written if the path represents an item that is hidden from the user and - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) is set to `false`. - Your implementation of the - [System.Management.Automation.Provider.Icontentcmdletprovider.Clearcontent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) + [System.Management.Automation.Provider.IContentCmdletProvider.ClearContent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) method should call - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) and verify its return value before making any changes to the data store. This method is used to confirm execution of an operation when a change is made to the data store, such as clearing content. The - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) method sends the name of the resource to be changed to the user, with the Windows PowerShell runtime handling any command-line settings or preference variables in determining what should be displayed. After the call to - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) returns `true`, the - [System.Management.Automation.Provider.Icontentcmdletprovider.Clearcontent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) + [System.Management.Automation.Provider.IContentCmdletProvider.ClearContent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) method should call the - [System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) + [System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) method. This method sends a message to the user to allow feedback to verify if the operation should be continued. The call to - [System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) + [System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) allows an additional check for potentially dangerous system modifications. ## Attaching Dynamic Parameters to the Clear-Content Cmdlet The `Clear-Content` cmdlet might require additional dynamic parameters that are added at runtime. To provide these dynamic parameters, the Windows PowerShell content provider must implement the -[System.Management.Automation.Provider.Icontentcmdletprovider.Clearcontentdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContentDynamicParameters) +[System.Management.Automation.Provider.IContentCmdletProvider.ClearContentDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContentDynamicParameters) method to handle these parameters. This method retrieves the parameters for the item at the indicated path. This method retrieves dynamic parameters for the item at the indicated path and returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the cmdlet. This Windows PowerShell container provider does not implement this method. However, the following code is the default implementation of this method. diff --git a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-drive-provider.md b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-drive-provider.md index da3d42aee1e4..b1d7d22170f2 100644 --- a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-drive-provider.md +++ b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-drive-provider.md @@ -19,26 +19,26 @@ the database, and the items of the containers represent the rows in the tables. ## Defining the Windows PowerShell Provider Class Your drive provider must define a .NET class that derives from the -[System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) +[System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) base class. Here is the class definition for this drive provider: :::code language="csharp" source="~/../powershell-sdk-samples/SDK-2.0/csharp/AccessDBProviderSample02/AccessDBProviderSample02.cs" range="29-30"::: Notice that in this example, the -[System.Management.Automation.Provider.Cmdletproviderattribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) +[System.Management.Automation.Provider.CmdletProviderAttribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) attribute specifies a user-friendly name for the provider and the Windows PowerShell specific capabilities that the provider exposes to the Windows PowerShell runtime during command processing. The possible values for the provider capabilities are defined by the -[System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) +[System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. This drive provider does not support any of these capabilities. ## Defining Base Functionality As described in [Design Your Windows PowerShell Provider](./designing-your-windows-powershell-provider.md), the -[System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) +[System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class derives from the -[System.Management.Automation.Provider.Cmdletprovider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) +[System.Management.Automation.Provider.CmdletProvider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) base class that defines the methods needed for initializing and uninitializing the provider. To implement functionality for adding session-specific initialization information and for releasing resources that are used by the provider, see @@ -62,9 +62,9 @@ object that describes the drive: ## Creating a Drive To allow the Windows PowerShell runtime to create a drive, the drive provider must implement the -[System.Management.Automation.Provider.Drivecmdletprovider.Newdrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) +[System.Management.Automation.Provider.DriveCmdletProvider.NewDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) method. The following code shows the implementation of the -[System.Management.Automation.Provider.Drivecmdletprovider.Newdrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) +[System.Management.Automation.Provider.DriveCmdletProvider.NewDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) method for this drive provider: :::code language="csharp" source="~/../powershell-sdk-samples/SDK-2.0/csharp/AccessDBProviderSample02/AccessDBProviderSample02.cs" range="42-84"::: @@ -83,7 +83,7 @@ Your override of this method should do the following: object that describes the drive with any required performance or reliability information, or provide extra data for callers using the drive. - Handle failures using the - [System.Management.Automation.Provider.Cmdletprovider.WriteError](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WriteError) + [System.Management.Automation.Provider.CmdletProvider.WriteError](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WriteError) method and then return `null`. This method returns either the drive information that was passed to the method or a @@ -93,10 +93,10 @@ Your override of this method should do the following: The `New-PSDrive` cmdlet supported by your drive provider might require additional parameters. To attach these dynamic parameters to the cmdlet, the provider implements the -[System.Management.Automation.Provider.Drivecmdletprovider.Newdrivedynamicparameters*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDriveDynamicParameters) +[System.Management.Automation.Provider.DriveCmdletProvider.NewDriveDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDriveDynamicParameters) method. This method returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. This drive provider does not override this method. However, the following code shows the default @@ -107,12 +107,12 @@ implementation of this method: ## Removing a Drive To close the database connection, the drive provider must implement the -[System.Management.Automation.Provider.Drivecmdletprovider.Removedrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) +[System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) method. This method closes the connection to the drive after cleaning up any provider-specific information. The following code shows the implementation of the -[System.Management.Automation.Provider.Drivecmdletprovider.Removedrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) +[System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) method for this drive provider: :::code language="csharp" source="~/../powershell-sdk-samples/SDK-2.0/csharp/AccessDBProviderSample02/AccessDBProviderSample02.cs" range="91-116"::: @@ -125,17 +125,17 @@ method just returns the drive information passed as input. ## Initializing Default Drives Your drive provider implements the -[System.Management.Automation.Provider.Drivecmdletprovider.Initializedefaultdrives*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.InitializeDefaultDrives) +[System.Management.Automation.Provider.DriveCmdletProvider.InitializeDefaultDrives*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.InitializeDefaultDrives) method to mount drives. For example, the Active Directory provider might mount a drive for the default naming context if the computer is joined to a domain. This method returns a collection of drive information about the initialized drives, or an empty collection. The call to this method is made after the Windows PowerShell runtime calls the -[System.Management.Automation.Provider.Cmdletprovider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) +[System.Management.Automation.Provider.CmdletProvider.Start*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Start) method to initialize the provider. This drive provider does not override the -[System.Management.Automation.Provider.Drivecmdletprovider.Initializedefaultdrives*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.InitializeDefaultDrives) +[System.Management.Automation.Provider.DriveCmdletProvider.InitializeDefaultDrives*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.InitializeDefaultDrives) method. However, the following code shows the default implementation, which returns an empty drive collection: @@ -184,7 +184,7 @@ derivation. Let's test the sample drive provider. 3. Create a new drive using the sample drive provider: ```powershell - new-psdrive -name mydb -root c:\ps\northwind.mdb -psprovider AccessDb` + New-PSDrive -Name mydb -Root C:\ps\northwind.mdb -PSProvider AccessDb` ``` The following output appears: @@ -192,7 +192,7 @@ derivation. Let's test the sample drive provider. ```Output Name Provider Root CurrentLocation ---- -------- ---- --------------- - mydb AccessDB c:\ps\northwind.mdb + mydb AccessDB C:\ps\northwind.mdb ``` 4. Validate the connection. Because the connection is defined as a member of the drive, you can @@ -203,14 +203,14 @@ derivation. Let's test the sample drive provider. > functionality for that interaction. For more information, see > [Creating a Windows PowerShell Container Provider](./creating-a-windows-powershell-container-provider.md). - **PS> (get-psdrive mydb).connection** + **PS> (Get-PSDrive mydb).Connection** The following output appears: ```Output - ConnectionString : Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\ps\northwind.mdb + ConnectionString : Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\ps\northwind.mdb ConnectionTimeout : 15 - Database : c:\ps\northwind + Database : C:\ps\northwind DataSource : ACCESS ServerVersion : 04.00.0000 Driver : odbcjt32.dll @@ -222,7 +222,7 @@ derivation. Let's test the sample drive provider. 5. Remove the drive and exit the shell: ```powershell - PS> remove-psdrive mydb + PS> Remove-PSDrive mydb PS> exit ``` diff --git a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-navigation-provider.md b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-navigation-provider.md index 2eaa47db6b1e..29001bbf4424 100644 --- a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-navigation-provider.md +++ b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-navigation-provider.md @@ -32,13 +32,13 @@ an item, and test to identify if an item is a container. ## Define the Windows PowerShell provider A Windows PowerShell navigation provider must create a .NET class that derives from the -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) base class. Here is the class definition for the navigation provider described in this section. :::code language="csharp" source="~/../powershell-sdk-samples/SDK-2.0/csharp/AccessDBProviderSample05/AccessDBProviderSample05.cs" range="31-32"::: Note that in this provider, the -[System.Management.Automation.Provider.Cmdletproviderattribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) +[System.Management.Automation.Provider.CmdletProviderAttribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) attribute includes two parameters. The first parameter specifies a user-friendly name for the provider that is used by Windows PowerShell. The second parameter specifies the Windows PowerShell specific capabilities that the provider exposes to the Windows PowerShell runtime during command @@ -47,7 +47,7 @@ processing. For this provider, there are no Windows PowerShell specific capabili ## Defining Base Functionality As described in [Design Your PS Provider](./designing-your-windows-powershell-provider.md), the -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) base class derives from several other classes that provided different provider functionality. A Windows PowerShell navigation provider, therefore, must define all of the functionality provided by those classes. @@ -60,19 +60,19 @@ functionality provided by Windows PowerShell. To get access to the data store through a Windows PowerShell drive, you must implement the methods of the -[System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) +[System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) base class. For more information about implementing these methods, see [Creating a Windows PowerShell Drive Provider](./creating-a-windows-powershell-drive-provider.md). To manipulate the items of a data store, such as getting, setting, and clearing items, the provider must implement the methods provided by the -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) base class. For more information about implementing these methods, see [Creating a Windows PowerShell Item Provider](./creating-a-windows-powershell-item-provider.md). To get to the child items, or their names, of the data store, as well as methods that create, copy, rename, and remove items, you must implement the methods provided by the -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) base class. For more information about implementing these methods, see [Creating a Windows PowerShell Container Provider](./creating-a-windows-powershell-container-provider.md). @@ -80,7 +80,7 @@ base class. For more information about implementing these methods, see Windows PowerShell navigation provider use a provider-internal Windows PowerShell path to navigate the items of the data store. To create a provider-internal path the provider must implement the -[System.Management.Automation.Provider.Navigationcmdletprovider.Makepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) +[System.Management.Automation.Provider.NavigationCmdletProvider.MakePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) method to supports calls from the Combine-Path cmdlet. This method combines a parent and child path into a provider-internal path, using a provider-specific path separator between the parent and child paths. @@ -91,7 +91,7 @@ then returns a string that contains the combined paths. This navigation provider does not implement this method. However, the following code is the default implementation of the -[System.Management.Automation.Provider.Navigationcmdletprovider.Makepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) +[System.Management.Automation.Provider.NavigationCmdletProvider.MakePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) method. @@ -99,28 +99,28 @@ method. #### Things to Remember About Implementing MakePath The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Navigationcmdletprovider.Makepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath): +[System.Management.Automation.Provider.NavigationCmdletProvider.MakePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath): - Your implementation of the - [System.Management.Automation.Provider.Navigationcmdletprovider.Makepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) + [System.Management.Automation.Provider.NavigationCmdletProvider.MakePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) method should not validate the path as a legal fully-qualified path in the provider namespace. Be aware that each parameter can only represent a part of a path, and the combined parts might not generate a fully-qualified path. For example, the - [System.Management.Automation.Provider.Navigationcmdletprovider.Makepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) - method for the filesystem provider might receive "windows\system32" in the `parent` parameter and + [System.Management.Automation.Provider.NavigationCmdletProvider.MakePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) + method for the FileSystem provider might receive "windows\system32" in the `parent` parameter and "abc.dll" in the `child` parameter. The method joins these values with the "\\" separator and returns "windows\system32\abc.dll", which is not a fully-qualified file system path. > [!IMPORTANT] > The path parts provided in the call to - > [System.Management.Automation.Provider.Navigationcmdletprovider.Makepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) + > [System.Management.Automation.Provider.NavigationCmdletProvider.MakePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) > might contain characters not allowed in the provider namespace. These characters are most likely > used for wildcard expansion and the implementation of this method should not remove them. ## Retrieving the Parent Path Windows PowerShell navigation providers implement the -[System.Management.Automation.Provider.Navigationcmdletprovider.Getparentpath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetParentPath) +[System.Management.Automation.Provider.NavigationCmdletProvider.GetParentPath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetParentPath) method to retrieve the parent part of the indicated full or partial provider-specific path. The method removes the child part of the path and returns the parent path part. The `root` parameter specifies the fully-qualified path to the root of a drive. This parameter can be null or empty if a @@ -136,15 +136,15 @@ only "\\" separators, then splits the parent path off at the last "\\" and retur #### To Remember About Implementing GetParentPath Your implementation of the -[System.Management.Automation.Provider.Navigationcmdletprovider.Getparentpath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetParentPath) +[System.Management.Automation.Provider.NavigationCmdletProvider.GetParentPath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetParentPath) method should split the path lexically on the path separator for the provider namespace. For -example, the filesystem provider uses this method to look for the last "\\" and returns everything +example, the FileSystem provider uses this method to look for the last "\\" and returns everything to the left of the separator. ## Retrieve the Child Path Name Your navigation provider implements the -[System.Management.Automation.Provider.Navigationcmdletprovider.Getchildname*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName) +[System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName) method to retrieve the name (leaf element) of the child of the item located at the indicated full or partial provider-specific path. @@ -158,7 +158,7 @@ of the child path part. #### Things to Remember About Implementing GetChildName Your implementation of the -[System.Management.Automation.Provider.Navigationcmdletprovider.Getchildname*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName) +[System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName) method should split the path lexically on the path separator. If the supplied path contains no path separators, the method should return the path unmodified. @@ -170,13 +170,13 @@ separators, the method should return the path unmodified. ## Determining if an Item is a Container The navigation provider can implement the -[System.Management.Automation.Provider.Navigationcmdletprovider.Isitemcontainer*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer) +[System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer) method to determine if the specified path indicates a container. It returns true if the path represents a container, and false otherwise. The user needs this method to be able to use the `Test-Path` cmdlet for the supplied path. The following code shows the -[System.Management.Automation.Provider.Navigationcmdletprovider.Isitemcontainer*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer) +[System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer) implementation in our sample navigation provider. The method verifies that the specified path is correct and if the table exists, and returns true if the path indicates a container. @@ -186,22 +186,22 @@ correct and if the table exists, and returns true if the path indicates a contai Your navigation provider .NET class might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the -[System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) +[System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In this case, the implementation of -[System.Management.Automation.Provider.Navigationcmdletprovider.Isitemcontainer*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer) +[System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer) needs to ensure that the path passed meets requirements. To do this, the method should access the appropriate property, for example, the -[System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) +[System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) property. ## Moving an Item In support of the `Move-Item` cmdlet, your navigation provider implements the -[System.Management.Automation.Provider.Navigationcmdletprovider.Moveitem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) +[System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) method. This method moves the item specified by the `path` parameter to the container at the path supplied in the `destination` parameter. -The sample navigation provider does not override the [System.Management.Automation.Provider.Navigationcmdletprovider.Moveitem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) method. The following is the default implementation. +The sample navigation provider does not override the [System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) method. The following is the default implementation. @@ -209,68 +209,68 @@ The sample navigation provider does not override the [System.Management.Automati Your navigation provider .NET class might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the -[System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) +[System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In this case, the implementation of -[System.Management.Automation.Provider.Navigationcmdletprovider.Moveitem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) +[System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) must ensure that the path passed meets requirements. To do this, the method should access the appropriate property, for example, the **CmdletProvider.Exclude** property. By default, overrides of this method should not move objects over existing objects unless the -[System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) -property is set to `true`. For example, the filesystem provider will not copy c:\temp\abc.txt over -an existing c:\bar.txt file unless the -[System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) +[System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) +property is set to `true`. For example, the FileSystem provider will not copy C:\temp\abc.txt over +an existing C:\bar.txt file unless the +[System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is set to `true`. If the path specified in the `destination` parameter exists and is a container, the -[System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) +[System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is not required. In this case, -[System.Management.Automation.Provider.Navigationcmdletprovider.Moveitem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) +[System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) should move the item indicated by the `path` parameter to the container indicated by the `destination` parameter as a child. Your implementation of the -[System.Management.Automation.Provider.Navigationcmdletprovider.Moveitem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) +[System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) method should call -[System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) +[System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) and check its return value before making any changes to the data store. This method is used to confirm execution of an operation when a change is made to system state, for example, deleting files. -[System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) +[System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) sends the name of the resource to be changed to the user, with the Windows PowerShell runtime taking into account any command line settings or preference variables in determining what should be displayed to the user. After the call to -[System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) +[System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) returns `true`, the -[System.Management.Automation.Provider.Navigationcmdletprovider.Moveitem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) +[System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) method should call the -[System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) +[System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) method. This method sends a message to the user to allow feedback to say if the operation should be continued. Your provider should call -[System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) +[System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) as an additional check for potentially dangerous system modifications. ## Attaching Dynamic Parameters to the Move-Item Cmdlet Sometimes the `Move-Item` cmdlet requires additional parameters that are provided dynamically at runtime. To provide these dynamic parameters, the navigation provider must implement the -[System.Management.Automation.Provider.Navigationcmdletprovider.Moveitemdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItemDynamicParameters) +[System.Management.Automation.Provider.NavigationCmdletProvider.MoveItemDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItemDynamicParameters) method to get the required parameter values from the item at the indicated path, and return an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. This navigation provider does not implement this method. However, the following code is the default implementation of -[System.Management.Automation.Provider.Navigationcmdletprovider.Moveitemdynamicparameters*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItemDynamicParameters). +[System.Management.Automation.Provider.NavigationCmdletProvider.MoveItemDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItemDynamicParameters). ## Normalizing a Relative Path Your navigation provider implements the -[System.Management.Automation.Provider.Navigationcmdletprovider.Normalizerelativepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.NormalizeRelativePath) +[System.Management.Automation.Provider.NavigationCmdletProvider.NormalizeRelativePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.NormalizeRelativePath) method to normalize the fully-qualified path indicated in the `path` parameter as being relative to the path specified by the `basePath` parameter. The method returns a string representation of the normalized path. It writes an error if the `path` parameter specifies a nonexistent path. @@ -282,7 +282,7 @@ The sample navigation provider does not override this method. The following is t #### Things to Remember About Implementing NormalizeRelativePath Your implementation of -[System.Management.Automation.Provider.Navigationcmdletprovider.Normalizerelativepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.NormalizeRelativePath) +[System.Management.Automation.Provider.NavigationCmdletProvider.NormalizeRelativePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.NormalizeRelativePath) should parse the `path` parameter, but it does not have to use purely syntactical parsing. You are encouraged to design this method to use the path to look up the path information in the data store and create a path that matches the casing and standardized path syntax. @@ -315,11 +315,11 @@ derivation. This example will test the sample navigation provider. Set-Location mydb: ``` -2. Now run the `Get-Childitem` cmdlet to retrieve a list of the database items, which are the +2. Now run the `Get-ChildItem` cmdlet to retrieve a list of the database items, which are the available database tables. For each table, this cmdlet also retrieves the number of table rows. ```powershell - Get-ChildItem | Format-Table rowcount,name -AutoSize + Get-ChildItem | Format-Table RowCount, Name -AutoSize ``` ```Output @@ -361,12 +361,12 @@ derivation. This example will test the sample navigation provider. mydb:\Employees ``` -5. Now use the `Get-Childitem` cmdlet piped to the `Format-Table` cmdlet. This set of cmdlets +5. Now use the `Get-ChildItem` cmdlet piped to the `Format-Table` cmdlet. This set of cmdlets retrieves the items for the Employees data table, which are the table rows. They are formatted as specified by the `Format-Table` cmdlet. ```powershell - Get-ChildItem | Format-Table rownumber,psiscontainer,data -AutoSize + Get-ChildItem | Format-Table RowNumber, PSIsContainer, Data -AutoSize ``` ```Output @@ -404,7 +404,7 @@ derivation. This example will test the sample navigation provider. 7. Use the `Get-Item` cmdlet again to retrieve the employee data for the items in row 0. ```powershell - (Get-Item 0).data + (Get-Item 0).Data ``` ```Output diff --git a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-property-provider.md b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-property-provider.md index 797cee7a787d..d3fbd87aba80 100644 --- a/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-property-provider.md +++ b/reference/docs-conceptual/developer/prog-guide/creating-a-windows-powershell-property-provider.md @@ -11,7 +11,7 @@ items in a data store. As a consequence, this type of provider is referred to as PowerShell property provider. For example, the Registry provider provided by Windows PowerShell handles registry key values as properties of the registry key item. This type of provider must add the -[System.Management.Automation.Provider.Ipropertycmdletprovider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider) +[System.Management.Automation.Provider.IPropertyCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider) interface to the implementation of the .NET class. > [!NOTE] @@ -27,13 +27,13 @@ interface to the implementation of the .NET class. > [!CAUTION] > The methods of your property provider should write any objects using the -> [System.Management.Automation.Provider.Cmdletprovider.Writepropertyobject*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WritePropertyObject) +> [System.Management.Automation.Provider.CmdletProvider.Writepropertyobject*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WritePropertyObject) > method. ## Defining the Windows PowerShell provider A property provider must create a .NET class that supports the -[System.Management.Automation.Provider.Ipropertycmdletprovider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider) +[System.Management.Automation.Provider.IPropertyCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider) interface. Here is the default class declaration from the TemplateProvider.cs file provided by Windows PowerShell. @@ -42,9 +42,9 @@ Windows PowerShell. ## Defining Base Functionality The -[System.Management.Automation.Provider.Ipropertycmdletprovider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider) +[System.Management.Automation.Provider.IPropertyCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider) interface can be attached to any of the provider base classes, with the exception of the -[System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) +[System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class. Add the base functionality that is required by the base class you are using. For more information about base classes, see [Designing Your Windows PowerShell Provider](./designing-your-windows-powershell-provider.md). @@ -52,26 +52,26 @@ information about base classes, see ## Retrieving Properties To retrieve properties, the provider must implement the -[System.Management.Automation.Provider.Ipropertycmdletprovider.Getproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) +[System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) method to support calls from the `Get-ItemProperty` cmdlet. This method retrieves the properties of the item located at the specified provider-internal path (fully-qualified). The `providerSpecificPickList` parameter indicates which properties to retrieve. If this parameter is `null` or empty, the method should retrieve all properties. In addition, -[System.Management.Automation.Provider.Ipropertycmdletprovider.Getproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) +[System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) writes an instance of a [System.Management.Automation.PSObject](/dotnet/api/System.Management.Automation.PSObject) object that represents a property bag of the retrieved properties. The method should return nothing. It is recommended that the implementation of -[System.Management.Automation.Provider.Ipropertycmdletprovider.Getproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) +[System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) supports the wildcard expansion of property names for each element in the pick list. To do this, use the -[System.Management.Automation.Wildcardpattern](/dotnet/api/System.Management.Automation.WildcardPattern) +[System.Management.Automation.WildcardPattern](/dotnet/api/System.Management.Automation.WildcardPattern) class to perform the wildcard pattern matching. Here is the default implementation of -[System.Management.Automation.Provider.Ipropertycmdletprovider.Getproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) +[System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) from the TemplateProvider.cs file provided by Windows PowerShell. @@ -79,26 +79,26 @@ from the TemplateProvider.cs file provided by Windows PowerShell. #### Things to Remember About Implementing GetProperty The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Ipropertycmdletprovider.Getproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty): +[System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty): - When defining the provider class, a Windows PowerShell property provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Ipropertycmdletprovider.Getproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) + [System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) method needs to ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - By default, overrides of this method should not retrieve a reader for objects that are hidden from the user unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is set to `true`. An error should be written if the path represents an item that is hidden from the user and - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) is set to `false`. ## Attaching Dynamic Parameters to the Get-ItemProperty Cmdlet @@ -106,17 +106,17 @@ The following conditions may apply to your implementation of The `Get-ItemProperty` cmdlet might require additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, the Windows PowerShell property provider must implement the -[System.Management.Automation.Provider.Ipropertycmdletprovider.Getpropertydynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters) +[System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters) method. The `path` parameter indicates a fully-qualified provider-internal path, while the `providerSpecificPickList` parameter specifies the provider-specific properties entered on the command line. This parameter might be `null` or empty if the properties are piped to the cmdlet. In this case, this method returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The Windows PowerShell runtime uses the returned object to add the parameters to the cmdlet. Here is the default implementation of -[System.Management.Automation.Provider.Ipropertycmdletprovider.Getpropertydynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters) +[System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters) from the TemplateProvider.cs file provided by Windows PowerShell. @@ -124,16 +124,16 @@ from the TemplateProvider.cs file provided by Windows PowerShell. ## Setting Properties To set properties, the Windows PowerShell property provider must implement the -[System.Management.Automation.Provider.Ipropertycmdletprovider.Setproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) +[System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) method to support calls from the `Set-ItemProperty` cmdlet. This method sets one or more properties of the item at the specified path, and overwrites the supplied properties as required. -[System.Management.Automation.Provider.Ipropertycmdletprovider.Setproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) +[System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) also writes an instance of a [System.Management.Automation.PSObject](/dotnet/api/System.Management.Automation.PSObject) object that represents a property bag of the updated properties. Here is the default implementation of -[System.Management.Automation.Provider.Ipropertycmdletprovider.Setproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) +[System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) from the TemplateProvider.cs file provided by Windows PowerShell. @@ -141,46 +141,46 @@ from the TemplateProvider.cs file provided by Windows PowerShell. #### Things to Remember About Implementing Set-ItemProperty The following conditions may apply to an implementation of -[System.Management.Automation.Provider.Ipropertycmdletprovider.Setproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty): +[System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty): - When defining the provider class, a Windows PowerShell property provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Ipropertycmdletprovider.Setproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) + [System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) method must ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - By default, overrides of this method should not retrieve a reader for objects that are hidden from the user unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is set to `true`. An error should be written if the path represents an item that is hidden from the user and - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) is set to `false`. - Your implementation of the - [System.Management.Automation.Provider.Ipropertycmdletprovider.Setproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) + [System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) method should call - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) and verify its return value before making any changes to the data store. This method is used to confirm execution of an operation when a change is made to system state, for example, renaming files. - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) sends the name of the resource to be changed to the user, with the Windows PowerShell runtime and handling any command-line settings or preference variables in determining what should be displayed. After the call to - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) returns `true`, if potentially dangerous system modifications can be made, the - [System.Management.Automation.Provider.Ipropertycmdletprovider.Setproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) + [System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) method should call the - [System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) + [System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) method. This method sends a confirmation message to the user to allow additional feedback to indicate that the operation should be continued. @@ -189,25 +189,25 @@ The following conditions may apply to an implementation of The `Set-ItemProperty` cmdlet might require additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, the Windows PowerShell property provider must implement the -[System.Management.Automation.Provider.Ipropertycmdletprovider.Setpropertydynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetPropertyDynamicParameters) +[System.Management.Automation.Provider.IPropertyCmdletProvider.SetPropertyDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetPropertyDynamicParameters) method. This method returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The `null` value can be returned if no dynamic parameters are to be added. -Here is the default implementation of [System.Management.Automation.Provider.Ipropertycmdletprovider.Getpropertydynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters) from the TemplateProvider.cs file provided by Windows PowerShell. +Here is the default implementation of [System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetPropertyDynamicParameters) from the TemplateProvider.cs file provided by Windows PowerShell. ## Clearing Properties To clear properties, the Windows PowerShell property provider must implement the -[System.Management.Automation.Provider.Ipropertycmdletprovider.Clearproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) +[System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) method to support calls from the `Clear-ItemProperty` cmdlet. This method sets one or more properties for the item located at the specified path. Here is the default implementation of -[System.Management.Automation.Provider.Ipropertycmdletprovider.Clearproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) +[System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) from the TemplateProvider.cs file provided by Windows PowerShell. @@ -215,46 +215,46 @@ from the TemplateProvider.cs file provided by Windows PowerShell. #### Thing to Remember About Implementing ClearProperty The following conditions may apply to your implementation of -[System.Management.Automation.Provider.Ipropertycmdletprovider.Clearproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty): +[System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty): - When defining the provider class, a Windows PowerShell property provider might declare provider capabilities of ExpandWildcards, Filter, Include, or Exclude, from the - [System.Management.Automation.Provider.Providercapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) + [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) enumeration. In these cases, the implementation of the - [System.Management.Automation.Provider.Ipropertycmdletprovider.Clearproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) + [System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) method needs to ensure that the path passed to the method meets the requirements of the specified capabilities. To do this, the method should access the appropriate property, for example, the - [System.Management.Automation.Provider.Cmdletprovider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) + [System.Management.Automation.Provider.CmdletProvider.Exclude*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Exclude) and - [System.Management.Automation.Provider.Cmdletprovider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) + [System.Management.Automation.Provider.CmdletProvider.Include*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Include) properties. - By default, overrides of this method should not retrieve a reader for objects that are hidden from the user unless the - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) property is set to `true`. An error should be written if the path represents an item that is hidden from the user and - [System.Management.Automation.Provider.Cmdletprovider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) + [System.Management.Automation.Provider.CmdletProvider.Force*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.Force) is set to `false`. - Your implementation of the - [System.Management.Automation.Provider.Ipropertycmdletprovider.Clearproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) + [System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) method should call - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) and verify its return value before making any changes to the data store. This method is used to confirm execution of an operation before a change is made to system state, such as clearing content. - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) sends the name of the resource to be changed to the user, with the Windows PowerShell runtime taking into account any command line settings or preference variables in determining what should be displayed. After the call to - [System.Management.Automation.Provider.Cmdletprovider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) + [System.Management.Automation.Provider.CmdletProvider.ShouldProcess](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldProcess) returns `true`, if potentially dangerous system modifications can be made, the - [System.Management.Automation.Provider.Ipropertycmdletprovider.Clearproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) + [System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) method should call the - [System.Management.Automation.Provider.Cmdletprovider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) + [System.Management.Automation.Provider.CmdletProvider.ShouldContinue](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.ShouldContinue) method. This method sends a confirmation message to the user to allow additional feedback to indicate that the potentially dangerous operation should be continued. @@ -263,14 +263,14 @@ The following conditions may apply to your implementation of The `Clear-ItemProperty` cmdlet might require additional parameters that are specified dynamically at runtime. To provide these dynamic parameters, the Windows PowerShell property provider must implement the -[System.Management.Automation.Provider.Ipropertycmdletprovider.Clearpropertydynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearPropertyDynamicParameters) +[System.Management.Automation.Provider.IPropertyCmdletProvider.ClearPropertyDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearPropertyDynamicParameters) method. This method returns an object that has properties and fields with parsing attributes similar to a cmdlet class or a -[System.Management.Automation.Runtimedefinedparameterdictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) +[System.Management.Automation.RuntimeDefinedParameterDictionary](/dotnet/api/System.Management.Automation.RuntimeDefinedParameterDictionary) object. The `null` value can be returned if no dynamic parameters are to be added. Here is the default implementation of -[System.Management.Automation.Provider.Ipropertycmdletprovider.Clearpropertydynamicparameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearPropertyDynamicParameters) +[System.Management.Automation.Provider.IPropertyCmdletProvider.ClearPropertyDynamicParameters*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearPropertyDynamicParameters) from the TemplateProvider.cs file provided by Windows PowerShell. diff --git a/reference/docs-conceptual/developer/prog-guide/designing-your-windows-powershell-provider.md b/reference/docs-conceptual/developer/prog-guide/designing-your-windows-powershell-provider.md index 93755144da4e..2e31313faec0 100644 --- a/reference/docs-conceptual/developer/prog-guide/designing-your-windows-powershell-provider.md +++ b/reference/docs-conceptual/developer/prog-guide/designing-your-windows-powershell-provider.md @@ -33,7 +33,7 @@ example, mydrive:\abc\bar. To allow the Windows PowerShell runtime to initialize and uninitialize the provider, your Windows PowerShell provider must support a provider-qualified path. For example, -FileSystem::\\\uncshare\abc\bar is the provider-qualified path for the filesystem provider furnished +FileSystem::\\\uncshare\abc\bar is the provider-qualified path for the FileSystem provider furnished by Windows PowerShell. ### Defining a Provider-Direct Path @@ -47,12 +47,12 @@ registry Windows PowerShell provider can use \\\server\regkeypath as a provider- To allow the provider cmdlet to access data using non-Windows PowerShell application programming interfaces (APIs), your Windows PowerShell provider should support a provider-internal path. This path is indicated after the "::" in the provider-qualified path. For example, the provider-internal -path for the filesystem Windows PowerShell provider is \\\uncshare\abc\bar. +path for the FileSystem Windows PowerShell provider is \\\uncshare\abc\bar. ## Changing Stored Data When overriding methods that modify the underlying data store, always call the -[System.Management.Automation.Provider.Cmdletprovider.Writeitemobject*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WriteItemObject) +[System.Management.Automation.Provider.CmdletProvider.WriteItemObject*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WriteItemObject) method with the most up-to-date version of the item changed by that method. The provider infrastructure determines if the item object needs to be passed to the pipeline, such as when the user specifies the -PassThru parameter. If retrieving the most up-to-date item is a costly operation @@ -76,7 +76,7 @@ location cmdlets. ### CmdletProvider Base Class The -[System.Management.Automation.Provider.Cmdletprovider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) +[System.Management.Automation.Provider.CmdletProvider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) class defines a basic Windows PowerShell provider. This class supports the provider declaration and supplies a number of properties and methods that are available to all Windows PowerShell providers. The class is invoked by the `Get-PSProvider` cmdlet to list all available providers for a session. @@ -88,14 +88,14 @@ The implementation of this cmdlet is furnished by the session state. ### DriveCmdletProvider Base Class The -[System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) +[System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class defines a Windows PowerShell drive provider that supports operations for adding new drives, removing existing drives, and initializing default drives. For example, the FileSystem provider provided by Windows PowerShell initializes drives for all volumes that are mounted, such as hard drives and CD/DVD device drives. This class derives from the -[System.Management.Automation.Provider.Cmdletprovider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) +[System.Management.Automation.Provider.CmdletProvider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) base class. The following table lists the cmdlets exposed by this class. In addition to those listed, the `Get-PSDrive` cmdlet (exposed by session state) is a related cmdlet that is used to retrieve available drives. @@ -108,11 +108,11 @@ retrieve available drives. ### ItemCmdletProvider Base Class The -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class defines a Windows PowerShell item provider that performs operations on the individual items of the data store, and it does not assume any container or navigation capabilities. This class derives from the -[System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) +[System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) base class. The following table lists the cmdlets exposed by this class. | Cmdlet | Definition | @@ -122,25 +122,25 @@ base class. The following table lists the cmdlets exposed by this class. | `Invoke-Item` | Invokes the default action for the item at the specified path. | | `Set-Item` | Sets an item at the specified location with the indicated value. This cmdlet does not pass an output object through the pipeline unless its `PassThru` parameter is specified. | | `Resolve-Path` | Resolves the wildcards for a Windows PowerShell path, and streams path information. | -| `Test-Path` | Tests for the specified path, and returns `true` if it exists and `false` otherwise. This cmdlet is implemented to support the `IsContainer` parameter for the [System.Management.Automation.Provider.Cmdletprovider.Writeitemobject*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WriteItemObject) method. | +| `Test-Path` | Tests for the specified path, and returns `true` if it exists and `false` otherwise. This cmdlet is implemented to support the `IsContainer` parameter for the [System.Management.Automation.Provider.CmdletProvider.WriteItemObject*](/dotnet/api/System.Management.Automation.Provider.CmdletProvider.WriteItemObject) method. | ### ContainerCmdletProvider Base Class The -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class defines a Windows PowerShell container provider that exposes a container, for data store items, to the user. Be aware that a Windows PowerShell container provider can be used only when there is one container (no nested containers) with items in it. If there are nested containers, then you must implement a Windows PowerShell navigation provider . This class derives from the -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) base class. The following table defines the cmdlets implemented by this class. | Cmdlet | Definition | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | `Copy-Item` | Copies items from one location to another. This cmdlet does not pass an output object through the pipeline unless its `PassThru` parameter is specified. | -| `Get-Childitem` | Retrieves the child items at the specified location, and streams them as objects. | +| `Get-ChildItem` | Retrieves the child items at the specified location, and streams them as objects. | | `New-Item` | Creates new items at the specified location, and streams the resultant object. | | `Remove-Item` | Removes items from the specified location. | | `Rename-Item` | Renames an item at the specified location. This cmdlet does not pass an output object through the pipeline unless its `PassThru` parameter is specified. | @@ -148,10 +148,10 @@ base class. The following table defines the cmdlets implemented by this class. ### NavigationCmdletProvider Base Class The -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class defines a Windows PowerShell navigation provider that performs operations for items that use more than one container. This class derives from the -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) base class. The following table list the cmdlets exposed by this class. | Cmdlet | Definition | @@ -174,7 +174,7 @@ available online using the `Get-Command` and `Get-Help` cmdlets. ### IContentCmdletProvider The -[System.Management.Automation.Provider.Icontentcmdletprovider](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider) +[System.Management.Automation.Provider.IContentCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider) interface defines a content provider that performs operations on the content of a data item. The following table lists the cmdlets exposed by this interface. @@ -188,7 +188,7 @@ following table lists the cmdlets exposed by this interface. ### IPropertyCmdletProvider The -[System.Management.Automation.Provider.Ipropertycmdletprovider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider) +[System.Management.Automation.Provider.IPropertyCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider) interface defines a property Windows PowerShell provider that performs operations on the properties of items in the data store. The following table lists the cmdlets exposed by this interface. @@ -205,9 +205,9 @@ of items in the data store. The following table lists the cmdlets exposed by thi ### IDynamicPropertyCmdletProvider The -[System.Management.Automation.Provider.Idynamicpropertycmdletprovider](/dotnet/api/System.Management.Automation.Provider.IDynamicPropertyCmdletProvider) +[System.Management.Automation.Provider.IDynamicPropertyCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IDynamicPropertyCmdletProvider) interface, derived from -[System.Management.Automation.Provider.Ipropertycmdletprovider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider), +[System.Management.Automation.Provider.IPropertyCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider), defines a provider that specifies dynamic parameters for its supported cmdlets. This type of provider handles operations for which properties can be defined at run time, for example, a new property operation. Such operations are not possible on items having statically defined properties. @@ -224,7 +224,7 @@ The following table lists the cmdlets exposed by this interface. ### ISecurityDescriptorCmdletProvider The -[System.Management.Automation.Provider.Isecuritydescriptorcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ISecurityDescriptorCmdletProvider) +[System.Management.Automation.Provider.ISecurityDescriptorCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ISecurityDescriptorCmdletProvider) interface adds security descriptor functionality to a provider. This interface allows the user to get and set security descriptor information for an item in the data store. The following table lists the cmdlets exposed by this interface. @@ -232,7 +232,7 @@ the cmdlets exposed by this interface. | Cmdlet | Definition | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `Get-Acl` | Retrieves the information contained in an access control list (ACL), which is part of a security descriptor used to guard operating system resources, for example, a file or an object. | -| `Set-Acl` | Sets the information for an ACL. It is in the form of an instance of [System.Security.Accesscontrol.Objectsecurity](/dotnet/api/System.Security.AccessControl.ObjectSecurity) on the item(s) designated for the specified path. This cmdlet can set information about files, keys, and subkeys in the registry, or any other provider item, if the Windows PowerShell provider supports the setting of security information. | +| `Set-Acl` | Sets the information for an ACL. It is in the form of an instance of [System.Security.AccessControl.ObjectSecurity](/dotnet/api/System.Security.AccessControl.ObjectSecurity) on the item(s) designated for the specified path. This cmdlet can set information about files, keys, and subkeys in the registry, or any other provider item, if the Windows PowerShell provider supports the setting of security information. | ## See Also diff --git a/reference/docs-conceptual/developer/prog-guide/getproc05-vb-net-sample-code.md b/reference/docs-conceptual/developer/prog-guide/getproc05-vb-net-sample-code.md index e5b807dc8706..7447cee50cbd 100644 --- a/reference/docs-conceptual/developer/prog-guide/getproc05-vb-net-sample-code.md +++ b/reference/docs-conceptual/developer/prog-guide/getproc05-vb-net-sample-code.md @@ -21,11 +21,11 @@ Imports System.ComponentModel Namespace Microsoft.Samples.PowerShell.Commands - ' This sample is a complete implementation of the get-proc Cmdlet. + ' This sample is a complete implementation of the Get-Proc Cmdlet. #Region "GetProcCommand" ''' - ''' This class implements the get-proc cmdlet + ''' This class implements the Get-Proc cmdlet ''' _ @@ -411,7 +411,7 @@ ContinueForEach1: Public Overrides ReadOnly Property Description() As String Get Return "This is a PowerShell snap-in that includes " & _ - "the get-proc sample." + "the Get-Proc sample." End Get End Property End Class 'GetProcPSSnapIn05 diff --git a/reference/docs-conceptual/developer/prog-guide/how-to-create-a-windows-powershell-provider.md b/reference/docs-conceptual/developer/prog-guide/how-to-create-a-windows-powershell-provider.md index 4f749b084575..cca76b44e79d 100644 --- a/reference/docs-conceptual/developer/prog-guide/how-to-create-a-windows-powershell-provider.md +++ b/reference/docs-conceptual/developer/prog-guide/how-to-create-a-windows-powershell-provider.md @@ -23,7 +23,7 @@ Windows PowerShell provides several providers (such as the FileSystem provider, and Alias provider) that are used to access known data stores. For more information about the providers supplied by Windows PowerShell, use the following command to access online Help: -**PS>get-help about_providers** +**PS>Get-Help about_Providers** ## Accessing the Stored Data Using Windows PowerShell Paths diff --git a/reference/docs-conceptual/developer/prog-guide/runspace01-vb-net-code-sample.md b/reference/docs-conceptual/developer/prog-guide/runspace01-vb-net-code-sample.md index 4cbcfbdf5502..0133a40d32a0 100644 --- a/reference/docs-conceptual/developer/prog-guide/runspace01-vb-net-code-sample.md +++ b/reference/docs-conceptual/developer/prog-guide/runspace01-vb-net-code-sample.md @@ -23,7 +23,7 @@ Namespace Microsoft.Samples.PowerShell.Runspaces Module Runspace01 ' ' This sample uses the RunspaceInvoke class to execute - ' the get-process cmdlet synchronously. The name and + ' the Get-Process cmdlet synchronously. The name and ' handlecount are then extracted from the PSObjects ' returned and displayed. ' @@ -46,7 +46,7 @@ Namespace Microsoft.Samples.PowerShell.Runspaces ' Now invoke the runspace and display the objects that are ' returned... - For Each result As PSObject In invoker.Invoke("get-process") + For Each result As PSObject In invoker.Invoke("Get-Process") Console.WriteLine("{0,-20} {1}", _ result.Members("ProcessName").Value, _ result.Members("HandleCount").Value) diff --git a/reference/docs-conceptual/developer/prog-guide/runspace02-code-samples.md b/reference/docs-conceptual/developer/prog-guide/runspace02-code-samples.md index 0ad4d8c316c2..c1249496aa49 100644 --- a/reference/docs-conceptual/developer/prog-guide/runspace02-code-samples.md +++ b/reference/docs-conceptual/developer/prog-guide/runspace02-code-samples.md @@ -6,7 +6,7 @@ title: Runspace02 Code Samples --- # Runspace02 Code Samples -Here is the source code for the Runspace02 sample. This sample uses the [System.Management.Automation.Runspaceinvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute the `Get-Process` cmdlet synchronously. Windows Forms and data binding are then used to display the results in a DataGridView control. +Here is the source code for the Runspace02 sample. This sample uses the [System.Management.Automation.RunspaceInvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute the `Get-Process` cmdlet synchronously. Windows Forms and data binding are then used to display the results in a DataGridView control. For complete sample code, see the following topics. diff --git a/reference/docs-conceptual/developer/prog-guide/runspace02-csharp-code-sample.md b/reference/docs-conceptual/developer/prog-guide/runspace02-csharp-code-sample.md index 8c2f93c33425..31fe7de8c8db 100644 --- a/reference/docs-conceptual/developer/prog-guide/runspace02-csharp-code-sample.md +++ b/reference/docs-conceptual/developer/prog-guide/runspace02-csharp-code-sample.md @@ -7,7 +7,7 @@ title: Runspace02 (C#) Code Sample # Runspace02 (C#) Code Sample Here is the C# source code for the Runspace02 sample. This sample uses the -[System.Management.Automation.Runspaceinvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) +[System.Management.Automation.RunspaceInvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute the `Get-Process` cmdlet synchronously. Windows Forms and data binding are then used to display the results in a DataGridView control diff --git a/reference/docs-conceptual/developer/prog-guide/runspace02-vb-net-code-sample.md b/reference/docs-conceptual/developer/prog-guide/runspace02-vb-net-code-sample.md index ec93c0fb713e..c2e5a5e223a8 100644 --- a/reference/docs-conceptual/developer/prog-guide/runspace02-vb-net-code-sample.md +++ b/reference/docs-conceptual/developer/prog-guide/runspace02-vb-net-code-sample.md @@ -6,7 +6,7 @@ title: Runspace02 (VB.NET) Code Sample --- # Runspace02 (VB.NET) Code Sample -Here is the VB.NET source code for the Runspace02 sample. This sample uses the [System.Management.Automation.Runspaceinvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute the `Get-Process` cmdlet synchronously. Windows Forms and data binding are then used to display the results in a DataGridView control. +Here is the VB.NET source code for the Runspace02 sample. This sample uses the [System.Management.Automation.RunspaceInvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute the `Get-Process` cmdlet synchronously. Windows Forms and data binding are then used to display the results in a DataGridView control. ## Code Sample @@ -34,7 +34,7 @@ Namespace Microsoft.Samples.PowerShell.Runspaces Dim invoker As New RunspaceInvoke() Dim results As Collection(Of PSObject) = _ - invoker.Invoke("get-process | sort-object ID") + invoker.Invoke("Get-Process | Sort-Object ID") ' The generic collection needs to be re-wrapped in an ArrayList ' for data-binding to work... @@ -52,7 +52,7 @@ Namespace Microsoft.Samples.PowerShell.Runspaces ''' ''' This sample uses the RunspaceInvoke class to execute - ''' the get-process cmdlet synchronously. Windows Forms and data + ''' the Get-Process cmdlet synchronously. Windows Forms and data ''' binding are then used to display the results in a ''' DataGridView control. ''' diff --git a/reference/docs-conceptual/developer/prog-guide/runspace03-csharp-code-sample.md b/reference/docs-conceptual/developer/prog-guide/runspace03-csharp-code-sample.md index 3069d77a3a89..21d566a7f534 100644 --- a/reference/docs-conceptual/developer/prog-guide/runspace03-csharp-code-sample.md +++ b/reference/docs-conceptual/developer/prog-guide/runspace03-csharp-code-sample.md @@ -8,7 +8,7 @@ title: RunSpace03 (C#) Code Sample Here is the C# source code for the console application described in "Creating a Console Application That Runs a Specified Script". This sample uses the -[System.Management.Automation.Runspaceinvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) +[System.Management.Automation.RunspaceInvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute a script that retrieves process information by using the list of process names passed into the script. It shows how to pass input objects to a script and how to retrieve error objects as well as the output objects. diff --git a/reference/docs-conceptual/developer/prog-guide/runspace03-vb-net-code-sample.md b/reference/docs-conceptual/developer/prog-guide/runspace03-vb-net-code-sample.md index 25d2a44ebfa6..3cf6041ddd88 100644 --- a/reference/docs-conceptual/developer/prog-guide/runspace03-vb-net-code-sample.md +++ b/reference/docs-conceptual/developer/prog-guide/runspace03-vb-net-code-sample.md @@ -8,7 +8,7 @@ title: RunSpace03 (VB.NET) Code Sample Here is the VB.NET source code for the console application described in "Creating a Console Application That Runs a Specified Script". This sample uses -the [System.Management.Automation.Runspaceinvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) +the [System.Management.Automation.RunspaceInvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute a script that retrieves process information for the list of process names passed into the script. It shows how to pass input objects to a script and how to retrieve error objects as well as the output objects. @@ -63,7 +63,7 @@ Namespace Microsoft.Samples.PowerShell.Runspaces ' The script to run to get these processes. Input passed ' to the script will be available in the $input variable. - Dim script As String = "$input | get-process -name {$_}" + Dim script As String = "$input | Get-Process -Name {$_}" ' Create an instance of the RunspaceInvoke class. Dim invoker As New RunspaceInvoke() diff --git a/reference/docs-conceptual/developer/prog-guide/runspace04-code-samples.md b/reference/docs-conceptual/developer/prog-guide/runspace04-code-samples.md index f0be6d110dc5..e3dfe45fa300 100644 --- a/reference/docs-conceptual/developer/prog-guide/runspace04-code-samples.md +++ b/reference/docs-conceptual/developer/prog-guide/runspace04-code-samples.md @@ -6,7 +6,7 @@ title: RunSpace04 Code Samples --- # RunSpace04 Code Samples -Here is a code sample for a runspace that uses the [System.Management.Automation.Runspaceinvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) +Here is a code sample for a runspace that uses the [System.Management.Automation.RunspaceInvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute a script that generates a terminating error. The host application is responsible for catching the error and interpreting the error record. diff --git a/reference/docs-conceptual/developer/prog-guide/runspace04-vb-net-code-sample.md b/reference/docs-conceptual/developer/prog-guide/runspace04-vb-net-code-sample.md index aa3a630ec2a7..6ba88eac1c95 100644 --- a/reference/docs-conceptual/developer/prog-guide/runspace04-vb-net-code-sample.md +++ b/reference/docs-conceptual/developer/prog-guide/runspace04-vb-net-code-sample.md @@ -6,7 +6,7 @@ title: RunSpace04 (VB.NET) Code Sample --- # RunSpace04 (VB.NET) Code Sample -Here is the VB.NET source code for the Runspace04 sample. This sample uses the [System.Management.Automation.Runspaceinvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute a script that generates a terminating error. The host application is responsible for catching the error and interpreting the error record. +Here is the VB.NET source code for the Runspace04 sample. This sample uses the [System.Management.Automation.RunspaceInvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute a script that generates a terminating error. The host application is responsible for catching the error and interpreting the error record. > [!NOTE] > You can download the VB.NET source file (runspace02.vb) for this sample by using the Windows Software Development Kit for Windows Vista and Microsoft .NET Framework 3.0 Runtime Components. For download instructions, see [How to Install Windows PowerShell and Download the Windows PowerShell SDK](/powershell/scripting/developer/installing-the-windows-powershell-sdk). @@ -52,13 +52,13 @@ Namespace Microsoft.Samples.PowerShell.Runspaces ' Define a list of patterns to use in matching ' Note that the fourth pattern is not a valid regular ' expression so it will cause a terminating exception to - ' be thrown when used in select-string. + ' be thrown when used in Select-String. Dim patterns() As String = {"aa", "bc", "ab*c", "*", "abc"} ' The script to run to use the patterns. Input passed ' to the script will be available in the $input variable. Dim script As String = "$input | where {" & _ - " select-string $_ -inputobject 'abc' }" + " Select-String $_ -InputObject 'abc' }" ' Create an instance of the RunspaceInvoke class. Dim invoker As New RunspaceInvoke()