diff --git a/reference/docs-conceptual/developer/prog-guide/runspace10-code-sample.md b/reference/docs-conceptual/developer/prog-guide/runspace10-code-sample.md index 022cad514695..cc61dcb77b00 100644 --- a/reference/docs-conceptual/developer/prog-guide/runspace10-code-sample.md +++ b/reference/docs-conceptual/developer/prog-guide/runspace10-code-sample.md @@ -7,7 +7,7 @@ title: RunSpace10 Code Sample # RunSpace10 Code Sample Here is the source code for the Runspace10 sample. This sample application adds a cmdlet to -[System.Management.Automation.Runspaces.Runspaceconfiguration](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConfiguration) +[System.Management.Automation.Runspaces.RunspaceConfiguration](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConfiguration) and then uses the modified configuration information to create the runspace. > [!NOTE] diff --git a/reference/docs-conceptual/developer/prog-guide/stopprocesssample04-vb-net-sample-code.md b/reference/docs-conceptual/developer/prog-guide/stopprocesssample04-vb-net-sample-code.md index 5b7e8f84e6dd..d5eaadae1990 100644 --- a/reference/docs-conceptual/developer/prog-guide/stopprocesssample04-vb-net-sample-code.md +++ b/reference/docs-conceptual/developer/prog-guide/stopprocesssample04-vb-net-sample-code.md @@ -29,7 +29,7 @@ Namespace Microsoft.Samples.PowerShell.Commands #Region "StopProcCommand" ''' - ''' Class that implements the stop-proc cmdlet. + ''' Class that implements the Stop-Proc cmdlet. ''' _ @@ -454,7 +454,7 @@ ContinueForEach1: Public Overrides ReadOnly Property Description() As String Get Return "This is a PowerShell snap-in that includes " & _ - "the stop-proc cmdlet." + "the Stop-Proc cmdlet." End Get End Property End Class 'StopProcPSSnapIn04 diff --git a/reference/docs-conceptual/developer/prog-guide/windows-powershell-programmer-s-guide.md b/reference/docs-conceptual/developer/prog-guide/windows-powershell-programmer-s-guide.md index 50ad4d82a47e..e960f160e01f 100644 --- a/reference/docs-conceptual/developer/prog-guide/windows-powershell-programmer-s-guide.md +++ b/reference/docs-conceptual/developer/prog-guide/windows-powershell-programmer-s-guide.md @@ -39,7 +39,7 @@ PowerShell runtime processes all command types just as it does cmdlets, using pi In addition to commands, Windows PowerShell supports various customizable Windows PowerShell providers that make available specific sets of cmdlets. The shell operates within the Windows -PowerShell-provided host application (Windows PowerShell.exe), but it is equally accessible from a +PowerShell-provided host application (`powershell.exe`), but it is equally accessible from a custom host application that you can develop to meet specific requirements. For more information, see [How Windows PowerShell Works](/previous-versions//ms714658(v=vs.85)). diff --git a/reference/docs-conceptual/developer/prog-guide/windows-powershell-sample-code.md b/reference/docs-conceptual/developer/prog-guide/windows-powershell-sample-code.md index ce5b5b148728..a16bc89419d7 100644 --- a/reference/docs-conceptual/developer/prog-guide/windows-powershell-sample-code.md +++ b/reference/docs-conceptual/developer/prog-guide/windows-powershell-sample-code.md @@ -34,15 +34,15 @@ code that is contained in the Windows SDK samples. | [StopProc01 Code Samples](./stopproc01-code-samples.md) | This is the `Stop-Process` cmdlet sample described in [Creating a Cmdlet That Modifies the System](../cmdlet/creating-a-cmdlet-that-modifies-the-system.md). | | [StopProcessSample04 Code Samples](./stopprocesssample04-code-samples.md) | This is the `Stop-Process` cmdlet sample described in [Adding Parameter Sets to a Cmdlet](../cmdlet/adding-parameter-sets-to-a-cmdlet.md). | | [Runspace01 Code Samples](./runspace01-code-samples.md) | These are the code samples for the runspace described in [Creating a Console Application That Runs a Specified Command](/dotnet/csharp/programming-guide/inside-a-program/hello-world-your-first-program). | -| [Runspace02 Code Samples](./runspace02-code-samples.md) | This sample uses the [System.Management.Automation.Runspaceinvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute the `Get-Process` cmdlet synchronously. | +| [Runspace02 Code Samples](./runspace02-code-samples.md) | This sample uses the [System.Management.Automation.RunspaceInvoke](/dotnet/api/System.Management.Automation.RunspaceInvoke) class to execute the `Get-Process` cmdlet synchronously. | | [RunSpace03 Code Samples](./runspace03-code-samples.md) | These are the code samples for the runspace described in "Creating a Console Application That Runs a Specified Script". | -| [RunSpace04 Code Samples](./runspace04-code-samples.md) | This 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. | +| [RunSpace04 Code Samples](./runspace04-code-samples.md) | This 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. | | [RunSpace05 Code Sample](./runspace05-code-sample.md) | | | [RunSpace06 Code Sample](./runspace06-code-sample.md) | | | [RunSpace07 Code Sample](./runspace07-code-sample.md) | | | [RunSpace08 Code Sample](./runspace08-code-sample.md) | | | [RunSpace09 Code Sample](./runspace09-code-sample.md) | | -| [RunSpace10 Code Sample](./runspace10-code-sample.md) | This is the source code for the Runspace10 sample, which adds a cmdlet to [System.Management.Automation.Runspaces.Runspaceconfiguration](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConfiguration) and then uses the modified configuration information to create the runspace. | +| [RunSpace10 Code Sample](./runspace10-code-sample.md) | This is the source code for the Runspace10 sample, which adds a cmdlet to [System.Management.Automation.Runspaces.RunspaceConfiguration](/dotnet/api/System.Management.Automation.Runspaces.RunspaceConfiguration) and then uses the modified configuration information to create the runspace. | ## See Also diff --git a/reference/docs-conceptual/developer/provider/accessdbprovidersample01.md b/reference/docs-conceptual/developer/provider/accessdbprovidersample01.md index 6876b7a5fbd1..8d0994410e57 100644 --- a/reference/docs-conceptual/developer/provider/accessdbprovidersample01.md +++ b/reference/docs-conceptual/developer/provider/accessdbprovidersample01.md @@ -7,7 +7,7 @@ title: AccessDBProviderSample01 # AccessDBProviderSample01 This sample shows how to declare a provider class that derives directly 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) class. It is included here only for completeness. ## Demonstrates @@ -16,9 +16,9 @@ class. It is included here only for completeness. > Your provider class will most likely derive from one of the following classes and possibly > implement other provider interfaces: > -> - [System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. See [AccessDBProviderSample03](./accessdbprovidersample03.md). -> - [System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). -> - [System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. See [AccessDBProviderSample05](./accessdbprovidersample05.md). +> - [System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. See [AccessDBProviderSample03](./accessdbprovidersample03.md). +> - [System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). +> - [System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. See [AccessDBProviderSample05](./accessdbprovidersample05.md). > > For more information about choosing which provider class to derive from based on provider > features, see [Designing Your Windows PowerShell Provider](./provider-types.md). @@ -28,7 +28,7 @@ This sample demonstrates the following: - Declaring the `CmdletProvider` attribute. - Defining a provider class that derives directly 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) class. ## Example @@ -39,10 +39,10 @@ This sample shows how to define a provider class and how to declare the `CmdletP ## See Also -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) [Designing Your Windows PowerShell Provider](./provider-types.md) diff --git a/reference/docs-conceptual/developer/provider/accessdbprovidersample02.md b/reference/docs-conceptual/developer/provider/accessdbprovidersample02.md index b0a2ad532019..f66d2940054e 100644 --- a/reference/docs-conceptual/developer/provider/accessdbprovidersample02.md +++ b/reference/docs-conceptual/developer/provider/accessdbprovidersample02.md @@ -7,12 +7,12 @@ title: AccessDBProviderSample02 # AccessDBProviderSample02 This sample shows how to overwrite 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) and -[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) methods to support calls to the `New-PSDrive` and `Remove-PSDrive` cmdlets. The provider class in this sample 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) class. ## Demonstrates @@ -21,9 +21,9 @@ class. > Your provider class will most likely derive from one of the following classes and possibly > implement other provider interfaces: > -> - [System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. See [AccessDBProviderSample03](./accessdbprovidersample03.md). -> - [System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). -> - [System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. See [AccessDBProviderSample05](./accessdbprovidersample05.md). +> - [System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. See [AccessDBProviderSample03](./accessdbprovidersample03.md). +> - [System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). +> - [System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. See [AccessDBProviderSample05](./accessdbprovidersample05.md). > > For more information about choosing which provider class to derive from based on provider > features, see [Designing Your Windows PowerShell Provider](./provider-types.md). @@ -33,24 +33,24 @@ This sample demonstrates the following: - Declaring the `CmdletProvider` attribute. - Defining a provider class that drives 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) class. - Overwriting 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 to support creating new drives. (This sample does not show how to add dynamic parameters to the `New-PSDrive` cmdlet.) - Overwriting 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 to support removing existing drives. ## Example This sample shows how to overwrite 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) and -[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) methods. For this sample provider, when a drive is created its connection information is stored in an `AccessDBPsDriveInfo` object. @@ -58,10 +58,10 @@ an `AccessDBPsDriveInfo` object. ## See Also -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) [Designing Your Windows PowerShell Provider](./provider-types.md) diff --git a/reference/docs-conceptual/developer/provider/accessdbprovidersample03.md b/reference/docs-conceptual/developer/provider/accessdbprovidersample03.md index f6a84f577348..64e1fdad0043 100644 --- a/reference/docs-conceptual/developer/provider/accessdbprovidersample03.md +++ b/reference/docs-conceptual/developer/provider/accessdbprovidersample03.md @@ -7,12 +7,12 @@ title: AccessDBProviderSample03 # AccessDBProviderSample03 This sample shows how to overwrite 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) and -[System.Management.Automation.Provider.Itemcmdletprovider.Setitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) +[System.Management.Automation.Provider.ItemCmdletProvider.SetItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) methods to support calls to the `Get-Item` and `Set-Item` cmdlets. The provider class in this sample 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) class. ## Demonstrates @@ -21,9 +21,9 @@ class. > Your provider class will most likely derive from one of the following classes and possibly > implement other provider interfaces: > -> - [System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. -> - [System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). -> - [System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. See [AccessDBProviderSample05](./accessdbprovidersample05.md). +> - [System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. +> - [System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). +> - [System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. See [AccessDBProviderSample05](./accessdbprovidersample05.md). > > For more information about choosing which provider class to derive from based on provider > features, see [Designing Your Windows PowerShell Provider](./provider-types.md). @@ -32,31 +32,31 @@ This sample demonstrates the following: - Declaring the `CmdletProvider` attribute. - Defining a provider class that 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) class. - Overwriting 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 to change the behavior of the `New-PSDrive` cmdlet, allowing the user to create new drives. (This sample does not show how to add dynamic parameters to the `New-PSDrive` cmdlet.) - Overwriting 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 to support removing existing drives. - Overwriting 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 to change the behavior of the `Get-Item` cmdlet, allowing the user to retrieve items from the data store. (This sample does not show how to add dynamic parameters to the `Get-Item` cmdlet.) - Overwriting the - [System.Management.Automation.Provider.Itemcmdletprovider.Setitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) + [System.Management.Automation.Provider.ItemCmdletProvider.SetItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) method to change the behavior of the `Set-Item` cmdlet, allowing the user to update the items in the data store. (This sample does not show how to add dynamic parameters to the `Get-Item` cmdlet.) - Overwriting the - [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) method to change the behavior of the `Test-Path` cmdlet. (This sample does not show how to add dynamic parameters to the `Test-Path` cmdlet.) - Overwriting the - [System.Management.Automation.Provider.Itemcmdletprovider.Isvalidpath*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath) + [System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath) method to determine if the provided path is valid. ## Example @@ -68,10 +68,10 @@ data base. ## See Also -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) [Designing Your Windows PowerShell Provider](./provider-types.md) diff --git a/reference/docs-conceptual/developer/provider/accessdbprovidersample04.md b/reference/docs-conceptual/developer/provider/accessdbprovidersample04.md index a9e599ab776c..ec6e548b24d0 100644 --- a/reference/docs-conceptual/developer/provider/accessdbprovidersample04.md +++ b/reference/docs-conceptual/developer/provider/accessdbprovidersample04.md @@ -10,20 +10,20 @@ This sample shows how to overwrite container methods to support calls to the `Co `Get-ChildItem`, `New-Item`, and `Remove-Item` cmdlets. These methods should be implemented when the data store contains items that are containers. A container is a group of child items under a common parent item. The provider class in this sample 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) class. ## Demonstrates > [!IMPORTANT] > Your provider class will most likely derive 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) This sample demonstrates the following: - Declaring the `CmdletProvider` attribute. - Defining a provider 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) class. - Overwriting the [System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem) @@ -31,20 +31,20 @@ This sample demonstrates the following: one location to another. (This sample does not show how to add dynamic parameters to the `Copy-Item` cmdlet.) - Overwriting 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 change the behavior of the Get-ChildItems cmdlet, which allows the user to retrieve the child items of the parent item. (This sample does not show how to add dynamic parameters to the Get-ChildItems cmdlet.) - Overwriting 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 change the behavior of the Get-ChildItems cmdlet when the `Name` parameter of the cmdlet is specified. - Overwriting 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 change the behavior of the `New-Item` cmdlet, which allows the user to add items to the data store. (This sample does not show how to add dynamic parameters to the `New-Item` cmdlet.) - Overwriting 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 change the behavior of the `Remove-Item` cmdlet. (This sample does not show how to add dynamic parameters to the `Remove-Item` cmdlet.) @@ -57,10 +57,10 @@ methods for getting the child items of a parent item. ## See Also -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) [Designing Your Windows PowerShell Provider](./provider-types.md) diff --git a/reference/docs-conceptual/developer/provider/accessdbprovidersample05.md b/reference/docs-conceptual/developer/provider/accessdbprovidersample05.md index 0a478460f4a1..a632b92e7764 100644 --- a/reference/docs-conceptual/developer/provider/accessdbprovidersample05.md +++ b/reference/docs-conceptual/developer/provider/accessdbprovidersample05.md @@ -10,7 +10,7 @@ This sample shows how to overwrite container methods to support calls to the `Mo `Join-Path` cmdlets. These methods should be implemented when the user needs to move items within a container and if the data store contains nested containers. The provider class in this sample 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) class. ## Demonstrates @@ -19,9 +19,9 @@ class. > Your provider class will most likely derive from one of the following classes and possibly > implement other provider interfaces: > -> - [System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. See [AccessDBProviderSample03](./accessdbprovidersample03.md). -> - [System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). -> - [System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. +> - [System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. See [AccessDBProviderSample03](./accessdbprovidersample03.md). +> - [System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). +> - [System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. > > For more information about choosing which provider class to derive from based on provider > features, see [Designing Your Windows PowerShell Provider](./provider-types.md). @@ -31,33 +31,33 @@ This sample demonstrates the following: - Declaring the `CmdletProvider` attribute. - Defining a provider 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) class. - Overwriting 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 to change the behavior of the `Move-Item` cmdlet, allowing the user to move items from one location to another. (This sample does not show how to add dynamic parameters to the `Move-Item` cmdlet.) - Overwriting 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 change the behavior of the `Join-Path` cmdlet. - Overwriting 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. - Overwriting 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. - Overwriting 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. - Overwriting 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. ## Example @@ -68,10 +68,10 @@ This sample shows how to overwrite the methods needed to move items in a Microso ## See Also -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) [Designing Your Windows PowerShell Provider](./provider-types.md) diff --git a/reference/docs-conceptual/developer/provider/accessdbprovidersample06.md b/reference/docs-conceptual/developer/provider/accessdbprovidersample06.md index 68ca30343aea..445c28d81b82 100644 --- a/reference/docs-conceptual/developer/provider/accessdbprovidersample06.md +++ b/reference/docs-conceptual/developer/provider/accessdbprovidersample06.md @@ -10,9 +10,9 @@ This sample shows how to overwrite content methods to support calls to the `Clea `Get-Content`, and `Set-Content` cmdlets. These methods should be implemented when the user needs to manage the content of the items in the data store. The provider class in this sample 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) class, and it implements 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. ## Demonstrates @@ -21,9 +21,9 @@ interface. > Your provider class will most likely derive from one of the following classes and possibly > implement other provider interfaces: > -> - [System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. See [AccessDBProviderSample03](./accessdbprovidersample03.md). -> - [System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). -> - [System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. +> - [System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. See [AccessDBProviderSample03](./accessdbprovidersample03.md). +> - [System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. See [AccessDBProviderSample04](./accessdbprovidersample04.md). +> - [System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. > > For more information about choosing which provider class to derive from based on provider > features, see [Designing Your Windows PowerShell Provider](./provider-types.md). @@ -32,22 +32,22 @@ This sample demonstrates the following: - Declaring the `CmdletProvider` attribute. - Defining a provider 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) class and that declares 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. - Overwriting 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 to change the behavior of the `Clear-Content` cmdlet, allowing the user to remove the content from an item. (This sample does not show how to add dynamic parameters to the `Clear-Content` cmdlet.) - Overwriting 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 to change the behavior of the `Get-Content` cmdlet, allowing the user to retrieve the content of an item. (This sample does not show how to add dynamic parameters to the `Get-Content` cmdlet.). - Overwriting the - [Microsoft.PowerShell.Commands.Filesystemprovider.Getcontentwriter*](/dotnet/api/Microsoft.PowerShell.Commands.FileSystemProvider.GetContentWriter) + [Microsoft.PowerShell.Commands.FileSystemProvider.GetContentWriter*](/dotnet/api/Microsoft.PowerShell.Commands.FileSystemProvider.GetContentWriter) method to change the behavior of the `Set-Content` cmdlet, allowing the user to update the content of an item. (This sample does not show how to add dynamic parameters to the `Set-Content` cmdlet.) @@ -60,10 +60,10 @@ a Microsoft Access data base. ## See Also -[System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) +[System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) -[System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) +[System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) -[System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) +[System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) [Designing Your Windows PowerShell Provider](./provider-types.md) diff --git a/reference/docs-conceptual/developer/provider/provider-cmdlet-dynamic-parameters.md b/reference/docs-conceptual/developer/provider/provider-cmdlet-dynamic-parameters.md index 7b7427f95535..bf4ae4a99238 100644 --- a/reference/docs-conceptual/developer/provider/provider-cmdlet-dynamic-parameters.md +++ b/reference/docs-conceptual/developer/provider/provider-cmdlet-dynamic-parameters.md @@ -120,7 +120,7 @@ Here is a list of the static parameters that can be used to add dynamic paramete [System.Management.Automation.Provider.DriveCmdletProvider.NewDriveDynamicParameters*][08] method. - `Remove-Item` cmdlet - You can define dynamic parameters that are triggered by the `Path` and `Recurse` parameters of the `Remove-Item` cmdlet by implementing the - [System.Management.Automation.Provider.Containercmdletprovider.Removeitemdynamicparameters*][06] + [System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItemDynamicParameters*][06] method. - `Remove-ItemProperty` cmdlet - You can define dynamic parameters that are triggered by the `Path` and `Name` parameters of the `Remove-ItemProperty` cmdlet by implementing the @@ -128,7 +128,7 @@ Here is a list of the static parameters that can be used to add dynamic paramete method. - `Rename-Item` cmdlet - You can define dynamic parameters that are triggered by the `Path` and `NewName` parameters of the `Rename-Item` cmdlet by implementing the - [System.Management.Automation.Provider.Containercmdletprovider.Renameitemdynamicparameters*][07] + [System.Management.Automation.Provider.ContainerCmdletProvider.RenameItemDynamicParameters*][07] method. - `Rename-ItemProperty` - You can define dynamic parameters that are triggered by the `Path`, `Name`, and `NewName` parameters of the `Rename-ItemProperty` cmdlet by implementing the diff --git a/reference/docs-conceptual/developer/provider/provider-cmdlet-parameters.md b/reference/docs-conceptual/developer/provider/provider-cmdlet-parameters.md index d6dbb7a11cda..3f178a20e1c5 100644 --- a/reference/docs-conceptual/developer/provider/provider-cmdlet-parameters.md +++ b/reference/docs-conceptual/developer/provider/provider-cmdlet-parameters.md @@ -10,67 +10,67 @@ Provider cmdlets come with a set of static parameters that are available to all ## Provider Cmdlet Static Parameters -Static parameters are defined by Windows PowerShell. A large set of these parameters is implemented by Windows PowerShell to provide consistency across all the providers and to provide a simpler development experience. Examples of these parameters include the `literalPath`, `exclude`, and `include` parameters of the `Get-Item` cmdlet. A smaller set of these parameters can be overwritten to provide actions that are specific to your provider. Examples of these parameters include the `Path` and `Value` parameter of the `Set-Item` cmdlet. Here is a list of the parameters that can be overwritten for the provider cmdlets. +Static parameters are defined by Windows PowerShell. A large set of these parameters is implemented by Windows PowerShell to provide consistency across all the providers and to provide a simpler development experience. Examples of these parameters include the `LiteralPath`, `Exclude`, and `Include` parameters of the `Get-Item` cmdlet. A smaller set of these parameters can be overwritten to provide actions that are specific to your provider. Examples of these parameters include the `Path` and `Value` parameter of the `Set-Item` cmdlet. Here is a list of the parameters that can be overwritten for the provider cmdlets. `Clear-Content` cmdlet -You can define how your provider will use the values passed to the `Path` parameter of the `Clear-Content` cmdlet by implementing the [System.Management.Automation.Provider.Icontentcmdletprovider.Clearcontent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) method. +You can define how your provider will use the values passed to the `Path` parameter of the `Clear-Content` cmdlet by implementing the [System.Management.Automation.Provider.IContentCmdletProvider.ClearContent*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.ClearContent) method. `Clear-Item` cmdlet -You can define how your provider will use the values passed to the `Path` parameter of the `Clear-Item` cmdlet by implementing the [System.Management.Automation.Provider.Itemcmdletprovider.Clearitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.ClearItem) method. +You can define how your provider will use the values passed to the `Path` parameter of the `Clear-Item` cmdlet by implementing the [System.Management.Automation.Provider.ItemCmdletProvider.ClearItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.ClearItem) method. `Clear-ItemProperty` cmdlet -You can define how your provider will use the values passed to the `Path` and `Name` parameters of the `Clear-ItemProperty` cmdlet by implementing the [System.Management.Automation.Provider.Ipropertycmdletprovider.Clearproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) method. +You can define how your provider will use the values passed to the `Path` and `Name` parameters of the `Clear-ItemProperty` cmdlet by implementing the [System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.ClearProperty) method. `Copy-Item` cmdlet You can define how your provider will use the values passed to the `Path`, `Destination`, and `Recurse` parameters of the `Copy-Item` cmdlet by implementing the [System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.CopyItem) method. Get-ChildItems cmdlet -You can define how your provider will use the values passed to the `Path` and `Recurse` parameters of the `Get-ChildItem` cmdlet by implementing the [System.Management.Automation.Provider.Containercmdletprovider.Getchilditems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) and [System.Management.Automation.Provider.Containercmdletprovider.Getchildnames*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames) methods. +You can define how your provider will use the values passed to the `Path` and `Recurse` parameters of the `Get-ChildItem` cmdlet by implementing the [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildItems) and [System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.GetChildNames) methods. `Get-Content` cmdlet -You can define how your provider will use the values passed to the `Path` parameter of the `Get-Content` cmdlet by implementing the [System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentreader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader) method. +You can define how your provider will use the values passed to the `Path` parameter of the `Get-Content` cmdlet by implementing the [System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader) method. `Get-Item` cmdlet -You can define how your provider will use the values passed to the `Path` parameter of the `Get-Item` cmdlet by implementing the [System.Management.Automation.Provider.Itemcmdletprovider.Getitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.GetItem) method. +You can define how your provider will use the values passed to the `Path` parameter of the `Get-Item` cmdlet by implementing the [System.Management.Automation.Provider.ItemCmdletProvider.GetItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.GetItem) method. `Get-ItemProperty` cmdlet -You can define how your provider will use the values passed to the `Path` and `Name` parameters of the `Get-ItemProperty` cmdlet by implementing the [System.Management.Automation.Provider.Ipropertycmdletprovider.Getproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) method. +You can define how your provider will use the values passed to the `Path` and `Name` parameters of the `Get-ItemProperty` cmdlet by implementing the [System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.GetProperty) method. `Invoke-Item` cmdlet -You can define how your provider will use the values passed to the `Path` parameter of the `Invoke-Item` cmdlet by implementing the [System.Management.Automation.Provider.Itemcmdletprovider.Invokedefaultaction*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.InvokeDefaultAction) method. +You can define how your provider will use the values passed to the `Path` parameter of the `Invoke-Item` cmdlet by implementing the [System.Management.Automation.Provider.ItemCmdletProvider.InvokeDefaultAction*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.InvokeDefaultAction) method. `Move-Item` cmdlet -You can define how your provider will use the values passed to the `Path` and `Destination` parameters of the `Move-Item` cmdlet by implementing the [System.Management.Automation.Provider.Navigationcmdletprovider.Moveitem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) method. +You can define how your provider will use the values passed to the `Path` and `Destination` parameters of the `Move-Item` cmdlet by implementing the [System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) method. `New-Item` cmdlet -You can define how your provider will use the values passed to the `Path`, `ItemType`, and `Value` parameters of the `New-Item` cmdlet by implementing the [System.Management.Automation.Provider.Containercmdletprovider.Newitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method. +You can define how your provider will use the values passed to the `Path`, `ItemType`, and `Value` parameters of the `New-Item` cmdlet by implementing the [System.Management.Automation.Provider.ContainerCmdletProvider.NewItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.NewItem) method. `New-ItemProperty` cmdlet -You can define how your provider will use the values passed to the `Path`, `Name`, `PropertyType`, and `Value` parameters of the `New-ItemProperty` cmdlet by implementing the [Microsoft.PowerShell.Commands.Registryprovider.Newproperty*](/dotnet/api/Microsoft.PowerShell.Commands.RegistryProvider.NewProperty) method. +You can define how your provider will use the values passed to the `Path`, `Name`, `PropertyType`, and `Value` parameters of the `New-ItemProperty` cmdlet by implementing the [Microsoft.PowerShell.Commands.RegistryProvider.NewProperty*](/dotnet/api/Microsoft.PowerShell.Commands.RegistryProvider.NewProperty) method. `Remove-Item` -You can define how your provider will use the values passed to the `Path` and `Recurse` parameters of the `Remove-Item` cmdlet by implementing the [System.Management.Automation.Provider.Containercmdletprovider.Removeitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) method. +You can define how your provider will use the values passed to the `Path` and `Recurse` parameters of the `Remove-Item` cmdlet by implementing the [System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RemoveItem) method. `Remove-ItemProperty` -You can define how your provider will use the values passed to the `Path` and `Name` parameters of the `Remove-ItemProperty` cmdlet by implementing the [System.Management.Automation.Provider.Idynamicpropertycmdletprovider.Removeproperty*](/dotnet/api/System.Management.Automation.Provider.IDynamicPropertyCmdletProvider.RemoveProperty) method. +You can define how your provider will use the values passed to the `Path` and `Name` parameters of the `Remove-ItemProperty` cmdlet by implementing the [System.Management.Automation.Provider.IDynamicPropertyCmdletProvider.RemoveProperty*](/dotnet/api/System.Management.Automation.Provider.IDynamicPropertyCmdletProvider.RemoveProperty) method. `Rename-Item` cmdlet -You can define how your provider will use the values passed to the `Path` and `NewName` parameters of the `Rename-Item` cmdlet by implementing the [System.Management.Automation.Provider.Containercmdletprovider.Renameitem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) method. +You can define how your provider will use the values passed to the `Path` and `NewName` parameters of the `Rename-Item` cmdlet by implementing the [System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem*](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider.RenameItem) method. `Rename-ItemProperty` -You can define how your provider will use the values passed to the `Path`, `NewName`, and `Name` parameters of the `Rename-ItemProperty` cmdlet by implementing the [System.Management.Automation.Provider.Idynamicpropertycmdletprovider.Renameproperty*](/dotnet/api/System.Management.Automation.Provider.IDynamicPropertyCmdletProvider.RenameProperty) method. +You can define how your provider will use the values passed to the `Path`, `NewName`, and `Name` parameters of the `Rename-ItemProperty` cmdlet by implementing the [System.Management.Automation.Provider.IDynamicPropertyCmdletProvider.RenameProperty*](/dotnet/api/System.Management.Automation.Provider.IDynamicPropertyCmdletProvider.RenameProperty) method. `Set-Content` cmdlet -You can define how your provider will use the values passed to the `Path` parameter of the `Set-Content` cmdlet by implementing the [System.Management.Automation.Provider.Icontentcmdletprovider.Getcontentwriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter) method. +You can define how your provider will use the values passed to the `Path` parameter of the `Set-Content` cmdlet by implementing the [System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter*](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter) method. `Set-Item` cmdlet -You can define how your provider will use the values passed to the `Path` and `Value` parameters of the `Set-Item` cmdlet by implementing the [System.Management.Automation.Provider.Itemcmdletprovider.Setitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) method. +You can define how your provider will use the values passed to the `Path` and `Value` parameters of the `Set-Item` cmdlet by implementing the [System.Management.Automation.Provider.ItemCmdletProvider.SetItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) method. `Set-ItemProperty` cmdlet -You can define how your provider will use the values passed to the `Path` and `Value` parameters of the `Set-Item` cmdlet by implementing the [System.Management.Automation.Provider.Ipropertycmdletprovider.Setproperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) method. +You can define how your provider will use the values passed to the `Path` and `Value` parameters of the `Set-Item` cmdlet by implementing the [System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty*](/dotnet/api/System.Management.Automation.Provider.IPropertyCmdletProvider.SetProperty) method. `Test-Path` cmdlet -You can define how your provider will use the values passed to the `Path` parameter of the `Test-Path` cmdlet by implementing the [System.Management.Automation.Provider.Itemcmdletprovider.Invokedefaultaction*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.InvokeDefaultAction) method. +You can define how your provider will use the values passed to the `Path` parameter of the `Test-Path` cmdlet by implementing the [System.Management.Automation.Provider.ItemCmdletProvider.InvokeDefaultAction*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.InvokeDefaultAction) method. In addition, you cannot specify the characteristics of these parameters, such as whether they are optional or required, nor can you give these parameters an alias or specify any of the validation attributes. In contrast, you can specify parameter characteristics in stand-alone cmdlets by using attributes such as the `Parameters` attribute. diff --git a/reference/docs-conceptual/developer/provider/provider-cmdlets.md b/reference/docs-conceptual/developer/provider/provider-cmdlets.md index 012f85b3b123..ba21824a0989 100644 --- a/reference/docs-conceptual/developer/provider/provider-cmdlets.md +++ b/reference/docs-conceptual/developer/provider/provider-cmdlets.md @@ -25,13 +25,13 @@ This cmdlet allows the user to create PowerShell drives to access the data store cmdlet, overwrite the following methods of [System.Management.Automation.Provider.DriveCmdletProvider][12] class: -- [Newdrive][13] +- [NewDrive][13] - [NewDriveDynamicParameters][14] ### `Remove-PSDrive` This cmdlet allows the user to remove PowerShell drives that access the data store. To support this -cmdlet, overwrite the [System.Management.Automation.Provider.DriveCmdletProvider.Removedrive][15] +cmdlet, overwrite the [System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive][15] method. ## Item cmdlets @@ -42,7 +42,7 @@ This cmdlet allows the user to remove the value of an item in the data store. To cmdlet, overwrite the following methods of [System.Management.Automation.Provider.ItemCmdletProvider][43] class: -- [Clearitem][44] +- [ClearItem][44] - [ClearItemDynamicParameters][45] ### `Copy-Item` @@ -51,7 +51,7 @@ This cmdlet allows the user to copy an item from one location to another. To sup overwrite the following methods of [System.Management.Automation.Provider.ContainerCmdletProvider][01] class: -- [Copyitem][02] +- [CopyItem][02] - [CopyItemDynamicParameters][03] ### `Get-Item` @@ -59,7 +59,7 @@ overwrite the following methods of This cmdlet allows the user to retrieve data from the data store. To support this cmdlet, overwrite the following methods of [System.Management.Automation.Provider.ItemCmdletProvider][43] class: -- [Getitem][46] +- [GetItem][46] - [GetItemDynamicParameters][47] ### `Get-ChildItem` @@ -83,7 +83,7 @@ cmdlet, overwrite the This cmdlet allows the user to move an item from one location to another location. To support this cmdlet, overwrite the following methods of -[System.Management.Automation.Provider.Navigationcmdletprovider][53] class: +[System.Management.Automation.Provider.NavigationCmdletProvider][53] class: - [MoveItem][55] - [MoveItemDynamicParameters][56] diff --git a/reference/docs-conceptual/developer/provider/provider-samples.md b/reference/docs-conceptual/developer/provider/provider-samples.md index 723053a01bf0..35713d8ac3fa 100644 --- a/reference/docs-conceptual/developer/provider/provider-samples.md +++ b/reference/docs-conceptual/developer/provider/provider-samples.md @@ -13,22 +13,22 @@ This section includes samples of providers that access a Microsoft Access databa This section includes the following topics: [AccessDBProviderSample01 Sample](./accessdbprovidersample01.md) -This sample shows how to declare the provider class that derives directly from the [System.Management.Automation.Provider.Cmdletprovider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) class. It is included here only for completeness. +This sample shows how to declare the provider class that derives directly from the [System.Management.Automation.Provider.CmdletProvider](/dotnet/api/System.Management.Automation.Provider.CmdletProvider) class. It is included here only for completeness. [AccessDBProviderSample02](./accessdbprovidersample02.md) -This sample shows how to overwrite the [System.Management.Automation.Provider.Drivecmdletprovider.Newdrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) and [System.Management.Automation.Provider.Drivecmdletprovider.Removedrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) methods to support calls to the `New-PSDrive` and `Remove-PSDrive` cmdlets. The provider class in this sample derives from the [System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class. +This sample shows how to overwrite the [System.Management.Automation.Provider.DriveCmdletProvider.NewDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) and [System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) methods to support calls to the `New-PSDrive` and `Remove-PSDrive` cmdlets. The provider class in this sample derives from the [System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class. [AccessDBProviderSample03](./accessdbprovidersample03.md) -This sample shows how to overwrite the [System.Management.Automation.Provider.Itemcmdletprovider.Getitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.GetItem) and [System.Management.Automation.Provider.Itemcmdletprovider.Setitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) methods to support calls to the `Get-Item` and `Set-Item` cmdlets. The provider class in this sample derives from the [System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. +This sample shows how to overwrite the [System.Management.Automation.Provider.ItemCmdletProvider.GetItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.GetItem) and [System.Management.Automation.Provider.ItemCmdletProvider.SetItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) methods to support calls to the `Get-Item` and `Set-Item` cmdlets. The provider class in this sample derives from the [System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) class. [AccessDBProviderSample04](./accessdbprovidersample04.md) -This sample shows how to overwrite container methods to support calls to the `Copy-Item`, `Get-ChildItem`, `New-Item`, and `Remove-Item` cmdlets. These methods should be implemented when the data store contains items that are containers. A container is a group of child items under a common parent item. The provider class in this sample derives from the [System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. +This sample shows how to overwrite container methods to support calls to the `Copy-Item`, `Get-ChildItem`, `New-Item`, and `Remove-Item` cmdlets. These methods should be implemented when the data store contains items that are containers. A container is a group of child items under a common parent item. The provider class in this sample derives from the [System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) class. [AccessDBProviderSample05](./accessdbprovidersample05.md) -This sample shows how to overwrite container methods to support calls to the `Move-Item` and `Join-Path` cmdlets. These methods should be implemented when the user needs to move items within a container and if the data store contains nested containers. The provider class in this sample derives from the [System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. +This sample shows how to overwrite container methods to support calls to the `Move-Item` and `Join-Path` cmdlets. These methods should be implemented when the user needs to move items within a container and if the data store contains nested containers. The provider class in this sample derives from the [System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. [AccessDBProviderSample06](./accessdbprovidersample06.md) -This sample shows how to overwrite content methods to support calls to the `Clear-Content`, `Get-Content`, and `Set-Content` cmdlets. These methods should be implemented when the user needs to manage the content of the items in the data store. The provider class in this sample derives from the [System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class, and it implements the [System.Management.Automation.Provider.Icontentcmdletprovider](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider) interface. +This sample shows how to overwrite content methods to support calls to the `Clear-Content`, `Get-Content`, and `Set-Content` cmdlets. These methods should be implemented when the user needs to manage the content of the items in the data store. The provider class in this sample derives from the [System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class, and it implements the [System.Management.Automation.Provider.IContentCmdletProvider](/dotnet/api/System.Management.Automation.Provider.IContentCmdletProvider) interface. ## See Also diff --git a/reference/docs-conceptual/developer/provider/windows-powershell-provider-overview.md b/reference/docs-conceptual/developer/provider/windows-powershell-provider-overview.md index 015c3fc10bcc..ec734e3b05cc 100644 --- a/reference/docs-conceptual/developer/provider/windows-powershell-provider-overview.md +++ b/reference/docs-conceptual/developer/provider/windows-powershell-provider-overview.md @@ -52,7 +52,7 @@ ways. A provider should support one or more of the following path types. A drive-qualified path is a combination of the item name, the container and subcontainers in which the item is located, and the Windows PowerShell drive through which the item is accessed. (Drives are defined by the provider that is used to access the data store. This path starts with the drive -name followed by a colon (:). For example: `get-childitem C:` +name followed by a colon (:). For example: `Get-ChildItem C:` ### Provider-qualified paths @@ -72,7 +72,7 @@ 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`. ## Overriding cmdlet parameters @@ -91,18 +91,18 @@ dynamic parameter, and the methods used to implement them, see ## Provider capabilities 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 defines a number of capabilities that providers can support. These include the ability to use wildcards, filter items, and support transactions. To specify capabilities for a provider, add a list of values of 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, combined with a logical `OR` operation, as the -[System.Management.Automation.Provider.Cmdletproviderattribute.Providercapabilities*](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute.ProviderCapabilities) +[System.Management.Automation.Provider.CmdletProviderAttribute.ProviderCapabilities*](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute.ProviderCapabilities) property (the second parameter of the attribute) of 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 for your provider class. For example, the following attribute specifies that the provider supports 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) **ShouldProcess** and [System.Management.Automation.Provider.ProviderCapabilities](/dotnet/api/System.Management.Automation.Provider.ProviderCapabilities) **Transactions** capabilities. @@ -118,11 +118,11 @@ When writing a provider, you can implement your own Help for the provider cmdlet This includes a single help topic for each provider cmdlet or multiple versions of a help topic for cases where the provider cmdlet acts differently based on the use of dynamic parameters. To support provider cmdlet-specific help, your provider must implement the -[System.Management.Automation.Provider.Icmdletprovidersupportshelp](/dotnet/api/System.Management.Automation.Provider.ICmdletProviderSupportsHelp) +[System.Management.Automation.Provider.ICmdletProviderSupportsHelp](/dotnet/api/System.Management.Automation.Provider.ICmdletProviderSupportsHelp) interface. The Windows PowerShell engine calls the -[System.Management.Automation.Provider.Icmdletprovidersupportshelp.Gethelpmaml*](/dotnet/api/System.Management.Automation.Provider.ICmdletProviderSupportsHelp.GetHelpMaml) +[System.Management.Automation.Provider.ICmdletProviderSupportsHelp.GetHelpMaml*](/dotnet/api/System.Management.Automation.Provider.ICmdletProviderSupportsHelp.GetHelpMaml) method to display the Help topic for your provider cmdlets. The engine provides the name of the cmdlet that the user specified when running the `Get-Help` cmdlet and the current path of the user. The current path is required if your provider implements different versions of the same provider diff --git a/reference/docs-conceptual/developer/provider/windows-powershell-provider-quickstart.md b/reference/docs-conceptual/developer/provider/windows-powershell-provider-quickstart.md index cd756cbebe43..122953d8866c 100644 --- a/reference/docs-conceptual/developer/provider/windows-powershell-provider-quickstart.md +++ b/reference/docs-conceptual/developer/provider/windows-powershell-provider-quickstart.md @@ -10,7 +10,7 @@ This topic explains how to create a Windows PowerShell provider that has basic f ## Writing a basic provider -The most basic functionality of a Windows PowerShell provider is to create and remove drives. In this example, we implement the [System.Management.Automation.Provider.Drivecmdletprovider.Newdrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) and [System.Management.Automation.Provider.Drivecmdletprovider.Removedrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) methods of the [System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class. You will also see how to declare a provider class. +The most basic functionality of a Windows PowerShell provider is to create and remove drives. In this example, we implement the [System.Management.Automation.Provider.DriveCmdletProvider.NewDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) and [System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) methods of the [System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class. You will also see how to declare a provider class. When you write a provider, you can specify default drives-drives that are created automatically when the provider is available. You also define a method to create new drives that use that provider. @@ -24,15 +24,15 @@ In Visual Studio, create a Class Library project named AccessDBProviderSample. C 1. Add the System.Management.Automation assembly as a reference to your project. -2. Click **Project > AccessDBProviderSample Properties > Debug**. In **Start project**, click **Start external program**, and navigate to the Windows PowerShell executable (typically c:\Windows\System32\WindowsPowerShell\v1.0\\.powershell.exe). +2. Click **Project > AccessDBProviderSample Properties > Debug**. In **Start project**, click **Start external program**, and navigate to the Windows PowerShell executable (typically C:\Windows\System32\WindowsPowerShell\v1.0\\.powershell.exe). -3. Under **Start Options**, enter the following into the **Command line arguments** box: `-noexit -command "[reflection.assembly]::loadFrom(AccessDBProviderSample.dll' ) | import-module"` +3. Under **Start Options**, enter the following into the **Command line arguments** box: `-NoExit -Command "[Reflection.Assembly]::LoadFrom(AccessDBProviderSample.dll' ) | Import-Module"` ### Declaring the provider class -Our provider derives from the [System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class. Most providers that provide real functionality (accessing and manipulating items, navigating the data store, and getting and setting content of items) derive from the [System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. +Our provider derives from the [System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class. Most providers that provide real functionality (accessing and manipulating items, navigating the data store, and getting and setting content of items) derive from the [System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class. -In addition to specifying that the class derives from [System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider), you must decorate it with the [System.Management.Automation.Provider.Cmdletproviderattribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) as shown in the example. +In addition to specifying that the class derives from [System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider), you must decorate it with the [System.Management.Automation.Provider.CmdletProviderAttribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute) as shown in the example. ```csharp namespace Microsoft.Samples.PowerShell.Providers @@ -56,7 +56,7 @@ namespace Microsoft.Samples.PowerShell.Providers ### Implementing NewDrive -The [System.Management.Automation.Provider.Drivecmdletprovider.Newdrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) method is called by the Windows PowerShell engine when a user calls the [Microsoft.PowerShell.Commands.NewPSDriveCommand](/dotnet/api/Microsoft.PowerShell.Commands.Newpsdrivecommand) cmdlet specifying the name of your provider. The PSDriveInfo parameter is passed by the Windows PowerShell engine, and the method returns the new drive to the Windows PowerShell engine. This method must be declared within the class created above. +The [System.Management.Automation.Provider.DriveCmdletProvider.NewDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.NewDrive) method is called by the Windows PowerShell engine when a user calls the [Microsoft.PowerShell.Commands.NewPSDriveCommand](/dotnet/api/Microsoft.PowerShell.Commands.Newpsdrivecommand) cmdlet specifying the name of your provider. The PSDriveInfo parameter is passed by the Windows PowerShell engine, and the method returns the new drive to the Windows PowerShell engine. This method must be declared within the class created above. The method first checks to make sure both the drive object and the drive root that were passed in exist, returning `null` if either of them do not. It then uses a constructor of the internal class AccessDBPSDriveInfo to create a new drive and a connection to the Access database the drive represents. @@ -136,7 +136,7 @@ internal class AccessDBPSDriveInfo : PSDriveInfo ### Implementing RemoveDrive -The [System.Management.Automation.Provider.Drivecmdletprovider.Removedrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) method is called by the Windows PowerShell engine when a user calls the [Microsoft.PowerShell.Commands.RemovePSDriveCommand](/dotnet/api/Microsoft.PowerShell.Commands.removepsdrivecommand) cmdlet. The method in this provider closes the connection to the Access database. +The [System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive*](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider.RemoveDrive) method is called by the Windows PowerShell engine when a user calls the [Microsoft.PowerShell.Commands.RemovePSDriveCommand](/dotnet/api/Microsoft.PowerShell.Commands.removepsdrivecommand) cmdlet. The method in this provider closes the connection to the Access database. ```csharp protected override PSDriveInfo RemoveDrive(PSDriveInfo drive) diff --git a/reference/docs-conceptual/developer/provider/writing-a-container-provider.md b/reference/docs-conceptual/developer/provider/writing-a-container-provider.md index 7d8eda14deb3..690abb14271f 100644 --- a/reference/docs-conceptual/developer/provider/writing-a-container-provider.md +++ b/reference/docs-conceptual/developer/provider/writing-a-container-provider.md @@ -7,9 +7,9 @@ title: Writing a container provider # Writing a container provider This topic describes how to implement the methods of a Windows PowerShell provider that support -items that contain other items, such as folders in the file system provider. To be able to support +items that contain other items, such as folders in the FileSystem provider. To be able to support containers, a provider must derive 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) class. The provider in the examples in this topic uses an Access database as its data store. There are @@ -23,7 +23,7 @@ For more information about Windows PowerShell providers, see ## Implementing container methods 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 implements methods that support containers, and create, copy, and remove items. For a complete list of these methods, see [System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider#methods). @@ -33,19 +33,19 @@ list of these methods, see > [Windows PowerShell Provider QuickStart](./windows-powershell-provider-quickstart.md). This topic > does not cover the basics of how to set up a provider project, or how to implement the methods > inherited 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) > class that create and remove drives. This topic also does not cover how to implement methods > exposed 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) > class. For an example that shows how to implement item cmdlets, see > [Writing an item provider](./writing-an-item-provider.md). ### Declaring the provider class Declare the provider to derive 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) class, and decorate it with 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). ```csharp [CmdletProvider("AccessDB", ProviderCapabilities.None)] @@ -58,18 +58,18 @@ class, and decorate it with the ### Implementing GetChildItems The PowerShell engine calls 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 when a user calls the [Microsoft.PowerShell.Commands.GetChildItemCommand](/dotnet/api/Microsoft.PowerShell.Commands.Getchilditemcommand) cmdlet. This method gets the items that are the children of the item at the specified path. In the Access database example, the behavior 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 depends on the type of the specified item. If the item is the drive, then the children are tables, and the method returns the set of tables from the database. If the specified item is a table, then the children are the rows of that table. If the item is a row, then it has no children, and the method returns that row only. All child items are sent back to the PowerShell engine by 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. ```csharp @@ -130,9 +130,9 @@ protected override void GetChildItems(string path, bool recurse) ### Implementing GetChildNames 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 is similar to 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, except that it returns only the name property of the items, and not the items themselves. ```csharp @@ -184,7 +184,7 @@ protected override void GetChildNames(string path, ### Implementing 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 creates a new item of the specified type at the specified path. The PowerShell engine calls this method when a user calls the [Microsoft.PowerShell.Commands.NewItemCommand](/dotnet/api/Microsoft.PowerShell.Commands.newitemcommand) @@ -378,7 +378,7 @@ cmdlet. This method can also be recursive, copying all of the items children in itself. Similarly to 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, this method performs logic to make sure that the specified item is of the correct type for the path to which it is being copied. For example, if the destination path is a table, the item to be copied must be a row. @@ -435,7 +435,7 @@ protected override void CopyItem(string path, string copyPath, bool recurse) throw e; } - // if table already exists then force parameter should be set + // if table already exists then Force parameter should be set // to force a copy if (!Force && GetTable(copyTableName) != null) { @@ -513,7 +513,7 @@ protected override void CopyItem(string path, string copyPath, bool recurse) ### Implementing RemoveItem 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 removes the item at the specified path. The PowerShell engine calls this method when a user calls the [Microsoft.PowerShell.Commands.RemoveItemCommand](/dotnet/api/Microsoft.PowerShell.Commands.removeitemcommand) diff --git a/reference/docs-conceptual/developer/provider/writing-a-navigation-provider.md b/reference/docs-conceptual/developer/provider/writing-a-navigation-provider.md index 7494361dba95..aaecaf97b85c 100644 --- a/reference/docs-conceptual/developer/provider/writing-a-navigation-provider.md +++ b/reference/docs-conceptual/developer/provider/writing-a-navigation-provider.md @@ -9,7 +9,7 @@ title: Writing a navigation provider This topic describes how to implement the methods of a Windows PowerShell provider that support nested containers (multi-level data stores), moving items, and relative paths. A navigation provider must derive 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) class. The provider in the examples in this topic uses an Access database as its data store. There are @@ -22,17 +22,17 @@ For more information about Windows PowerShell providers, see [Windows PowerShell ## Implementing navigation methods 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 implements methods that support nested containers, relative paths, and moving items. For a complete list of these methods, see [NavigationCmdletProvider Methods](/dotnet/api/system.management.automation.provider.navigationcmdletprovider#methods). > [!NOTE] -> This topic builds on the information in [Windows PowerShell Provider QuickStart](./windows-powershell-provider-quickstart.md). This topic does not cover the basics of how to set up a provider project, or how to implement the methods inherited from the [System.Management.Automation.Provider.Drivecmdletprovider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class that create and remove drives. This topic also does not cover how to implement methods exposed by the [System.Management.Automation.Provider.Itemcmdletprovider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) or [System.Management.Automation.Provider.Containercmdletprovider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) classes. For an example that shows how to implement item cmdlets, see [Writing an item provider](./writing-an-item-provider.md). For an example that shows how to implement container cmdlets, see [Writing a container provider](./writing-a-container-provider.md). +> This topic builds on the information in [Windows PowerShell Provider QuickStart](./windows-powershell-provider-quickstart.md). This topic does not cover the basics of how to set up a provider project, or how to implement the methods inherited from the [System.Management.Automation.Provider.DriveCmdletProvider](/dotnet/api/System.Management.Automation.Provider.DriveCmdletProvider) class that create and remove drives. This topic also does not cover how to implement methods exposed by the [System.Management.Automation.Provider.ItemCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider) or [System.Management.Automation.Provider.ContainerCmdletProvider](/dotnet/api/System.Management.Automation.Provider.ContainerCmdletProvider) classes. For an example that shows how to implement item cmdlets, see [Writing an item provider](./writing-an-item-provider.md). For an example that shows how to implement container cmdlets, see [Writing a container provider](./writing-a-container-provider.md). ### Declaring the provider class -Declare the provider to derive from the [System.Management.Automation.Provider.Navigationcmdletprovider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class, and decorate it with the [System.Management.Automation.Provider.Cmdletproviderattribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute). +Declare the provider to derive from the [System.Management.Automation.Provider.NavigationCmdletProvider](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider) class, and decorate it with the [System.Management.Automation.Provider.CmdletProviderAttribute](/dotnet/api/System.Management.Automation.Provider.CmdletProviderAttribute). ``` [CmdletProvider("AccessDB", ProviderCapabilities.None)] @@ -44,7 +44,7 @@ Declare the provider to derive from the [System.Management.Automation.Provider.N ### Implementing IsItemContainer -The [System.Management.Automation.Provider.Navigationcmdletprovider.Isitemcontainer*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer) method checks whether the item at the specified path is a container. +The [System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.IsItemContainer) method checks whether the item at the specified path is a container. ```csharp protected override bool IsItemContainer(string path) @@ -77,7 +77,7 @@ protected override bool IsItemContainer(string path) ### Implementing GetChildName -The [System.Management.Automation.Provider.Navigationcmdletprovider.Getchildname*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName) method gets the name property of the child item at the specified path. If the item at the specified path is not a child of a container, then this method should return the path. +The [System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetChildName) method gets the name property of the child item at the specified path. If the item at the specified path is not a child of a container, then this method should return the path. ```csharp protected override string GetChildName(string path) @@ -111,7 +111,7 @@ protected override string GetChildName(string path) ### Implementing GetParentPath -The [System.Management.Automation.Provider.Navigationcmdletprovider.Getparentpath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetParentPath) method gets the path of the parent of the item at the specified path. If the item at the specified path is the root of the data store (so it has no parent), then this method should return the root path. +The [System.Management.Automation.Provider.NavigationCmdletProvider.GetParentPath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.GetParentPath) method gets the path of the parent of the item at the specified path. If the item at the specified path is the root of the data store (so it has no parent), then this method should return the root path. ```csharp protected override string GetParentPath(string path, string root) @@ -132,7 +132,7 @@ protected override string GetParentPath(string path, string root) ### Implementing MakePath -The [System.Management.Automation.Provider.Navigationcmdletprovider.Makepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) method joins a specified parent path and a specified child path to create a provider-internal path (for information about path types that providers can support, see [Windows PowerShell Provider Overview](./windows-powershell-provider-overview.md). The PowerShell engine calls this method when a user calls the [Microsoft.PowerShell.Commands.JoinPathCommand](/dotnet/api/Microsoft.PowerShell.Commands.joinpathcommand) cmdlet. +The [System.Management.Automation.Provider.NavigationCmdletProvider.MakePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MakePath) method joins a specified parent path and a specified child path to create a provider-internal path (for information about path types that providers can support, see [Windows PowerShell Provider Overview](./windows-powershell-provider-overview.md). The PowerShell engine calls this method when a user calls the [Microsoft.PowerShell.Commands.JoinPathCommand](/dotnet/api/Microsoft.PowerShell.Commands.joinpathcommand) cmdlet. ```csharp protected override string MakePath(string parent, string child) @@ -191,7 +191,7 @@ protected override string MakePath(string parent, string child) ### Implementing NormalizeRelativePath -The [System.Management.Automation.Provider.Navigationcmdletprovider.Normalizerelativepath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.NormalizeRelativePath) method takes `path` and `basepath` parameters, and returns a normalized path that is equivalent to the `path` parameter and relative to the `basepath` parameter. +The [System.Management.Automation.Provider.NavigationCmdletProvider.NormalizeRelativePath*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.NormalizeRelativePath) method takes `path` and `basepath` parameters, and returns a normalized path that is equivalent to the `path` parameter and relative to the `basepath` parameter. ```csharp protected override string NormalizeRelativePath(string path, @@ -221,7 +221,7 @@ protected override string NormalizeRelativePath(string path, ### Implementing MoveItem -The [System.Management.Automation.Provider.Navigationcmdletprovider.Moveitem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) method moves an item from the specified path to the specified destination path. The PowerShell engine calls this method when a user calls the [Microsoft.PowerShell.Commands.MoveItemCommand](/dotnet/api/Microsoft.PowerShell.Commands.moveitemcommand) cmdlet. +The [System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem*](/dotnet/api/System.Management.Automation.Provider.NavigationCmdletProvider.MoveItem) method moves an item from the specified path to the specified destination path. The PowerShell engine calls this method when a user calls the [Microsoft.PowerShell.Commands.MoveItemCommand](/dotnet/api/Microsoft.PowerShell.Commands.moveitemcommand) cmdlet. ```csharp protected override void MoveItem(string path, string destination) diff --git a/reference/docs-conceptual/developer/provider/writing-an-item-provider.md b/reference/docs-conceptual/developer/provider/writing-an-item-provider.md index 817cd1990f36..f0b3e260e868 100644 --- a/reference/docs-conceptual/developer/provider/writing-an-item-provider.md +++ b/reference/docs-conceptual/developer/provider/writing-an-item-provider.md @@ -8,7 +8,7 @@ title: Writing an item provider This topic describes how to implement the methods of a Windows PowerShell provider that access and manipulate items in the data store. To be able to access items, a provider must derive 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) class. The provider in the examples in this topic uses an Access database as its data store. There are @@ -22,18 +22,18 @@ For more information about Windows PowerShell providers, see ## Implementing item methods 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 exposes several methods that can be used to access and manipulate the items in a data store. For a complete list of these methods, see [ItemCmdletProvider Methods](/dotnet/api/system.management.automation.provider.itemcmdletprovider#methods). In this example, we will implement four of these methods. -[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) gets an item at a specified path. -[System.Management.Automation.Provider.Itemcmdletprovider.Setitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) +[System.Management.Automation.Provider.ItemCmdletProvider.SetItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) sets the value of the specified item. -[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) checks whether an item exists at the specified path. -[System.Management.Automation.Provider.Itemcmdletprovider.Isvalidpath*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath) +[System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath) checks a path to see if it maps to a location in the data store. > [!NOTE] @@ -41,15 +41,15 @@ checks a path to see if it maps to a location in the data store. > [Windows PowerShell Provider QuickStart](./windows-powershell-provider-quickstart.md). This topic > does not cover the basics of how to set up a provider project, or how to implement the methods > inherited 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) > class that create and remove drives. ### Declaring the provider class Declare the provider to derive 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) class, and decorate it with 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). ```csharp [CmdletProvider("AccessDB", ProviderCapabilities.None)] @@ -64,13 +64,13 @@ class, and decorate it with the ### Implementing GetItem 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) is called by the PowerShell engine when a user calls the [Microsoft.PowerShell.Commands.GetItemCommand](/dotnet/api/Microsoft.PowerShell.Commands.getitemcommand) cmdlet on your provider. The method returns the item at the specified path. In the Access database example, the method checks whether the item is the drive itself, a table in the database, or a row in the database. The method sends the item to the PowerShell engine by calling 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. ```csharp @@ -111,7 +111,7 @@ protected override void GetItem(string path) ### Implementing SetItem The -[System.Management.Automation.Provider.Itemcmdletprovider.Setitem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) +[System.Management.Automation.Provider.ItemCmdletProvider.SetItem*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.SetItem) method is called by the PowerShell engine calls when a user calls the [Microsoft.PowerShell.Commands.SetItemCommand](/dotnet/api/Microsoft.PowerShell.Commands.setitemcommand) cmdlet. It sets the value of the item at the specified path. @@ -178,12 +178,12 @@ protected override void SetItem(string path, object values) ### Implementing ItemExists The -[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) method is called by the PowerShell engine when a user calls the [Microsoft.PowerShell.Commands.TestPathCommand](/dotnet/api/Microsoft.PowerShell.Commands.Testpathcommand) cmdlet. The method determines whether there is an item at the specified path. If the item does exist, the method passes it back to the PowerShell engine by calling -[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). ```csharp protected override bool ItemExists(string path) @@ -230,7 +230,7 @@ protected override bool ItemExists(string path) ### Implementing IsValidPath The -[System.Management.Automation.Provider.Itemcmdletprovider.Isvalidpath*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath) +[System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath*](/dotnet/api/System.Management.Automation.Provider.ItemCmdletProvider.IsValidPath) method checks whether the specified path is syntactically valid for the current provider. It does not check whether an item exists at the path. diff --git a/reference/docs-conceptual/developer/scheduling-jobs-with-the-windows-powershell-api.md b/reference/docs-conceptual/developer/scheduling-jobs-with-the-windows-powershell-api.md index 7a5f18a89450..e7c97ef6e13b 100644 --- a/reference/docs-conceptual/developer/scheduling-jobs-with-the-windows-powershell-api.md +++ b/reference/docs-conceptual/developer/scheduling-jobs-with-the-windows-powershell-api.md @@ -189,7 +189,7 @@ namespace Microsoft.Samples.PowerShell.ScheduledJob // Since the PowerShell job runs in a non-interactive Task Scheduler // process the job status and output data is written to a file based // job store and the directory location is the current user local app - // data ($env:LOCALAPPDATA). + // data ($Env:LOCALAPPDATA). // This job store can be accessed through the ScheduledJobSourceAdapter class. ScheduledJobSourceAdapter schedJobSourceAdapter = new ScheduledJobSourceAdapter(); IList jobRuns = schedJobSourceAdapter.GetJobs(); diff --git a/reference/docs-conceptual/developer/windows-powershell-reference.md b/reference/docs-conceptual/developer/windows-powershell-reference.md index 75bd4e1eee86..dd32a177d1dd 100644 --- a/reference/docs-conceptual/developer/windows-powershell-reference.md +++ b/reference/docs-conceptual/developer/windows-powershell-reference.md @@ -56,7 +56,7 @@ base class from which all cmdlet classes must be derived. For more information a [System.Management.Automation.Provider](/dotnet/api/System.Management.Automation.Provider) This namespace contains the classes, enumerations, and interfaces required to implement a Windows PowerShell provider. In particular, 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 is the base class from which all Windows PowerShell provider classes must be derived. [Microsoft.PowerShell.Commands](/dotnet/api/Microsoft.PowerShell.Commands) This namespace contains @@ -69,7 +69,7 @@ between the user and Windows PowerShell. [System.Management.Automation.Internal](/dotnet/api/System.Management.Automation.Internal) This namespace contains the base classes used by other namespace classes. For example, the -[System.Management.Automation.Internal.Cmdletmetadataattribute](/dotnet/api/System.Management.Automation.Internal.CmdletMetadataAttribute) +[System.Management.Automation.Internal.CmdletMetadataAttribute](/dotnet/api/System.Management.Automation.Internal.CmdletMetadataAttribute) class is the base class for the [System.Management.Automation.CmdletAttribute](/dotnet/api/System.Management.Automation.CmdletAttribute) class. diff --git a/reference/docs-conceptual/install/Installing-PowerShell-on-Windows.md b/reference/docs-conceptual/install/Installing-PowerShell-on-Windows.md index 129c9ce04c0a..3d54be36a18d 100644 --- a/reference/docs-conceptual/install/Installing-PowerShell-on-Windows.md +++ b/reference/docs-conceptual/install/Installing-PowerShell-on-Windows.md @@ -73,16 +73,16 @@ Once downloaded, double-click the installer file and follow the prompts. The installer creates a shortcut in the Windows Start Menu. -- By default the package is installed to `$env:ProgramFiles\PowerShell\` -- You can launch PowerShell via the Start Menu or `$env:ProgramFiles\PowerShell\\pwsh.exe` +- By default the package is installed to `$Env:ProgramFiles\PowerShell\` +- You can launch PowerShell via the Start Menu or `$Env:ProgramFiles\PowerShell\\pwsh.exe` > [!NOTE] > PowerShell 7.4 installs to a new directory and runs side-by-side with Windows PowerShell 5.1. > PowerShell 7.4 is an in-place upgrade that removes previous versions of PowerShell 7. Preview > versions of PowerShell can be installed side-by-side with other versions of PowerShell. > -> - PowerShell 7.4 is installed to `$env:ProgramFiles\PowerShell\7` -> - The `$env:ProgramFiles\PowerShell\7` folder is added to `$env:PATH` +> - PowerShell 7.4 is installed to `$Env:ProgramFiles\PowerShell\7` +> - The `$Env:ProgramFiles\PowerShell\7` folder is added to `$Env:PATH` > > If you need to run PowerShell 7.4 side-by-side with other versions, use the [ZIP install][15] > method to install the other version to a different folder. @@ -129,7 +129,7 @@ installation options: - `DISABLE_TELEMETRY` - This property controls the option for disabling PowerShell's telemetry by setting the `POWERSHELL_TELEMETRY_OPTOUT` environment variable. - `INSTALLFOLDER` - This property controls the installation directory. The default is - `$env:ProgramFiles\PowerShell\`. This is the location where the installer creates the versioned + `$Env:ProgramFiles\PowerShell\`. This is the location where the installer creates the versioned subfolder. You can't change the name of the versioned subfolder. - For current releases, the versioned subfolder is `7` - For preview releases, the versioned subfolder is `7-preview` @@ -158,7 +158,7 @@ installing the MSI packages, installing the ZIP archive doesn't check for prereq remoting over WSMan to work properly, ensure that you've met the [prerequisites][13]. Use this method to install the ARM-based version of PowerShell on computers like the Microsoft -Surface Pro X. For best results, install PowerShell to the to `$env:ProgramFiles\PowerShell\7` +Surface Pro X. For best results, install PowerShell to the to `$Env:ProgramFiles\PowerShell\7` folder. ## Install as a .NET Global tool @@ -170,8 +170,8 @@ If you already have the [.NET Core SDK][04] installed, you can install PowerShel dotnet tool install --global PowerShell ``` -The dotnet tool installer adds `$HOME\.dotnet\tools` to your `$env:PATH` environment variable. -However, the currently running shell doesn't have the updated `$env:PATH`. You can start PowerShell +The dotnet tool installer adds `$HOME\.dotnet\tools` to your `$Env:PATH` environment variable. +However, the currently running shell doesn't have the updated `$Env:PATH`. You can start PowerShell from a new shell by typing `pwsh`. ## Installing from the Microsoft Store @@ -216,7 +216,7 @@ application sandbox. However, changes to the application's root folder are still ## Installing a preview version -Preview releases of PowerShell 7 install to `$env:ProgramFiles\PowerShell\7-preview` so they can be +Preview releases of PowerShell 7 install to `$Env:ProgramFiles\PowerShell\7-preview` so they can be run side-by-side with non-preview releases of PowerShell. PowerShell 7.4 is the next preview release. @@ -258,7 +258,7 @@ Windows 10 IoT Enterprise comes with Windows PowerShell, which we can use to dep # Replace the placeholder information for the following variables: $deviceip = 'results.txt +Get-ChildItem E:*.txt | Sort-Object -CaseSensitive | Process-File >results.txt ``` In the first case, `Get-ChildItem` creates a collection of names of the files in the current/default @@ -831,7 +832,7 @@ directory. That collection is sent to the host environment, which, by default, w element's value to standard output. In the second case, `Get-ChildItem` creates a collection of names of the files in the directory -specified, using the argument `e:*.txt`. That collection is written to the command `Sort-Object`, +specified, using the argument `E:*.txt`. That collection is written to the command `Sort-Object`, which, by default, sorts them in ascending order, sensitive to case (by virtue of the **CaseSensitive** argument). The resulting collection is then written to command `Process-File`, which performs some (unknown) processing. The output from that command is then redirected to the diff --git a/reference/docs-conceptual/lang-spec/chapter-04.md b/reference/docs-conceptual/lang-spec/chapter-04.md index 977631b0e7c6..b8eb70831dcb 100644 --- a/reference/docs-conceptual/lang-spec/chapter-04.md +++ b/reference/docs-conceptual/lang-spec/chapter-04.md @@ -39,7 +39,7 @@ supports arithmetic operations on those values. The set of numerical types inclu A **collection** is a group of one or more related items, which need not have the same type. Examples of collection types are arrays, stacks, queues, lists, and hash tables. A program can _enumerate_ (or _iterate_) over the elements in a collection, getting access to each element one at -a time. Common ways to do this are with the foreach statement ([§8.4.4][§8.4.4]) and the +a time. Common ways to do this are with the `foreach` statement ([§8.4.4][§8.4.4]) and the [ForEach-Object](xref:Microsoft.PowerShell.Core.ForEach-Object) cmdlet. The type of an object that represents an enumerator is described in [§4.5.16][§4.5.16]. @@ -326,7 +326,7 @@ In PowerShell, `string` maps to `System.String`. ### 4.3.2 Arrays -All array types are derived from the type `Array`. This type has the following accessible members: +All array types are derived from the type `array`. This type has the following accessible members: @@ -372,7 +372,7 @@ Copy(source, sourceIndex, destination, destinatio For more details on arrays, see [§9.][§9.] -In PowerShell, `Array` maps to `System.Array`. +In PowerShell, `array` maps to `System.Array`. ### 4.3.3 Hashtables diff --git a/reference/docs-conceptual/lang-spec/chapter-05.md b/reference/docs-conceptual/lang-spec/chapter-05.md index 24fe4d6d4300..d322eb9be5c2 100644 --- a/reference/docs-conceptual/lang-spec/chapter-05.md +++ b/reference/docs-conceptual/lang-spec/chapter-05.md @@ -60,9 +60,9 @@ function F ($p1, $p2) { $h1.FirstName = "Smith" $Alias:A = "Help" - $Env:MyPath = "e:\Temp" + $Env:MyPath = "E:\Temp" ${E:output.txt} = 123 - $function:F = { "Hello there" } + $Function:F = { "Hello there" } $Variable:v = 10 } ``` @@ -74,7 +74,7 @@ function F ($p1, $p2) { - `$p1` and `$p2` are parameters - `$radius`, `$circumference`, `$date`, `$month`, `$values`, `$value`, and `$h1` are ordinary variables -- `$Alias:A`, `$Env:MyPath`, `${E:output.txt}`, and `$function:F` are variables on the corresponding +- `$Alias:A`, `$Env:MyPath`, `${E:output.txt}`, and `$Function:F` are variables on the corresponding provider drives. - `$Variable:v` is actually an ordinary variable written with its fully qualified provider drive. diff --git a/reference/docs-conceptual/lang-spec/chapter-06.md b/reference/docs-conceptual/lang-spec/chapter-06.md index 3348a9c809f9..84be60cef3af 100644 --- a/reference/docs-conceptual/lang-spec/chapter-06.md +++ b/reference/docs-conceptual/lang-spec/chapter-06.md @@ -143,8 +143,8 @@ The rules for converting any value to type string are as follows: - For other reference type values, if the reference type supports such a conversion, that conversion is used; otherwise, the conversion is in error. -The string used to represent the value of an element that is an array has the form `System.type[]`, -`System.type[,]`, and so on. For other reference types, the method `ToString` is called. For other +The string used to represent the value of an element that is an array has the form `System.Type[]`, +`System.Type[,]`, and so on. For other reference types, the method `ToString` is called. For other enumerable types, the source value is treated like a 1-dimensional array. ## 6.9 Conversion to array diff --git a/reference/docs-conceptual/lang-spec/chapter-07.md b/reference/docs-conceptual/lang-spec/chapter-07.md index 296b0998a84c..4e2f6b593540 100644 --- a/reference/docs-conceptual/lang-spec/chapter-07.md +++ b/reference/docs-conceptual/lang-spec/chapter-07.md @@ -132,7 +132,7 @@ the case. Consider the following example: ```powershell 2,4,6 # Length 3; values 2,4,6 -(2,4),6 # Length 2; values [object[]],int +(2,4),6 # Length 2; values [Object[]],int ``` In the second case, the parentheses change the semantics, resulting in an array whose two elements @@ -312,19 +312,19 @@ The type of the result of an _invocation-expression_ is a _method-designator_ ([ Examples: ```powershell -[math]::Sqrt(2.0) # call method with argument 2.0 +[Math]::Sqrt(2.0) # call method with argument 2.0 [char]::IsUpper("a") # call method $b = "abc#$%XYZabc" $b.ToUpper() # call instance method -[math]::Sqrt(2) # convert 2 to 2.0 and call method -[math]::Sqrt(2D) # convert 2D to 2.0 and call method -[math]::Sqrt($true) # convert $true to 1.0 and call method -[math]::Sqrt("20") # convert "20" to 20 and call method +[Math]::Sqrt(2) # convert 2 to 2.0 and call method +[Math]::Sqrt(2D) # convert 2D to 2.0 and call method +[Math]::Sqrt($true) # convert $true to 1.0 and call method +[Math]::Sqrt("20") # convert "20" to 20 and call method -$a = [math]::Sqrt # get method descriptor for Sqrt +$a = [Math]::Sqrt # get method descriptor for Sqrt $a.Invoke(2.0) # call Sqrt via the descriptor -$a = [math]::("Sq"+"rt") # get method descriptor for Sqrt +$a = [Math]::("Sq"+"rt") # get method descriptor for Sqrt $a.Invoke(2.0) # call Sqrt via the descriptor $a = [char]::ToLower # get method descriptor for ToLower $a.Invoke("X") # call ToLower via the descriptor @@ -503,9 +503,9 @@ $a[(0,1),(1,0)] # slice with Length 2, value 20,30, parens needed $h1 = @{ FirstName = "James"; LastName = "Anderson"; IDNum = 123 } $h1['FirstName'] # the value associated with key FirstName $h1['BirthDate'] # no such key, returns $null -$h1['FirstName','IDNum'] # returns [object[]], Length 2 (James/123) -$h1['FirstName','xxx'] # returns [object[]], Length 2 (James/$null) -$h1[$null,'IDNum'] # returns [object[]], Length 2 ($null/123) +$h1['FirstName','IDNum'] # returns [Object[]], Length 2 (James/123) +$h1['FirstName','xxx'] # returns [Object[]], Length 2 (James/$null) +$h1[$null,'IDNum'] # returns [Object[]], Length 2 ($null/123) ``` Windows PowerShell: When _expression_ is a collection of two or more key names, if `$null` is used @@ -593,11 +593,11 @@ $j = 20 $($i = 10) # pipeline gets nothing $(($i = 10)) # pipeline gets int 10 $($i = 10; $j) # pipeline gets int 20 -$(($i = 10); $j) # pipeline gets [object[]](10,20) +$(($i = 10); $j) # pipeline gets [Object[]](10,20) $(($i = 10); ++$j) # pipeline gets int 10 -$(($i = 10); (++$j)) # pipeline gets [object[]](10,22) +$(($i = 10); (++$j)) # pipeline gets [Object[]](10,22) $($i = 10; ++$j) # pipeline gets nothing -$(2,4,6) # pipeline gets [object[]](2,4,6) +$(2,4,6) # pipeline gets [Object[]](2,4,6) ``` ### 7.1.7 @(...) operator @@ -1107,8 +1107,8 @@ Examples: ```powershell 2,4,6 # Length 3; values 2,4,6 -(2,4),6 # Length 2; values [object[]],int -(2,4,6),12,(2..4) # Length 3; [object[]],int,[object[]] +(2,4),6 # Length 2; values [Object[]],int +(2,4,6),12,(2..4) # Length 3; [Object[]],int,[Object[]] 2,4,6,"red",$null,$true # Length 6 ``` @@ -1284,12 +1284,12 @@ Examples: ```powershell $a = [int[]](10,20) # [int[]], Length 2*1 -$a * "3" # [object[]], Length 2*3 -$a * 4 # [object[]], Length 2*4 -$a * 0 # [object[]], Length 2*0 -$a * 2.3450D # [object[]], Length 2*2 -$a * 2.7 # [object[]], Length 2*3 -(New-Object 'float[,]' 2,3) * 2 # [object[]], Length 2*2 +$a * "3" # [Object[]], Length 2*3 +$a * 4 # [Object[]], Length 2*4 +$a * 0 # [Object[]], Length 2*0 +$a * 2.3450D # [Object[]], Length 2*2 +$a * 2.7 # [Object[]], Length 2*3 +(New-Object 'float[,]' 2,3) * 2 # [Object[]], Length 2*2 ``` ### 7.6.4 Division @@ -1409,10 +1409,10 @@ Examples: ```powershell $a = [int[]](10,20) # [int[]], Length 2 -$a + "red" # [object[]], Length 3 -$a + 12.5,$true # [object[]], Length 4 -$a + (New-Object 'float[,]' 2,3) # [object[]], Length 8 -(New-Object 'float[,]' 2,3) + $a # [object[]], Length 8 +$a + "red" # [Object[]], Length 3 +$a + 12.5,$true # [Object[]], Length 4 +$a + (New-Object 'float[,]' 2,3) # [Object[]], Length 8 +(New-Object 'float[,]' 2,3) + $a # [Object[]], Length 8 ``` ### 7.7.4 Hashtable concatenation @@ -1627,7 +1627,7 @@ $x = [int[]](10,20) $x -is [int[]] # True $a = "abcd" # string is derived from object -$a -is [object] # True +$a -is [Object] # True $x = [double] foreach ($t in [int],$x,[decimal],"string") { @@ -2106,13 +2106,13 @@ Examples: $a = 20; $b = $a + 12L # $b has type long, value 22 $hypot = [Math]::Sqrt(3*3 + 4*4) # type double, value 5 $a = $b = $c = 10.20D # all have type decimal, value 10.20 -$a = (10,20,30),(1,2) # type [object[]], Length 2 +$a = (10,20,30),(1,2) # type [Object[]], Length 2 [int]$x = 10.6 # type int, value 11 [long]$x = "0xabc" # type long, value 0xabc $a = [float] # value type literal [float] $i,$j,$k = 10,"red",$true # $i is 10, $j is "red", $k is True -$i,$j = 10,"red",$true # $i is 10, $j is [object[]], Length 2 -$i,$j = (10,"red"),$true # $i is [object[]], Length 2, $j is True +$i,$j = 10,"red",$true # $i is 10, $j is [Object[]], Length 2 +$i,$j = (10,"red"),$true # $i is [Object[]], Length 2, $j is True $i,$j,$k = 10 # $i is 10, $j is $null, $k is $null $h = @{} @@ -2124,7 +2124,7 @@ $h1["City"] = "New York" # adds element City [int]$Variable:v = 123.456 # v takes on the value 123 ${E:output.txt} = "a" # write text to the given file -$Env:MyPath = "x:\data\file.txt" # define the environment variable +$Env:MyPath = "X:\data\file.txt" # define the environment variable $Function:F = { param ($a, $b) "Hello there, $a, $b" } F 10 "red" # define and invoke a function function Demo { "Hi there from inside Demo" } diff --git a/reference/docs-conceptual/lang-spec/chapter-08.md b/reference/docs-conceptual/lang-spec/chapter-08.md index a40a7fd6dc66..aeeb91a28f27 100644 --- a/reference/docs-conceptual/lang-spec/chapter-08.md +++ b/reference/docs-conceptual/lang-spec/chapter-08.md @@ -249,7 +249,7 @@ If the command type is Application, the parameter `--%` is not passed to the com after `--%` have any environment variables (strings surrounded by `%`) expanded. For example: ```powershell -echoargs.exe --% "%path%" # %path% is replaced with the value $env:path +echoargs.exe --% "%path%" # %path% is replaced with the value $Env:path ``` The order of evaluation of arguments is unspecified. @@ -290,11 +290,11 @@ Examples: New-Object 'int[,]' 3,2 New-Object -ArgumentList 3,2 -TypeName 'int[,]' -dir e:\PowerShell\Scripts\*statement*.ps1 | Foreach-Object {$_.Length} +dir E:\PowerShell\Scripts\*statement*.ps1 | ForEach-Object {$_.Length} -dir e:\PowerShell\Scripts\*.ps1 | +dir E:\PowerShell\Scripts\*.ps1 | Select-String -List "catch" | - Format-Table path,linenumber -AutoSize + Format-Table Path, LineNumber -AutoSize ``` ## 8.3 The if statement @@ -1013,7 +1013,7 @@ the `throw` statement. Examples: ```powershell -$a = new-object 'int[]' 10 +$a = New-Object 'int[]' 10 $i = 20 # out-of-bounds subscript while ($true) { @@ -1145,7 +1145,7 @@ data-name: simple-name data-commands-allowed: - new-lines~opt~ -supportedcommand data-commands-list + new-lines~opt~ -SupportedCommand data-commands-list data-commands-list: new-lines~opt~ data-command @@ -1176,7 +1176,7 @@ only: - Literals - Calls to the [ConvertFrom-StringData](xref:Microsoft.PowerShell.Utility.ConvertFrom-StringData) cmdlet -- Any other cmdlets identified via the **supportedcommand** parameter +- Any other cmdlets identified via the **SupportedCommand** parameter If the `ConvertFrom-StringData` cmdlet is used, the key/value pairs can be expressed using any form of string literal. However, *expandable-string-literal*s and *expandable-here-string-literal*s must @@ -1185,12 +1185,12 @@ not contain any variable substitutions or sub-expression expansions. Examples: The **SupportedCommand** parameter indicates that the given cmdlets or functions generate data only. -For example, the following data section includes a user-written cmdlet, `ConvertTo-XML`, which +For example, the following data section includes a user-written cmdlet, `ConvertTo-Xml`, which formats data in an XML file: ```powershell -data -supportedCommand ConvertTo-XML { - Format-XML -strings string1, string2, string3 +data -SupportedCommand ConvertTo-Xml { + Format-Xml -Strings string1, string2, string3 } ``` @@ -1199,7 +1199,7 @@ command that converts the strings into a hash table, whose value is assigned to ```powershell $messages = data { - ConvertFrom-StringData -stringdata @' + ConvertFrom-StringData -StringData @' Greeting = Hello Yes = yes No = no @@ -1215,7 +1215,7 @@ be created in separate files, with the following data sections: ```powershell $messages = data { - ConvertFrom-StringData -stringdata @" + ConvertFrom-StringData -StringData @" Greeting = Guten Tag Yes = ja No = nein @@ -1223,7 +1223,7 @@ $messages = data { } $messagesS = data { - ConvertFrom-StringData -stringdata @" + ConvertFrom-StringData -StringData @" Greeting = Buenos días Yes = sí No = no @@ -1331,17 +1331,17 @@ Windows Workflow Foundation engine. Consider the following definition for a function called `Get-Power`: ```powershell -function Get-Power ([long]$base, [int]$exponent) { +function Get-Power ([long]$Base, [int]$Exponent) { $result = 1 - for ($i = 1; $i -le $exponent; ++$i) { - $result *= $base + for ($i = 1; $i -le $Exponent; ++$i) { + $result *= $Base } return $result } ``` -This function has two parameters, `$base` and `$exponent`. It also contains a set of statements -that, for non-negative exponent values, computes `$base^$exponent^` and returns the result to +This function has two parameters, `$Base` and `$Exponent`. It also contains a set of statements +that, for non-negative exponent values, computes `$Base^$Exponent^` and returns the result to `Get-Power`'s caller. When a script, function, or filter begins execution, each parameter is initialized to its @@ -1378,10 +1378,10 @@ value is used to initialize *p* provided *p* is not bound to any arguments in th Consider the following function definition and calls: ```powershell -function Find-Str ([string]$str, [int]$start_pos = 0) { ... } +function Find-Str ([string]$Str, [int]$StartPos = 0) { ... } -Find-Str "abcabc" # 2nd argument omitted, 0 used for $start_pos -Find-Str "abcabc" 2 # 2nd argument present, so it is used for $start_pos +Find-Str "abcabc" # 2nd argument omitted, 0 used for $StartPos +Find-Str "abcabc" 2 # 2nd argument present, so it is used for $StartPos ``` ### 8.10.5 The [switch] type constraint @@ -1392,13 +1392,13 @@ the type switch. Type switch has two values, True and False. Consider the following function definition and calls: ```powershell -function Process ([switch]$trace, $p1, $p2) { ... } +function Process ([switch]$Trace, $P1, $P2) { ... } -Process 10 20 # $trace is False, $p1 is 10, $p2 is 20 -Process 10 -trace 20 # $trace is True, $p1 is 10, $p2 is 20 -Process 10 20 -trace # $trace is True, $p1 is 10, $p2 is 20 -Process 10 20 -trace:$false # $trace is False, $p1 is 10, $p2 is 20 -Process 10 20 -trace:$true # $trace is True, $p1 is 10, $p2 is 20 +Process 10 20 # $Trace is False, $P1 is 10, $P2 is 20 +Process 10 -Trace 20 # $Trace is True, $P1 is 10, $P2 is 20 +Process 10 20 -Trace # $Trace is True, $P1 is 10, $P2 is 20 +Process 10 20 -Trace:$false # $Trace is False, $P1 is 10, $P2 is 20 +Process 10 20 -Trace:$true # $Trace is True, $P1 is 10, $P2 is 20 ``` ### 8.10.6 Pipelines and functions @@ -1464,10 +1464,10 @@ registry drive. ```powershell function Sample { - Param ([String]$Name, [String]$Path) + param ([string]$Name, [string]$Path) dynamicparam { - if ($path -match "*HKLM*:") { - $dynParam1 = New-Object System.Management.Automation.RuntimeDefinedParameter("dp1", [Int32], $attributeCollection) + if ($Path -match "*HKLM*:") { + $dynParam1 = New-Object System.Management.Automation.RuntimeDefinedParameter("dp1", [int32], $attributeCollection) $attributes = New-Object System.Management.Automation.ParameterAttribute $attributes.ParameterSetName = 'pset1' @@ -1499,9 +1499,9 @@ A *param-block* provides an alternate way of declaring parameters. For example, of parameter declarations are equivalent: ```powershell -function FindStr1 ([string]$str, [int]$start_pos = 0) { ... } +function FindStr1 ([string]$Str, [int]$StartPos = 0) { ... } function FindStr2 { - param ([string]$str, [int]$start_pos = 0) ... + param ([string]$Str, [int]$StartPos = 0) ... } ``` @@ -1573,16 +1573,16 @@ corresponding parameter by position, with the first parameter having position ze Consider the following definition fragment for a function called `Get-Power`, and the calls to it: ```powershell -function Get-Power ([long]$base, [int]$exponent) { ... } +function Get-Power ([long]$Base, [int]$Exponent) { ... } -Get-Power 5 3 # argument 5 is bound to parameter $base in position 0 - # argument 3 is bound to parameter $exponent in position 1 +Get-Power 5 3 # argument 5 is bound to parameter $Base in position 0 + # argument 3 is bound to parameter $Exponent in position 1 # no conversion is needed, and the result is 5 to the power 3 Get-Power 4.7 3.2 # double argument 4.7 is rounded to int 5, double argument # 3.2 is rounded to int 3, and result is 5 to the power 3 -Get-Power 5 # $exponent has value $null, which is converted to int 0 +Get-Power 5 # $Exponent has value $null, which is converted to int 0 Get-Power # both parameters have value $null, which is converted to int 0 ``` @@ -1597,24 +1597,24 @@ designates the corresponding parameter. When choosing parameter names, avoid usi Consider the following calls to function `Get-Power`: ```powershell -Get-Power -base 5 -exponent 3 # -base designates $base, so 5 is - # bound to that, exponent designates - # $exponent, so 3 is bound to that +Get-Power -Base 5 -Exponent 3 # -Base designates $Base, so 5 is + # bound to that, -Exponent designates + # $Exponent, so 3 is bound to that -Get-Power -Exp 3 -BAs 5 # $base takes on 5 and $exponent takes on 3 +Get-Power -Exp 3 -Bas 5 # $Base takes on 5 and $Exponent takes on 3 -Get-Power -e 3 -b 5 # $base takes on 5 and $exponent takes on 3 +Get-Power -E 3 -B 5 # $Base takes on 5 and $Exponent takes on 3 ``` On the other hand, calls to the following function ```powershell -function Get-Hypot ([double]$side1, [double]$side2) { - return [Math]::Sqrt($side1 * $side1 + $side2 * $side2) +function Get-Hypot ([double]$Side1, [double]$Side2) { + return [Math]::Sqrt($Side1 * $Side1 + $Side2 * $Side2) } ``` -must use parameters `-side1` and `-side2`, as there is no prefix that uniquely designates the +must use parameters `-Side1` and `-Side2`, as there is no prefix that uniquely designates the parameter. The same parameter name cannot be used multiple times with or without different associated argument @@ -1654,11 +1654,11 @@ Positional parameters prefer to be bound without type conversion, if possible. F ```powershell function Test { - [CmdletBinding(DefaultParameterSetname = "SetB")] - param([Parameter(Position = 0, ParameterSetname = "SetA")] - [decimal]$dec, - [Parameter(Position = 0, ParameterSetname = "SetB")] - [int]$in + [CmdletBinding(DefaultParameterSetName = "SetB")] + param([Parameter(Position = 0, ParameterSetName = "SetA")] + [decimal]$Dec, + [Parameter(Position = 0, ParameterSetName = "SetB")] + [int]$In ) $PSCmdlet.ParameterSetName } diff --git a/reference/docs-conceptual/lang-spec/chapter-09.md b/reference/docs-conceptual/lang-spec/chapter-09.md index 35e0ff9ec221..0d3fb2e41d9c 100644 --- a/reference/docs-conceptual/lang-spec/chapter-09.md +++ b/reference/docs-conceptual/lang-spec/chapter-09.md @@ -226,14 +226,14 @@ elements from a collection. An array slice is created via the subscript operator ## 9.10 Copying an array A contiguous set of elements can be copied from one array to another using the method -`[Array]::Copy`. For example, +`[array]::Copy`. For example, ```powershell $a = [int[]](10,20,30) $b = [int[]](0,1,2,3,4,5) -[Array]::Copy($a, $b, 2) # $a[0]->$b[0], +[array]::Copy($a, $b, 2) # $a[0]->$b[0], $a[1]->$b[1] -[Array]::Copy($a, 1, $b, 3, 2) # $a[1]->$b[3], +[array]::Copy($a, 1, $b, 3, 2) # $a[1]->$b[3], $a[2]->$b[4] ``` diff --git a/reference/docs-conceptual/lang-spec/chapter-11.md b/reference/docs-conceptual/lang-spec/chapter-11.md index a1eb3802a708..73a88dc9ac25 100644 --- a/reference/docs-conceptual/lang-spec/chapter-11.md +++ b/reference/docs-conceptual/lang-spec/chapter-11.md @@ -77,7 +77,7 @@ environment variable PSModulePath points to a set of directories to be searched cmdlets look for modules whose names do not include a fully qualified path. Additional lookup paths can be provided; for example, -`$Env:PSModulepath = $Env:PSModulepath + ";"` +`$Env:PSModulePath = $Env:PSModulePath + ";"` Any additional paths added affect the current session only. @@ -221,40 +221,40 @@ A dynamic module can be used to create a *closure*, a function with attached dat following example: ```powershell -function Get-NextID ([int]$startValue = 1) { - $nextID = $startValue +function Get-NextID ([int]$StartValue = 1) { + $nextID = $StartValue { - ($script:nextID++) + ($Script:nextID++) }.GetNewClosure() } -$v1 = Get-NextID # get a scriptblock with $startValue of 0 +$v1 = Get-NextID # get a scriptblock with $StartValue of 0 & $v1 # invoke Get-NextID getting back 1 & $v1 # invoke Get-NextID getting back 2 -$v2 = Get-NextID 100 # get a scriptblock with $startValue of 100 +$v2 = Get-NextID 100 # get a scriptblock with $StartValue of 100 & $v2 # invoke Get-NextID getting back 100 & $v2 # invoke Get-NextID getting back 101 ``` The intent here is that `Get-NextID` return the next ID in a sequence whose start value can be -specified. However, multiple sequences must be supported, each with its own `$startValue` and +specified. However, multiple sequences must be supported, each with its own `$StartValue` and `$nextID` context. This is achieved by the call to the method `[scriptblock]::GetNewClosure` ([§4.3.7][§4.3.7]). Each time a new closure is created by `GetNewClosure`, a new dynamic module is created, and the variables in the caller's scope (in this case, the script block containing the increment) are copied into this new module. To ensure that the nextId defined inside the parent function (but outside the -script block) is incremented, the explicit script: scope prefix is needed. +script block) is incremented, the explicit Script: scope prefix is needed. Of course, the script block need not be a named function; for example: ```powershell -$v3 = & { # get a scriptblock with $startValue of 200 - param ([int]$startValue = 1) - $nextID = $startValue +$v3 = & { # get a scriptblock with $StartValue of 200 + param ([int]$StartValue = 1) + $nextID = $StartValue { - ($script:nextID++) + ($Script:nextID++) }.GetNewClosure() } 200 diff --git a/reference/docs-conceptual/lang-spec/chapter-12.md b/reference/docs-conceptual/lang-spec/chapter-12.md index 0f04a14309c7..4fa7d8e02d6d 100644 --- a/reference/docs-conceptual/lang-spec/chapter-12.md +++ b/reference/docs-conceptual/lang-spec/chapter-12.md @@ -87,15 +87,15 @@ Consider a function call `Test1` that has the following param block, and which i param ( [Parameter(Mandatory = $true)] [Alias("CN")] - [Alias("name", "system")] + [Alias("Name", "System")] [string[]] $ComputerName ) Test1 "Mars", "Saturn" # pass argument by position Test1 -ComputerName "Mars", "Saturn" # pass argument by name Test1 -CN "Mars", "Saturn" # pass argument using first alias -Test1 -name "Mars", "Saturn" # pass argument using second alias -Test1 -sys "Mars", "Saturn" # pass argument using third alias +Test1 -Name "Mars", "Saturn" # pass argument using second alias +Test1 -Sys "Mars", "Saturn" # pass argument using third alias ``` Consider a function call `Test2` that has the following param block, and which is called as shown: @@ -112,7 +112,7 @@ Get-ChildItem "E:\*.txt" | Test2 -LiteralPath { $_ ; "`n`t"; Get-ChildItem "E:\*.txt" | Test2 ``` -Cmdlet `Get-ChildItem` (alias `Dir`) adds to the object it returns a new **NoteProperty** of type +Cmdlet `Get-ChildItem` (alias `dir`) adds to the object it returns a new **NoteProperty** of type `string`, called **PSPath**. ### 12.3.2 The AllowEmptyCollection attribute @@ -124,14 +124,14 @@ Consider a function call `Test` that has the following param block, and which is ```powershell param ( - [parameter(Mandatory = $true)] + [Parameter(Mandatory = $true)] [AllowEmptyCollection()] [string[]] $ComputerName ) -Test "Red", "Green" # $computerName has Length 2 -Test "Red" # $computerName has Length 1 -Test -comp @() # $computerName has Length 0 +Test "Red", "Green" # $ComputerName has Length 2 +Test "Red" # $ComputerName has Length 1 +Test -Comp @() # $ComputerName has Length 0 ``` ### 12.3.3 The AllowEmptyString attribute @@ -143,14 +143,14 @@ Consider a function call `Test` that has the following param block, and which is ```powershell param ( - [parameter(Mandatory = $true)] + [Parameter(Mandatory = $true)] [AllowEmptyString()] [string] $ComputerName ) -Test "Red" # $computerName is "Red" +Test "Red" # $ComputerName is "Red" Test "" # empty string is permitted -Test -comp "" # empty string is permitted +Test -Comp "" # empty string is permitted ``` ### 12.3.4 The AllowNull attribute @@ -162,14 +162,14 @@ Consider a function call Test that has the following param block, and which is c ```powershell param ( - [parameter(Mandatory = $true)] + [Parameter(Mandatory = $true)] [AllowNull()] [int[]] $Values ) Test 10, 20, 30 # $values has Length 3, values 10, 20, 30 Test 10, $null, 30 # $values has Length 3, values 10, 0, 30 -Test -val $null # $values has value $null +Test -Val $null # $values has value $null ``` Note that the second case above does not need this attribute; there is already an implicit @@ -362,8 +362,8 @@ ValueFromPipeline=$true)]

This argument specifies whether the parameter takes its value from a property of a pipeline object that has either the same name or the same alias as this parameter. A value of $true indicates that it does. A value of $false indicates that it does not.

Specify $true if the following conditions are true: the parameter accesses a property of the piped object, and the property has the same name as the parameter, or the property has the same alias as the parameter.

A parameter having ValueFromPipelineByPropertyName set to $true need not have a parameter in the same set with ValueFromPipeline set to $true.

-

If a function has a parameter $ComputerName, and the piped object has a ComputerName property, the value of the ComputerName property is assigned to the $ComputerName parameter of the function:

-

param ( [parameter(Mandatory = $true,
+

If a function has a parameter $ComputerName, and the piped object has a ComputerName property, the value of the ComputerName property is assigned to the $ComputerName parameter of the Function:

+

param ( [Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[string[]] $ComputerName )

Multiple parameters in a parameter set can define the ValueFromPipelineByPropertyName as $true. Although, a single input object cannot be bound to multiple parameters, different properties in that input object may be bound to different parameters.

@@ -387,13 +387,13 @@ Get-Date | Process-Date

+

The following example shows a parameter $Others that accepts all the remaining arguments of the input object that is passed to the function Test:

+

param ( [Parameter(Mandatory = $true)][int] $p1,
+[Parameter(Mandatory = $true)][int] $p2,
+[Parameter(ValueFromRemainingArguments = $true)]
+[string[]] $Others )

+

Test 10 20 # $Others has Length 0
+Test 10 20 30 40 # $Others has Length 2, value 30,40

ValueFromRemainingArguments (named)

Type: bool; Default value: $false

This argument specifies whether the parameter accepts all of the remaining arguments that are not bound to the parameters of the function. A value of $true indicates that it does. A value of $false indicates that it does not.

-

The following example shows a parameter $others that accepts all the remaining arguments of the input object that is passed to the function Test:

-

param ( [parameter(Mandatory = $true)][int] $p1,
-[parameter(Mandatory = $true)][int] $p2,
-[parameter(ValueFromRemainingArguments = $true)]
-[string[]] $others )

-

Test 10 20 # $others has Length 0
-Test 10 20 30 40 # $others has Length 2, value 30,40

@@ -523,7 +523,7 @@ In the absence of this attribute, the parameter's corresponding argument can be Consider a function call Test that has the following param block, and which is called as shown: ```powershell -param ( [parameter(Mandatory = $true)] +param ( [Parameter(Mandatory = $true)] [ValidateLength(3,6)] [string[]] $ComputerName ) @@ -621,16 +621,16 @@ param ( [int] $Minimum ) -Test -c A12 # matches pattern -Test -c A63 # does not match pattern +Test -C A12 # matches pattern +Test -C A63 # does not match pattern -Test -h 0x4f # matches pattern -Test -h "0XB2" # matches pattern -Test -h 0xK3 # does not match pattern +Test -H 0x4f # matches pattern +Test -H "0XB2" # matches pattern +Test -H 0xK3 # does not match pattern -Test -m -4 # matches pattern -Test -m "+7" # matches pattern -Test -m -12 # matches pattern, but is too long +Test -M -4 # matches pattern +Test -M "+7" # matches pattern +Test -M -12 # matches pattern, but is too long [ValidatePattern('\^[a-z][a-z0-9]\*$')]$ident = "abc" $ident = "123" # does not match pattern @@ -669,13 +669,13 @@ Consider a function call `Test1` that has the following param block, and which i ```powershell param ( - [parameter(Mandatory = $true)] + [Parameter(Mandatory = $true)] [ValidateRange(1, 10)] [int] $StartValue ) Test1 2 -Test1 -st 7 +Test1 -St 7 Test1 -3 # value is too small Test1 12 # value is too large ``` @@ -684,7 +684,7 @@ Consider a function call Test2 that has the following param block and calls: ```powershell param ( - [parameter(Mandatory = $true)] + [Parameter(Mandatory = $true)] [ValidateRange("b", "f")] [string] $Name ) @@ -698,7 +698,7 @@ Consider a function call `Test3` that has the following param block, and which i ```powershell param ( - [parameter(Mandatory = $true)] + [Parameter(Mandatory = $true)] [ValidateRange(0.002, 0.003)] [double] $Distance ) @@ -778,11 +778,11 @@ param ( [ValidateSet("Red", "Green", "Blue")] ) -Test -col "RED" # case is ignored, is a member of the set -Test -col "white" # case is ignored, is not a member of the set +Test -Col "RED" # case is ignored, is a member of the set +Test -Col "white" # case is ignored, is not a member of the set -Test -dir "up" # case is not ignored, is a member of the set -Test -dir "Up" # case is not ignored, is not a member of the set +Test -Dir "up" # case is not ignored, is a member of the set +Test -Dir "Up" # case is not ignored, is not a member of the set [ValidateSet(("Red", "Green", "Blue")]$color = "RED" # ok, case is ignored $color = "Purple" # case is ignored, is not a member of the set diff --git a/reference/docs-conceptual/lang-spec/chapter-13.md b/reference/docs-conceptual/lang-spec/chapter-13.md index b5d08b24aa20..36015c009d80 100644 --- a/reference/docs-conceptual/lang-spec/chapter-13.md +++ b/reference/docs-conceptual/lang-spec/chapter-13.md @@ -19,7 +19,7 @@ specified destination. For each cmdlet, provide a help file that can be accessed by typing: -`get-help *cmdlet-name* -detailed` +`Get-Help *cmdlet-name* -Detailed` The detailed view of the cmdlet help file should include a description of the cmdlet, the command syntax, descriptions of the parameters, and an example that demonstrate the use of that cmdlet. diff --git a/reference/docs-conceptual/lang-spec/chapter-14.md b/reference/docs-conceptual/lang-spec/chapter-14.md index d9bf6163f916..503ecae0b865 100644 --- a/reference/docs-conceptual/lang-spec/chapter-14.md +++ b/reference/docs-conceptual/lang-spec/chapter-14.md @@ -140,7 +140,7 @@ Examples: ```powershell <# -.ExternalHelp C:\MyScripts\Update-Month-Help.xml +.EXTERNALHELP C:\MyScripts\Update-Month-Help.xml #> ``` @@ -220,7 +220,7 @@ is added to the item. function Process-Thing { param ( ... [Parameter(ValueFromPipeline=$true)] - [object[]]$Value, + [Object[]]$Value, ... ) ... @@ -275,7 +275,7 @@ Examples: ```powershell <# -.Notes +.NOTES *arbitrary text goes here* #> ``` diff --git a/reference/docs-conceptual/lang-spec/chapter-15.md b/reference/docs-conceptual/lang-spec/chapter-15.md index 8af7d22556f2..f993a338d855 100644 --- a/reference/docs-conceptual/lang-spec/chapter-15.md +++ b/reference/docs-conceptual/lang-spec/chapter-15.md @@ -73,7 +73,7 @@ input-character: Any Unicode character except a new-line-character requires-comment: - #requires whitespace command-arguments + #Requires whitespace command-arguments dash: - (U+002D) @@ -161,12 +161,12 @@ braced-variable: ${ variable-scope~opt~ braced-variable-characters } variable-scope: - global: - local: - private: - script: - using: - workflow: + Global: + Local: + Private: + Script: + Using: + Workflow: variable-namespace variable-namespace: @@ -777,7 +777,7 @@ data-name: simple-name data-commands-allowed: - new-lines~opt~ -supportedcommand data-commands-list + new-lines~opt~ -SupportedCommand data-commands-list data-commands-list: new-lines~opt~ data-command diff --git a/reference/docs-conceptual/learn/deep-dives/add-credentials-to-powershell-functions.md b/reference/docs-conceptual/learn/deep-dives/add-credentials-to-powershell-functions.md index 5a0051774228..e55629dce82d 100644 --- a/reference/docs-conceptual/learn/deep-dives/add-credentials-to-powershell-functions.md +++ b/reference/docs-conceptual/learn/deep-dives/add-credentials-to-powershell-functions.md @@ -125,7 +125,7 @@ function Set-RemoteRegistryValue { $Credential = [System.Management.Automation.PSCredential]::Empty ) $null = Invoke-Command -ComputerName $ComputerName -ScriptBlock { - Set-ItemProperty -Path $using:Path -Name $using:Name -Value $using:Value + Set-ItemProperty -Path $Using:Path -Name $Using:Name -Value $Using:Value } -Credential $Credential } ``` @@ -134,15 +134,15 @@ The following sections show different methods of providing credentials to `Set-R ### Prompting for credentials -Using `Get-Credential` in parentheses `()` at run time causes the `Get-credential` to run first. You +Using `Get-Credential` in parentheses `()` at run time causes the `Get-Credential` to run first. You are prompted for a username and password. You could use the **Credential** or **UserName** -parameters of `Get-credential` to pre-populate the username and domain. The following example uses a +parameters of `Get-Credential` to pre-populate the username and domain. The following example uses a technique called splatting to pass parameters to the `Set-RemoteRegistryValue` function. For more information about splatting, check out the [about_Splatting][about_Splatting] article. ```powershell $remoteKeyParams = @{ - ComputerName = $env:COMPUTERNAME + ComputerName = $Env:COMPUTERNAME Path = 'HKLM:\SOFTWARE\Microsoft\WebManagement\Server' Name = 'EnableRemoteManagement' Value = '1' @@ -159,7 +159,7 @@ only a username, the cmdlet automatically prompts for the password. The ```powershell $remoteKeyParams = @{ - ComputerName = $env:COMPUTERNAME + ComputerName = $Env:COMPUTERNAME Path = 'HKLM:\SOFTWARE\Microsoft\WebManagement\Server' Name = 'EnableRemoteManagement' Value = '1' @@ -191,7 +191,7 @@ $password = ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force $Cred = New-Object System.Management.Automation.PSCredential ("duffney", $password) $remoteKeyParams = @{ - ComputerName = $env:COMPUTERNAME + ComputerName = $Env:COMPUTERNAME Path = 'HKLM:\SOFTWARE\Microsoft\WebManagement\Server' Name = 'EnableRemoteManagement' Value = '1' @@ -212,7 +212,7 @@ credentials, as shown in this example: ```powershell $remoteKeyParams = @{ - ComputerName = $env:COMPUTERNAME + ComputerName = $Env:COMPUTERNAME Path = 'HKLM:\SOFTWARE\Microsoft\WebManagement\Server' Name = 'EnableRemoteManagement' Value = '1' @@ -247,11 +247,11 @@ function Set-RemoteRegistryValue { if($Credential -ne [System.Management.Automation.PSCredential]::Empty) { Invoke-Command -ComputerName:$ComputerName -Credential:$Credential { - Set-ItemProperty -Path $using:Path -Name $using:Name -Value $using:Value + Set-ItemProperty -Path $Using:Path -Name $Using:Name -Value $Using:Value } } else { Invoke-Command -ComputerName:$ComputerName { - Set-ItemProperty -Path $using:Path -Name $using:Name -Value $using:Value + Set-ItemProperty -Path $Using:Path -Name $Using:Name -Value $Using:Value } } } @@ -286,7 +286,7 @@ function Set-RemoteRegistryValue { } $null = Invoke-Command -ScriptBlock { - Set-ItemProperty -Path $using:Path -Name $using:Name -Value $using:Value + Set-ItemProperty -Path $Using:Path -Name $Using:Name -Value $Using:Value } @splat } ``` diff --git a/reference/docs-conceptual/learn/deep-dives/everything-about-arrays.md b/reference/docs-conceptual/learn/deep-dives/everything-about-arrays.md index 302b926ab45c..3f8d28a30ebf 100644 --- a/reference/docs-conceptual/learn/deep-dives/everything-about-arrays.md +++ b/reference/docs-conceptual/learn/deep-dives/everything-about-arrays.md @@ -37,7 +37,7 @@ An empty array can be created by using `@()` ```powershell PS> $data = @() -PS> $data.count +PS> $data.Count 0 ``` @@ -45,7 +45,7 @@ We can create an array and seed it with values just by placing them in the `@()` ```powershell PS> $data = @('Zero','One','Two','Three') -PS> $data.count +PS> $data.Count 4 PS> $data @@ -231,26 +231,26 @@ So make sure your arrays are not `$null` before you try to access elements insid #### Count -Arrays and other collections have a count property that tells you how many items are in the array. +Arrays and other collections have a `Count` property that tells you how many items are in the array. ```powershell -PS> $data.count +PS> $data.Count 4 ``` -PowerShell 3.0 added a count property to most objects. you can have a single object and it should +PowerShell 3.0 added a `Count` property to most objects. you can have a single object and it should give you a count of `1`. ```powershell PS> $date = Get-Date -PS> $date.count +PS> $date.Count 1 ``` -Even `$null` has a count property except it returns `0`. +Even `$null` has a `Count` property except it returns `0`. ```powershell -PS> $null.count +PS> $null.Count 0 ``` @@ -267,14 +267,14 @@ the third item. Or by thinking that you have four items and you want last item, to access the last item. ```powershell -$data[ $data.count ] +$data[ $data.Count ] ``` PowerShell is perfectly happy to let you do that and give you exactly what item exists at index 4: -`$null`. You should be using `$data.count - 1` or the `-1` that we learned about above. +`$null`. You should be using `$data.Count - 1` or the `-1` that we learned about above. ```powershell -PS> $data[ $data.count - 1 ] +PS> $data[ $data.Count - 1 ] Three ``` @@ -348,7 +348,7 @@ one because they both represent the current object in the pipeline. #### ForEach loop -The `ForEach` loop works well with collections. Using the syntax: +The `foreach` loop works well with collections. Using the syntax: `foreach ( in )` ```powershell @@ -361,24 +361,24 @@ foreach ( $node in $data ) #### ForEach method I tend to forget about this one but it works well for simple operations. PowerShell allows you to -call `.ForEach()` on a collection. +call `ForEach()` on a collection. ```powershell -PS> $data.foreach({"Item [$PSItem]"}) +PS> $data.ForEach({"Item [$PSItem]"}) Item [Zero] Item [One] Item [Two] Item [Three] ``` -The `.foreach()` takes a parameter that is a script block. You can drop the parentheses and just +The `ForEach()` takes a parameter that is a script block. You can drop the parentheses and just provide the script block. ```powershell -$data.foreach{"Item [$PSItem]"} +$data.ForEach{"Item [$PSItem]"} ``` -This is a lesser known syntax but it works just the same. This `foreach` method was added in +This is a lesser known syntax but it works just the same. This `ForEach` method was added in PowerShell 4.0. #### For loop @@ -387,20 +387,20 @@ The `for` loop is used heavily in most other languages but you don't see it much you do see it, it's often in the context of walking an array. ```powershell -for ( $index = 0; $index -lt $data.count; $index++) +for ( $index = 0; $index -lt $data.Count; $index++) { "Item: [{0}]" -f $data[$index] } ``` The first thing we do is initialize an `$index` to `0`. Then we add the condition that `$index` must -be less than `$data.count`. Finally, we specify that every time we loop that we must increase the +be less than `$data.Count`. Finally, we specify that every time we loop that we must increase the index by `1`. In this case `$index++` is short for `$index = $index + 1`. The [format operator][03] (`-f`) is used to insert the value of `$data[$index]` in the output string. Whenever you're using a `for` loop, pay special attention to the condition. I used -`$index -lt $data.count` here. It's easy to get the condition slightly wrong to get an off-by-one -error in your logic. Using `$index -le $data.count` or `$index -lt ($data.count - 1)` are ever so +`$index -lt $data.Count` here. It's easy to get the condition slightly wrong to get an off-by-one +error in your logic. Using `$index -le $data.Count` or `$index -lt ($data.Count - 1)` are ever so slightly wrong. That would cause your result to process too many or too few items. This is the classic off-by-one error. @@ -451,7 +451,7 @@ The exception to that statement is the `for` loop. If you want to walk an array inside it, then the `for` loop is what you're looking for. ```powershell -for ( $index = 0; $index -lt $data.count; $index++ ) +for ( $index = 0; $index -lt $data.Count; $index++ ) { $data[$index] = "Item: [{0}]" -f $data[$index] } @@ -556,7 +556,7 @@ Kevin Marquette We can write that same query to get the `FirstName` we are looking for. ```powershell -$data | Where FirstName -eq Kevin +$data | where FirstName -EQ Kevin ``` #### Where() @@ -805,19 +805,19 @@ A `$null` array isn't the same thing as an empty array. If you know you have an count of objects in it. If the array is `$null`, the count is `0`. ```powershell -if ( $array.count -gt 0 ) +if ( $array.Count -gt 0 ) { "Array isn't empty" } ``` -There is one more trap to watch out for here. You can use the `count` even if you have a single +There is one more trap to watch out for here. You can use the `Count` even if you have a single object, unless that object is a `PSCustomObject`. This is a bug that is fixed in PowerShell 6.1. That's good news, but a lot of people are still on 5.1 and need to watch out for it. ```powershell -PS> $object = [PSCustomObject]@{Name='TestObject'} -PS> $object.count +PS> $object = [pscustomobject]@{Name='TestObject'} +PS> $object.Count $null ``` @@ -825,7 +825,7 @@ If you're still on PowerShell 5.1, you can wrap the object in an array before ch get an accurate count. ```powershell -if ( @($array).count -gt 0 ) +if ( @($array).Count -gt 0 ) { "Array isn't empty" } @@ -834,7 +834,7 @@ if ( @($array).count -gt 0 ) To fully play it safe, check for `$null`, then check the count. ```powershell -if ( $null -ne $array -and @($array).count -gt 0 ) +if ( $null -ne $array -and @($array).Count -gt 0 ) { "Array isn't empty" } @@ -933,7 +933,7 @@ $array = foreach ( $node in (1..5)) ## Array Types -By default, an array in PowerShell is created as a `[PSObject[]]` type. This allows it to contain +By default, an array in PowerShell is created as a `[psobject[]]` type. This allows it to contain any type of object or value. This works because everything is inherited from the `PSObject` type. ### Strongly typed arrays @@ -1027,13 +1027,13 @@ PS> $myList[-1] 10 ``` -#### List[PSObject] +#### List[psobject] You can have a list of any type, but when you don't know the type of objects, you can use -`[List[PSObject]]` to contain them. +`[List[psobject]]` to contain them. ```powershell -$list = [List[PSObject]]::new() +$list = [List[psobject]]::new() ``` #### Remove() @@ -1054,13 +1054,13 @@ again to keep removing that value. If you have reference types, you have to prov you want removed. ```powershell -[list[System.Management.Automation.PSDriveInfo]]$drives = Get-PSDrive -$drives.remove($drives[2]) +[List[System.Management.Automation.PSDriveInfo]]$drives = Get-PSDrive +$drives.Remove($drives[2]) ``` ```powershell $delete = $drives[2] -$drives.remove($delete) +$drives.Remove($delete) ``` The remove method returns `true` if it was able to find and remove the item from the collection. @@ -1083,7 +1083,7 @@ a pre-determined size by calling it with the `new($size)` constructor. ```powershell $data = [Object[]]::new(4) -$data.count +$data.Count 4 ``` diff --git a/reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md b/reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md index 8b1365797b3b..72103e2d13fa 100644 --- a/reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md +++ b/reference/docs-conceptual/learn/deep-dives/everything-about-exceptions.md @@ -148,7 +148,7 @@ happens or not. A `finally` script does exactly that. Take a look at this example: ```powershell -$command = [System.Data.SqlClient.SqlCommand]::New(queryString, connection) +$command = [System.Data.SqlClient.SqlCommand]::new(queryString, connection) $command.Connection.Open() $command.ExecuteNonQuery() $command.Connection.Close() @@ -158,7 +158,7 @@ Anytime you open or connect to a resource, you should close it. If the `ExecuteN exception, the connection isn't closed. Here is the same code inside a `try/finally` block. ```powershell -$command = [System.Data.SqlClient.SqlCommand]::New(queryString, connection) +$command = [System.Data.SqlClient.SqlCommand]::new(queryString, connection) try { $command.Connection.Open() @@ -304,7 +304,7 @@ at CallSite.Target(Closure , CallSite , Type , String ) ``` You only get this stack trace when the event is thrown from managed code. I'm calling a .NET -framework function directly so that is all we can see in this example. Generally when you're looking +Framework function directly so that is all we can see in this example. Generally when you're looking at a stack trace, you're looking for where your code stops and the system calls begin. ## Working with exceptions diff --git a/reference/docs-conceptual/learn/deep-dives/everything-about-hashtable.md b/reference/docs-conceptual/learn/deep-dives/everything-about-hashtable.md index 6b14315f0e11..756aeaf39f30 100644 --- a/reference/docs-conceptual/learn/deep-dives/everything-about-hashtable.md +++ b/reference/docs-conceptual/learn/deep-dives/everything-about-hashtable.md @@ -70,9 +70,9 @@ using a key like this: ```powershell $key = 'Kevin' $value = 36 -$ageList.add( $key, $value ) +$ageList.Add( $key, $value ) -$ageList.add( 'Alex', 9 ) +$ageList.Add( 'Alex', 9 ) ``` The person's name is the key and their age is the value that I want to save. @@ -88,7 +88,7 @@ $ageList['Alex'] ``` When I want Kevin's age, I use his name to access it. We can use this approach to add or update -values into the hashtable too. This is just like using the `add()` function above. +values into the hashtable too. This is just like using the `Add()` method above. ```powershell $ageList = @{} @@ -168,17 +168,17 @@ PS> $ageList | Measure-Object count : 1 ``` -Even though the `.count` property tells you how many values it contains. +Even though the `Count` property tells you how many values it contains. ```powershell -PS> $ageList.count +PS> $ageList.Count 2 ``` -You get around this issue by using the `.values` property if all you need is just the values. +You get around this issue by using the `Values` property if all you need is just the values. ```powershell -PS> $ageList.values | Measure-Object -Average +PS> $ageList.Values | Measure-Object -Average Count : 2 Average : 22.5 ``` @@ -186,7 +186,7 @@ Average : 22.5 It's often more useful to enumerate the keys and use them to access the values. ```powershell -PS> $ageList.keys | ForEach-Object{ +PS> $ageList.Keys | ForEach-Object{ $message = '{0} is {1} years old!' -f $_, $ageList[$_] Write-Output $message } @@ -197,7 +197,7 @@ Alex is 9 years old Here is the same example with a `foreach(){...}` loop. ```powershell -foreach($key in $ageList.keys) +foreach($key in $ageList.Keys) { $message = '{0} is {1} years old' -f $key, $ageList[$key] Write-Output $message @@ -213,7 +213,7 @@ That brings us to `GetEnumerator()` for iterating over our hashtable. ```powershell $ageList.GetEnumerator() | ForEach-Object{ - $message = '{0} is {1} years old!' -f $_.key, $_.value + $message = '{0} is {1} years old!' -f $_.Key, $_.Value Write-Output $message } ``` @@ -252,7 +252,7 @@ enumeration operation may not execute. This will also fail even though it looks like it should also be fine: ```powershell -foreach($key in $environments.keys) { +foreach($key in $environments.Keys) { $environments[$key] = 'SrvDev03' } @@ -327,7 +327,7 @@ if( $person.age -ne $null ){...} ``` This works around that issue for zero values but not $null vs non-existent keys. Most of the time -you don't need to make that distinction but there are functions for when you do. +you don't need to make that distinction but there are methods for when you do. ```powershell if( $person.ContainsKey('age') ){...} @@ -338,10 +338,10 @@ knowing the key or iterating the whole collection. ### Removing and clearing keys -You can remove keys with the `.Remove()` function. +You can remove keys with the `Remove()` method. ```powershell -$person.remove('age') +$person.Remove('age') ``` Assigning them a `$null` value just leaves you with a key that has a `$null` value. @@ -352,13 +352,13 @@ A common way to clear a hashtable is to just initialize it to an empty hashtable $person = @{} ``` -While that does work, try to use the `clear()` function instead. +While that does work, try to use the `Clear()` method instead. ```powershell -$person.clear() +$person.Clear() ``` -This is one of those instances where using the function creates self-documenting code and it makes +This is one of those instances where using the method creates self-documenting code and it makes the intentions of the code very clean. ## All the fun stuff @@ -397,28 +397,28 @@ special syntax that looks like this when fully expanded. ```powershell $property = @{ - name = 'totalSpaceGB' - expression = { ($_.used + $_.free) / 1GB } + Name = 'TotalSpaceGB' + Expression = { ($_.Used + $_.Free) / 1GB } } ``` -The `name` is what the cmdlet would label that column. The `expression` is a script block that is +The `Name` is what the cmdlet would label that column. The `Expression` is a script block that is executed where `$_` is the value of the object on the pipe. Here is that script in action: ```powershell -$drives = Get-PSDrive | Where Used -$drives | Select-Object -Property name, $property +$drives = Get-PSDrive | where Used +$drives | Select-Object -Property Name, $property -Name totalSpaceGB +Name TotalSpaceGB ---- ------------ C 238.472652435303 ``` -I placed that in a variable but it could easily be defined inline and you can shorten `name` to `n` -and `expression` to `e` while you're at it. +I placed that in a variable but it could easily be defined inline and you can shorten `Name` to `n` +and `Expression` to `e` while you're at it. ```powershell -$drives | Select-Object -property name, @{n='totalSpaceGB';e={($_.used + $_.free) / 1GB}} +$drives | Select-Object -Property Name, @{n='TotalSpaceGB';e={($_.Used + $_.Free) / 1GB}} ``` I personally don't like how long that makes commands and it often promotes some bad behaviors that I @@ -498,12 +498,12 @@ hashtable. ### Splatting for optional parameters One of the most common ways I use splatting is to deal with optional parameters that come from -some place else in my script. Let's say I have a function that wraps a `Get-CIMInstance` call that +some place else in my script. Let's say I have a function that wraps a `Get-CimInstance` call that has an optional `$Credential` argument. ```powershell $CIMParams = @{ - ClassName = 'Win32_Bios' + ClassName = 'Win32_BIOS' ComputerName = $ComputerName } @@ -512,11 +512,11 @@ if($Credential) $CIMParams.Credential = $Credential } -Get-CIMInstance @CIMParams +Get-CimInstance @CIMParams ``` I start by creating my hashtable with common parameters. Then I add the `$Credential` if it exists. -Because I'm using splatting here, I only need to have the call to `Get-CIMInstance` in my code +Because I'm using splatting here, I only need to have the call to `Get-CimInstance` in my code once. This design pattern is very clean and can handle lots of optional parameters easily. To be fair, you could write your commands to allow `$null` values for parameters. You just don't @@ -648,7 +648,7 @@ defined statically in my code and I know them off the top of my head. If I need programmatically access the keys, I use the brackets to provide the key name. ```powershell -foreach($name in $people.keys) +foreach($name in $people.Keys) { $person = $people[$name] '{0}, age {1}, is in {2}' -f $name, $person.age, $person.city @@ -671,7 +671,7 @@ Kevin {age, city} Alex {age, city} ``` -My go to command for looking at these things is `ConvertTo-JSON` because it's very clean and I +My go to command for looking at these things is `ConvertTo-Json` because it's very clean and I frequently use JSON on other things. ```powershell @@ -739,7 +739,7 @@ if you start with a `pscustomobject` so the column order is preserved. But you c `pscustomobject` inline if needed. ```powershell -$person | ForEach-Object{ [pscustomobject]$_ } | Export-CSV -Path $path +$person | ForEach-Object{ [pscustomobject]$_ } | Export-Csv -Path $path ``` Again, check out my write-up on using a [pscustomobject][pscustomobject]. @@ -750,8 +750,8 @@ If I need to save a nested hashtable to a file and then read it back in again, I cmdlets to do it. ```powershell -$people | ConvertTo-JSON | Set-Content -Path $path -$people = Get-Content -Path $path -Raw | ConvertFrom-JSON +$people | ConvertTo-Json | Set-Content -Path $path +$people = Get-Content -Path $path -Raw | ConvertFrom-Json ``` There are two important points about this method. First is that the JSON is written out multiline so @@ -831,7 +831,7 @@ $hashtable = ( & $scriptBlock ) It imports the contents of the file into a `scriptblock`, then checks to make sure it doesn't have any other PowerShell commands in it before it executes it. -On that note, did you know that a module manifest (the psd1 file) is just a hashtable? +On that note, did you know that a module manifest (the `.psd1` file) is just a hashtable? ## Keys can be any object @@ -872,7 +872,7 @@ Name Value Accessing a value in the hashtable by its key doesn't always work. For example: ```powershell -$key = $ht.keys[0] +$key = $ht.Keys[0] $ht.$($key) a $ht[$key] @@ -968,7 +968,7 @@ One little known feature of `Group-Object` is that it can turn some datasets int you. ```powershell -Import-CSV $Path | Group-Object -AsHashtable -Property email +Import-Csv $Path | Group-Object -AsHashtable -Property Email ``` This will add each row into a hashtable and use the specified property as the key to access it. @@ -1000,7 +1000,7 @@ make changes to that hashtable, your original is also altered. ### Shallow copies, single level -If we have a simple hashtable like our example above, we can use `.Clone()` to make a shallow copy. +If we have a simple hashtable like our example above, we can use `Clone()` to make a shallow copy. ```powershell PS> $orig = @{name='orig'} @@ -1055,7 +1055,7 @@ function Get-DeepClone { if($InputObject -is [hashtable]) { $clone = @{} - foreach($key in $InputObject.keys) + foreach($key in $InputObject.Keys) { $clone[$key] = Get-DeepClone $InputObject[$key] } @@ -1069,7 +1069,7 @@ function Get-DeepClone It doesn't handle any other reference types or arrays, but it's a good starting point. -Another way is to use .Net to deserialize it using **CliXml** like in this function: +Another way is to use .NET to deserialize it using **CliXml** like in this function: ```powershell function Get-DeepClone