diff --git a/dsc/authoringResourceComposite.md b/dsc/authoringResourceComposite.md index fb936948d7b8..d80c6983b814 100644 --- a/dsc/authoringResourceComposite.md +++ b/dsc/authoringResourceComposite.md @@ -94,7 +94,7 @@ Configuration xVirtualMachine DependsOn = "[File]ParentVHDFile" } - # Creae VM specific diff VHD + # Create VM specific diff VHD foreach ($Name in $VMName) { xVHD "VHD$Name" diff --git a/dsc/configurations.md b/dsc/configurations.md index 814b9e0011a5..e6bc1148b6a2 100644 --- a/dsc/configurations.md +++ b/dsc/configurations.md @@ -28,7 +28,6 @@ Configuration MyDscConfiguration { } } -MyDscConfiguration ``` Save the script as a .ps1 file. @@ -62,7 +61,6 @@ Configuration MyDscConfiguration { } } -MyDscConfiguration ``` In this example, you specify the name of the node by passing it as the **ComputerName** parameter when you compile the configuraton. The name defaults to "localhost". @@ -99,7 +97,7 @@ MyDscConfiguration Directory: C:\users\default\Documents\DSC Configurations\MyDscConfiguration Mode LastWriteTime Length Name ---- ------------- ------ ---- --a---- 10/23/2015 4:32 PM 2842 TEST-PC1.mof +-a---- 10/23/2015 4:32 PM 2842 localhost.mof ``` If the configuration takes a parameter, as in the second example, that has to be provided at compile time. Here's how that would look: @@ -140,7 +138,6 @@ Configuration DependsOnExample { } } -DependsOnExample ``` ## Using new resources in Your configuration diff --git a/dsc/dscCiCd.md b/dsc/dscCiCd.md index 53c40ad7f7da..37e2fbe01912 100644 --- a/dsc/dscCiCd.md +++ b/dsc/dscCiCd.md @@ -375,7 +375,7 @@ and stores the results in the `InfraDNS/Tests/Results/*.xml` folder. **\Integration\** ``` -1. Set **TargetFolder** to `$(BuildArtifactStagingDirectory)\` +1. Set **TargetFolder** to `$(Build.ArtifactStagingDirectory)\` This step copies the build and test scripts to the staging directory so that the can be published as build artifacts by the next step. diff --git a/dsc/separatingEnvData.md b/dsc/separatingEnvData.md index 8ff944f4b73c..cb229942ea49 100644 --- a/dsc/separatingEnvData.md +++ b/dsc/separatingEnvData.md @@ -104,6 +104,7 @@ We'll define the development and production environment data in a file namd `Dev SQLServerName = "MySQLServer" SqlSource = "C:\Software\Sql" DotNetSrc = "C:\Software\sxs" + WebSiteName = "New website" }, @{ @@ -218,7 +219,7 @@ Configuration MyWebApp { Ensure = 'Present' - Name = $WebSiteName + Name = $Node.WebSiteName State = 'Started' PhysicalPath = $Node.SitePath DependsOn = '[File]WebContent' diff --git a/reference/3.0/Microsoft.PowerShell.Core/About/about_Transactions.md b/reference/3.0/Microsoft.PowerShell.Core/About/about_Transactions.md index ec1627dacb25..e93860f24d7f 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/About/about_Transactions.md +++ b/reference/3.0/Microsoft.PowerShell.Core/About/about_Transactions.md @@ -579,7 +579,7 @@ $t.tostring() Windows PowerShell -# EXAMPLE 7: MANAGING MULTI-SUBSCRIBER TRANSACTIONS +# EXAMPLE 8: MANAGING MULTI-SUBSCRIBER TRANSACTIONS When you start a transaction while another transaction is in @@ -663,7 +663,7 @@ RollbackPreference SubscriberCount Status ------------------ --------------- ------ Error 0 Committed -# EXAMPLE 8: MANAGING INDEPENDENT TRANSACTIONS +# EXAMPLE 9: MANAGING INDEPENDENT TRANSACTIONS When you start a transaction while another transaction is in diff --git a/reference/3.0/Microsoft.PowerShell.Core/Get-Help.md b/reference/3.0/Microsoft.PowerShell.Core/Get-Help.md index 7039374759c2..0b102d43b26e 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/Get-Help.md +++ b/reference/3.0/Microsoft.PowerShell.Core/Get-Help.md @@ -219,7 +219,7 @@ PS C:\> Get-Help Get-Member -Online ``` This command displays the online version of the help topic for the Get-Member cmdlet. -### Example 14 +### Example 12 ``` PS C:\> Get-Help remoting ``` @@ -227,7 +227,7 @@ PS C:\> Get-Help remoting This command displays a list of topics that include the word "remoting." When you enter a word that does not appear in any topic title, **Get-Help** displays a list of topics that include that word. -### Example 15 +### Example 13 ``` The first command uses the **Path** parameter of **Get-Help** to specify the provider path. This command can be entered at any path location. PS C:\> Get-Help Get-Item -Path SQLSERVER:\DataCollection @@ -282,7 +282,7 @@ The example shows two ways of getting the provider-specific help for **Get-Item* You can also get provider-specific help for cmdlets online in the section that describes the provider. For example, for provider-specific online help for the New-Item cmdlet in each WSMan provider path, see http://go.microsoft.com/fwlink/?LinkID=158676http://go.microsoft.com/fwlink/?LinkID=158676. -### Example 16 +### Example 14 ``` PS C:\> Get-Help C:\PS-Test\MyScript.ps1 ``` diff --git a/reference/3.0/Microsoft.PowerShell.Core/Import-Module.md b/reference/3.0/Microsoft.PowerShell.Core/Import-Module.md index 42b005fc741c..a4440b82e3c4 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/Import-Module.md +++ b/reference/3.0/Microsoft.PowerShell.Core/Import-Module.md @@ -322,7 +322,7 @@ This command imports the PSWorkflow module. It uses the **MinimumVersion** (alias=Version) parameter of **Import-Module** to import only version 3.0.0.0 or greater of the module. You can also use the **RequiredVersion** parameter to import a particular version of a module, or use the **Module** and **Version** parameters of the **#Requires** keyword to require a particular version of a module in a script. -### Example 10 +### Example 11 ``` The first command uses the New-PSSession cmdlet to create a remote session (PSSession) to the Server01 computer. The command saves the PSSession in the $s variable PS C:\> $s = New-PSSession -ComputerName Server01 @@ -365,7 +365,7 @@ This command uses the Implicit Remoting feature of Windows PowerShell. When you import modules from another session, you can use the cmdlets in the current session. However, commands that use the cmdlets actually run in the remote session. -### Example 11 +### Example 12 ``` The first command uses the **New-CimSession** cmdlet to create a session on the RSDGF03 remote computer. The session connects to WMI on the remote computer. The command saves the CIM session in the $cs variable. PS C:\> $cs = New-CimSession -ComputerName RSDGF03 diff --git a/reference/3.0/Microsoft.PowerShell.Core/Providers/Alias-Provider.md b/reference/3.0/Microsoft.PowerShell.Core/Providers/Alias-Provider.md index 91c016ac26d1..8dc482039dea 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/Providers/Alias-Provider.md +++ b/reference/3.0/Microsoft.PowerShell.Core/Providers/Alias-Provider.md @@ -1,308 +1,311 @@ --- -ms.date: 2017-06-09 +ms.date: 2017-11-15 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet title: Alias Provider --- - # *Alias* provider - ## Provider name - Alias - +Alias ## Drives - `Alias:` - +`Alias:` ## Short description - Provides access to the Windows PowerShell aliases and the values that they represent. - +Provides access to the PowerShell aliases and the values that they represent. ## Detailed description - The Windows PowerShell **Alias** provider lets you get, add, change, clear, and delete aliases in Windows PowerShell. +The PowerShell **Alias** provider lets you get, add, change, clear, and delete aliases in PowerShell. - An alias is an alternate name for a cmdlet, function, or executable file. Windows PowerShell includes a set of built-in aliases. And, you can add your own aliases to the current session and to your Windows PowerShell profile. +An alias is an alternate name for a cmdlet, function, executable file, including scripts. +PowerShell includes a set of built-in aliases. +You can add your own aliases to the current session and to your PowerShell profile. - The **Alias** provider is a flat namespace that contains only the alias objects. The aliases have no child items. +The **Alias** provider is a flat namespace that contains only the alias objects. +The aliases have no child items. - Each alias is an instance of the [System.Management.Automation.AliasInfo](https://msdn.microsoft.com/library/system.management.automation.aliasinfo) class. +Each alias is an instance of the [System.Management.Automation.AliasInfo](https://msdn.microsoft.com/library/system.management.automation.aliasinfo) class. - The **Alias** provider exposes its data store in the `Alias:` drive. To work with aliases, you can change your location to the `Alias:` drive by using the following command: +The **Alias** provider exposes its data store in the `Alias:` drive. +To work with aliases, you can change your location to the `Alias:` drive by using the following command: ```powershell Set-Location Alias: ``` - Or, you can work from any other Windows PowerShell drive. To reference an alias from another location, use the `Alias:` drive name in the path. +Or, you can work from any other PowerShell drive. +To reference an alias from another location, use the `Alias:` drive name in the path. - Windows PowerShell includes a set of cmdlets that are designed to view and to change aliases: +PowerShell includes a set of cmdlets that are designed to view and to change aliases: -- [Export-Alias](../../Microsoft.PowerShell.Utility/Export-Alias.md) -- [Get-Alias](../../Microsoft.PowerShell.Utility/Get-Alias.md) -- [Import-Alias](../../Microsoft.PowerShell.Utility/Import-Alias.md) -- [New-Alias](../../Microsoft.PowerShell.Utility/New-Alias.md) -- [Set-Alias](../../Microsoft.PowerShell.Utility/Set-Alias.md) +- [Export-Alias](../../Microsoft.PowerShell.Utility/Export-Alias.md) +- [Get-Alias](../../Microsoft.PowerShell.Utility/Get-Alias.md) +- [Import-Alias](../../Microsoft.PowerShell.Utility/Import-Alias.md) +- [New-Alias](../../Microsoft.PowerShell.Utility/New-Alias.md) +- [Set-Alias](../../Microsoft.PowerShell.Utility/Set-Alias.md) - When you use these cmdlets, you do not need to specify the `Alias:` drive in the name. +When you use these cmdlets, you do not need to specify the `Alias:` drive in the name. - The **Alias** provider supports all the cmdlets that have the *Item* noun except for the [Invoke-Item](../../Microsoft.PowerShell.Management/Invoke-Item.md) cmdlet. And, it supports the [Get-Content](../../Microsoft.PowerShell.Management/Get-Content.md) and [Set-Content](../../Microsoft.PowerShell.Management/Set-Content.md) cmdlets. The **Alias** provider does not support the cmdlets that have the *ItemProperty* noun. And, the **Alias** provider does not support the `-Filter` parameter in any cmdlet. - - All changes to the aliases affect the current session only. To save the changes, add the changes to the Windows PowerShell profile. Or, use the [Export-Alias](../../Microsoft.PowerShell.Utility/Export-Alias.md) and [Import-Alias](../../Microsoft.PowerShell.Utility/Import-Alias.md) cmdlets. +The **Alias** provider supports all the cmdlets that have the *Item* noun except for the [Invoke-Item](../../Microsoft.PowerShell.Management/Invoke-Item.md) cmdlet. +It also supports the [Get-Content](../../Microsoft.PowerShell.Management/Get-Content.md) and [Set-Content](../../Microsoft.PowerShell.Management/Set-Content.md) cmdlets. +The **Alias** provider does not support the cmdlets that have the *ItemProperty* noun and does not support the `-Filter` parameter in any cmdlet. +All changes to the aliases affect the current session only. +To save the changes, add the changes to the PowerShell profile. +Or, use the [Export-Alias](../../Microsoft.PowerShell.Utility/Export-Alias.md) and [Import-Alias](../../Microsoft.PowerShell.Utility/Import-Alias.md) cmdlets. ## Capabilities - ShouldProcess - +ShouldProcess ## Examples - ### Getting to the `Alias:` drive - #### Example 1 - This command changes the current location to the `Alias:` drive. You can use this command from any drive in Windows PowerShell. To return to a file system drive, type the drive name. For example, type `set-location c:`. +This command changes the current location to the `Alias:` drive. +You can use this command from any drive in PowerShell. +To return to a file system drive, type the drive name. +For example, type `set-location c:`. ```powershell Set-Location Alias: ``` - ### Getting aliases - #### Example 1 - This command gets a list of all the aliases in the current session. You can use this command in any Windows PowerShell drive. +This command gets a list of all the aliases in the current session. +You can use this command in any PowerShell drive. ```powershell Get-Item -Path Alias: ``` - #### Example 2 - This command gets the `ls` alias. Because it includes the path, you can use it in any Windows PowerShell drive. +This command gets the `ls` alias. +Because it includes the path, you can use it in any PowerShell drive. ```powershell Get-Item -Path Alias:ls ``` - If you are in the `Alias:` drive, you can omit the drive name from the path. - +If you are in the `Alias:` drive, you can omit the drive name from the path. #### Example 3 - This command gets a list of the aliases that are associated with the [Get-ChildItem](../../Microsoft.PowerShell.Management/Get-ChildItem.md) cmdlet. It uses the `Definition` property, which stores the cmdlet name. +This command gets a list of the aliases that are associated with the [Get-ChildItem](../../Microsoft.PowerShell.Management/Get-ChildItem.md) cmdlet. +It uses the `Definition` property, which stores the cmdlet name. ```powershell Get-Item -Path Alias:* | Where-Object {$_.Definition -eq "Get-ChildItem"} ``` - When the aliased item is an executable file, the `Definition` contains the fully qualified path of the file. - - #### Example 4 - This command gets the list of all the aliases when the current location is the `Alias:` drive. It uses a wildcard character `*` to indicate all the contents of the current location. +This command gets the list of all the aliases when the current location is the `Alias:` drive. +It uses a wildcard character `*` to indicate all the contents of the current location. ```powershell Get-Item -Path * ``` - In the `Alias:` drive, a dot `.`, which represents the current location, and a wildcard character `*`, which represents all items in the current location, have the same effect. For example, `Get-Item -Path .` or `Get-Item \*` produce the same result. - +In the `Alias:` drive, a dot `.`, which represents the current location, and a wildcard character `*`, which represents all items in the current location, have the same effect. +For example, `Get-Item -Path .` or `Get-Item \*` produce the same result. ### Creating a new alias - #### Example 1 - This command creates the `serv` alias for the [Get-Service](../../Microsoft.PowerShell.Management/Get-Service.md) cmdlet. Because the current location is in the `Alias:` drive, the value of the `-Path` parameter is a dot `.`. The dot represents the current location. +This command creates the `serv` alias for the [Get-Service](../../Microsoft.PowerShell.Management/Get-Service.md) cmdlet. +Because the current location is in the `Alias:` drive, the value of the `-Path` parameter is a dot `.`. +The dot represents the current location. - This command also uses the `-Options` dynamic parameter to set the **AllScope** and **Constant** options on the alias. The `-Options` parameter is available in the [New-Item](../../Microsoft.PowerShell.Management/New-Item.md) cmdlet only when you are in the `Alias:` drive. +This command also uses the `-Options` dynamic parameter to set the **AllScope** and **Constant** options on the alias. +The `-Options` parameter is available in the [New-Item](../../Microsoft.PowerShell.Management/New-Item.md) cmdlet only when you are in the `Alias:` drive. ```powershell New-Item -Path . -Name serv -Value Get-Service -Options "AllScope,Constant" ``` - If you are in the `Alias:` drive, you can omit the drive name from the path. - +If you are in the `Alias:` drive, you can omit the drive name from the path. #### Example 2 - You can create an alias for any item that invokes a command. This command creates the `np` alias for `Notepad.exe`. +You can create an alias for any item that invokes a command. +This command creates the `np` alias for `Notepad.exe`. ```powershell New-Item -Path Alias:np -Value c:\windows\notepad.exe ``` - #### Example 3 - You can create an alias for any function. You can use this feature to create an alias that includes both a cmdlet and its parameters. +You can create an alias for any function. +You can use this feature to create an alias that includes both a cmdlet and its parameters. - The first command creates the `CD32` function, which changes the current directory to the `System32` directory. The second command creates the `go` alias for the `CD32` function. The semi-colon `;` is the command separator. +The first command creates the `CD32` function, which changes the current directory to the `System32` directory. +The second command creates the `go` alias for the `CD32` function. +The semi-colon `;` is the command separator. - When the command is complete, you can use either `CD32` or `go` to invoke the function. +When the command is complete, you can use either `CD32` or `go` to invoke the function. ```powershell function CD32 {Set-Location -Path c:\windows\system32}; Set-Item -Path Alias:go -Value CD32 ``` - ### Displaying the properties and methods of aliases - #### Example 1 - This command uses the [Get-Item](../../Microsoft.PowerShell.Management/Get-Item.md) cmdlet to get all aliases. The pipeline operator `|` sends the results to the [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md) cmdlet, which displays the methods and properties of the object. +This command uses the [Get-Item](../../Microsoft.PowerShell.Management/Get-Item.md) cmdlet to get all aliases. +The pipeline operator `|` sends the results to the [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md) cmdlet, which displays the methods and properties of the object. ```powershell Get-Item -Path Alias:* | Get-Member ``` - When you pipe a collection of objects to [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md), such as the collection of aliases in the `Alias:` drive, [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md) evaluates each object in the collection separately. Then, [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md) returns information about each object type that it finds. If all the objects are of the same type, it returns information about the single object type. In this case, all the aliases are [AliasInfo](https://msdn.microsoft.com/library/system.management.automation.aliasinfo) objects. -To get information about the collection of [AliasInfo](https://msdn.microsoft.com/library/system.management.automation.aliasinfo) objects, use the `-InputObject` parameter of [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md). For example, use the following command: +When you pipe a collection of objects to [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md), such as the collection of aliases in the `Alias:` drive, [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md) evaluates each object in the collection separately. +Then, [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md) returns information about each object type that it finds. +If all the objects are of the same type, it returns information about the single object type. +In this case, all the aliases are [AliasInfo](https://msdn.microsoft.com/library/system.management.automation.aliasinfo) objects. +To get information about the collection of [AliasInfo](https://msdn.microsoft.com/library/system.management.automation.aliasinfo) objects, use the `-InputObject` parameter of [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md). +For example, use the following command: ```powershell Get-Member -InputObject (Get-Item Alias:*) ``` -When you use `-InputObject`, [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md) evaluates the collection, not the objects in the collection. - +When you use `-InputObject`, [Get-Member](../../Microsoft.PowerShell.Utility/Get-Member.md) evaluates the collection, not the objects in the collection. #### Example 2 - This command lists the values of the properties of the `dir` alias. It uses the [Get-Item](../../Microsoft.PowerShell.Management/Get-Item.md) cmdlet to get an object that represents the `dir` alias. The pipeline operator `|` sends the results to the [Format-List](../../Microsoft.PowerShell.Utility/Format-List.md) command. The [Format-List](../../Microsoft.PowerShell.Utility/Format-List.md) command uses the `-Property` parameter with a wildcard character `*` to format and display the values of all the `dir` alias properties. +This command lists the values of the properties of the `dir` alias. +It uses the [Get-Item](../../Microsoft.PowerShell.Management/Get-Item.md) cmdlet to get an object that represents the `dir` alias. +The pipeline operator `|` sends the results to the [Format-List](../../Microsoft.PowerShell.Utility/Format-List.md) command. +The [Format-List](../../Microsoft.PowerShell.Utility/Format-List.md) command uses the `-Property` parameter with a wildcard character `*` to format and display the values of all the `dir` alias properties. ```powershell Get-Item Alias:dir | Format-List -Property * ``` - ### Changing the properties of an alias - #### Example 1 - You can use the [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) cmdlet with the `-Options` dynamic parameter to change the value of the `-Options` property of an alias. +You can use the [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) cmdlet with the `-Options` dynamic parameter to change the value of the `-Options` property of an alias. - This command sets the **AllScope** and **ReadOnly** options for the `dir` alias. The command uses the `-Options` dynamic parameter of the [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) cmdlet. The `-Options` parameter is available in [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) only when you use it with the **Alias** or **Function** provider. +This command sets the **AllScope** and **ReadOnly** options for the `dir` alias. +The command uses the `-Options` dynamic parameter of the [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) cmdlet. +The `-Options` parameter is available in [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) only when you use it with the **Alias** or **Function** provider. ```powershell Set-Item -Path Alias:dir -Options "AllScope,ReadOnly" ``` - #### Example 2 - This command uses the [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) cmdlet to change the `gp` alias so that it represents the [Get-Process](../../Microsoft.PowerShell.Management/Get-Process.md) cmdlet instead of the [Get-ItemProperty](../../Microsoft.PowerShell.Management/Get-ItemProperty.md) cmdlet. The `-Force` parameter is required because the value of the **Options** property of the `gp` alias is set to `ReadOnly`. Because the command is submitted from within the `Alias:` drive, the drive is not specified in the path. +This command uses the [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) cmdlet to change the `gp` alias so that it represents the [Get-Process](../../Microsoft.PowerShell.Management/Get-Process.md) cmdlet instead of the [Get-ItemProperty](../../Microsoft.PowerShell.Management/Get-ItemProperty.md) cmdlet. +The `-Force` parameter is required because the value of the **Options** property of the `gp` alias is set to `ReadOnly`. +Because the command is submitted from within the `Alias:` drive, the drive is not specified in the path. ```powershell Set-Item -Path gp -Value Get-Process -Force ``` - The change affects the four properties that define the association between the alias and the command. To view the effect of the change, type the following command: +The change affects the four properties that define the association between the alias and the command. +To view the effect of the change, type the following command: + ```powershell Get-Item -Path gp | Format-List -Property * ``` - #### Example 3 - This command uses the [Rename-Item](../../Microsoft.PowerShell.Management/Rename-Item.md) cmdlet to change the `popd` alias to `pop`. +This command uses the [Rename-Item](../../Microsoft.PowerShell.Management/Rename-Item.md) cmdlet to change the `popd` alias to `pop`. ```powershell Rename-Item -Path Alias:popd -NewName pop ``` - ### Copying an alias - #### Example 1 - This command copies the `pushd` alias so that a new `push` alias is created for the [Push-Location](../../Microsoft.PowerShell.Management/Push-Location.md) cmdlet. +This command copies the `pushd` alias so that a new `push` alias is created for the [Push-Location](../../Microsoft.PowerShell.Management/Push-Location.md) cmdlet. ```powershell Copy-Item -Path Alias:pushd -Destination Alias:push ``` - When the new alias is created, its **Description** property has a null value. And, its **Option** property has a value of `None`. -If the command is issued from within the `Alias:` drive, you can omit the drive name from the value of the `-Path` parameter. - +When the new alias is created, its **Description** property has a null value. +And, its **Option** property has a value of `None`. +If the command is issued from within the `Alias:` drive, you can omit the drive name from the value of the `-Path` parameter. ### Deleting an alias - #### Example 1 - This command deletes the `serv` alias from the current session. You can use this command in any Windows PowerShell drive. +This command deletes the `serv` alias from the current session. +You can use this command in any PowerShell drive. ```powershell Remove-Item -Path Alias:serv ``` - If you are in the `Alias:` drive, you can omit the drive name from the path. - +If you are in the `Alias:` drive, you can omit the drive name from the path. #### Example 2 - This command deletes aliases that begin with "s". It does not delete read-only aliases. +This command deletes aliases that begin with "s". +It does not delete read-only aliases. ```powershell Clear-Item -Path Alias:s* ``` - #### Example 3 - This command deletes all aliases from the current session, except those with a value of `Constant` for their **Options** property. Without the `-Force` parameter, the command does not delete aliases whose **Options** property has a value of `ReadOnly`. +This command deletes all aliases from the current session, except those with a value of `Constant` for their **Options** property. +Without the `-Force` parameter, the command does not delete aliases whose **Options** property has a value of `ReadOnly`. ```powershell Remove-Item Alias:* -Force ``` - ## Dynamic parameters - Dynamic parameters are cmdlet parameters that are added by a Windows PowerShell provider and are available only when the cmdlet is being used in the provider-enabled drive. - +Dynamic parameters are cmdlet parameters that are added by a PowerShell provider and are available only when the cmdlet is being used in the provider-enabled drive. -### `Options` <[System.Management.Automation.ScopedItemOptions](https://msdn.microsoft.com/library/system.management.automation.scopeditemoptions)> +### `Options` [System.Management.Automation.ScopedItemOptions](https://msdn.microsoft.com/library/system.management.automation.scopeditemoptions) - Determines the value of the **Options** property of an alias. - -|Value|Description| -|-----------|-----------------| -|`None`|No options. This value is the default.| -|`Constant`|The alias cannot be deleted and its properties cannot be changed. `Constant` is available only when you create an alias. You cannot change the option of an existing alias to `Constant`.| -|`Private`|The alias is visible only in the current scope, not in the child scopes.| -|`ReadOnly`|The properties of the alias cannot be changed except by using the `-Force` parameter. You can use [Remove-Item](../../Microsoft.PowerShell.Management/Remove-Item.md) to delete the alias.| -|`AllScope`|The alias is copied to any new scopes that are created.| +Determines the value of the **Options** property of an alias. +|Value|Description| +|-----------|-----------------| +|`None`|No options. This value is the default.| +|`Constant`|The alias cannot be deleted and its properties cannot be changed. `Constant` is available only when you create an alias. You cannot change the option of an existing alias to `Constant`.| +|`Private`|The alias is visible only in the current scope, not in the child scopes.| +|`ReadOnly`|The properties of the alias cannot be changed except by using the `-Force` parameter. You can use [Remove-Item](../../Microsoft.PowerShell.Management/Remove-Item.md) to delete the alias.| +|`AllScope`|The alias is copied to any new scopes that are created.| #### Cmdlets supported: - -- [New-Item](../../Microsoft.PowerShell.Management/New-Item.md) - -- [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) - +- [New-Item](../../Microsoft.PowerShell.Management/New-Item.md) +- [Set-Item](../../Microsoft.PowerShell.Management/Set-Item.md) ## See also - [about_Aliases](../About/about_Aliases.md) - [about_Providers](../About/about_Providers.md) +[about_Aliases](../About/about_Aliases.md) +[about_Providers](../About/about_Providers.md) diff --git a/reference/3.0/Microsoft.PowerShell.Core/Resume-Job.md b/reference/3.0/Microsoft.PowerShell.Core/Resume-Job.md index 5f9305ece342..eac94b88a35e 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/Resume-Job.md +++ b/reference/3.0/Microsoft.PowerShell.Core/Resume-Job.md @@ -103,14 +103,14 @@ This command resumes all suspended jobs on the Srv01 remote computer. The command uses the Invoke-Command cmdlet to run a command on the Srv01 computer. The remote command uses the **State** parameter of the Get-Job cmdlet to get all suspended jobs on the computer. A pipeline operator (|) sends the suspended jobs to the **Resume-Job** cmdlet, which resumes them. -### Example 4: Wait for jobs to resume +### Example 5: Wait for jobs to resume ``` PS C:\> Resume-Job -Name WorkflowJob, InventoryWorkflow, WFTest* -Wait ``` This command uses the **Wait** parameter to direct Resume-Job to return only after all specified jobs are resumed. The **Wait** parameter is especially useful in scripts that assume that jobs are resumed before the script continues. -### Example 5: Resume a Workflow that Suspends Itself +### Example 6: Resume a Workflow that Suspends Itself ``` This code sample shows the **Suspend-Workflow** activity in a workflow. #SampleWorkflow diff --git a/reference/3.0/Microsoft.PowerShell.Core/Where-Object.md b/reference/3.0/Microsoft.PowerShell.Core/Where-Object.md index fe6405119d6e..0e20d28acf73 100644 --- a/reference/3.0/Microsoft.PowerShell.Core/Where-Object.md +++ b/reference/3.0/Microsoft.PowerShell.Core/Where-Object.md @@ -428,7 +428,7 @@ Accept wildcard characters: False Specifies the Is operator, which gets objects when the property value is an instance of the specified .NET Framework type. Enclose the type name in square brackets. -For example, `Get-Process | where StartTime -is \[DateTime\]` +For example, `Get-Process | where StartTime -Is [DateTime]` This parameter is introduced in Windows PowerShell 3.0. @@ -447,7 +447,7 @@ Accept wildcard characters: False ### -IsNot Specifies the Is-Not operator, which gets objects when the property value is not an instance of the specified .NET Framework type. -For example, `Get-Process | where StartTime -IsNot \[System.String\]` +For example, `Get-Process | where StartTime -IsNot [DateTime]` This parameter is introduced in Windows PowerShell 3.0. diff --git a/reference/3.0/Microsoft.PowerShell.Management/Add-Content.md b/reference/3.0/Microsoft.PowerShell.Management/Add-Content.md index 45f6fb17fe94..ed1b89be2772 100644 --- a/reference/3.0/Microsoft.PowerShell.Management/Add-Content.md +++ b/reference/3.0/Microsoft.PowerShell.Management/Add-Content.md @@ -1,5 +1,5 @@ --- -ms.date: 2017-06-09 +ms.date: 2017-11-09 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -9,47 +9,59 @@ title: Add-Content --- # Add-Content + ## SYNOPSIS + Adds content to the specified items, such as adding words to a file. + ## SYNTAX ### Path (Default) -``` + +```powershell Add-Content [-Value] [-PassThru] [-Path] [-Filter ] [-Include ] [-Exclude ] [-Force] [-Credential ] [-WhatIf] [-Confirm] [-UseTransaction] [-Encoding ] [-Stream ] [] ``` ### LiteralPath -``` + +```powershell Add-Content [-Value] [-PassThru] -LiteralPath [-Filter ] [-Include ] [-Exclude ] [-Force] [-Credential ] [-WhatIf] [-Confirm] [-UseTransaction] [-Encoding ] [-Stream ] [] ``` ## DESCRIPTION + The Add-Content cmdlet appends content to a specified item or file. You can specify the content by typing the content in the command or by specifying an object that contains the content. + ## EXAMPLES -### Example 1 -``` -PS C:\> add-content -path *.txt -exclude help* -value "END" +### Example 1: Add a string to all text files with an exception + +```powershell +PS C:\> Add-Content -Path "*.txt" -Exclude "help*" -Value "END" ``` This command adds "END" to all text files in the current directory, except for those with file names that begin with "help". -### Example 2 -``` -PS C:\> add-content -Path file1.log, file2.log -Value (get-date) -passthru + +### Example 2: Add a date to the end of the specified files + +```powershell +PS C:\> Add-Content -Path "file1.log", "file2.log" -Value (Get-Date) -PassThru ``` This command adds the date to the end of the File1.log and File2.log files and then displays the date at the command line. The command uses the Get-Date cmdlet to get the date, and it uses the Value parameter to pass the date to Add-Content. The PassThru parameter passes an object representing the added content through the pipeline. Because there is no other cmdlet to receive the passed object, it is displayed at the command line. -### Example 3 -``` -PS C:\> add-content -path monthly.txt -value (get-content c:\rec1\weekly.txt) + +### Example 3: Add the contents of a specified file to another file + +```powershell +PS C:\> Add-Content -Path "monthly.txt" -Value (Get-Content "c:\rec1\weekly.txt") ``` This command adds the contents of the Weekly.txt file to the end of the Monthly.txt file. @@ -57,10 +69,12 @@ It uses the Get-Content cmdlet to get the contents of the Weekly.txt file, and i The parentheses ensure that the Get-Content command is complete before the Add-Content command begins. You can also copy the content of Weekly.txt to a variable, such as $w, and then use the Value parameter to pass the variable to Add-Content. -In that case, the command would be "add-content -path monthly.txt -value $w". -### Example 4 -``` -PS C:\> add-content -value (get-content test.log) -path C:\tests\test134\logs\test134.log +In that case, the command would be "Add-Content -Path monthly.txt -Value $w". + +### Example 4: Create a new directory and file and copy content + +```powershell +PS C:\> Add-Content -Value (Get-Content "test.log") -Path "C:\tests\test134\logs\test134.log" ``` This command creates a new directory and file and copies the content of an existing file to the newly created file. @@ -74,26 +88,31 @@ The command creates the remaining directories and the Test134.log file. The Force parameter is not required for this command. Add-Content creates directories to complete a path even without the Force parameter. + ## PARAMETERS ### -Encoding + Specifies the file encoding. The default is ASCII. Valid values are: --- ASCII: Uses the encoding for the ASCII (7-bit) character set. --- BigEndianUnicode: Encodes in UTF-16 format using the big-endian byte order. --- Byte: Encodes a set of characters into a sequence of bytes. --- String: Uses the encoding type for a string. --- Unicode: Encodes in UTF-16 format using the little-endian byte order. --- UTF7: Encodes in UTF-7 format. --- UTF8: Encodes in UTF-8 format. --- Unknown: The encoding type is unknown or invalid. The data can be treated as binary. +- ASCII: Uses the encoding for the ASCII (7-bit) character set. +- BigEndianUnicode: Encodes in UTF-16 format using the big-endian byte order. +- Byte: Encodes a set of characters into a sequence of bytes. +- String: Uses the encoding type for a string. +- Unicode: Encodes in UTF-16 format using the little-endian byte order. +- UTF7: Encodes in UTF-7 format. +- UTF8: Encodes in UTF-8 format. +- Unknown: The encoding type is unknown or invalid. The data can be treated as binary. + +Encoding is a dynamic parameter that the FileSystem provider adds to the Add-Content cmdlet. +This parameter works only in file system drives. -Encoding is a dynamic parameter that the FileSystem provider adds to the Add-Content cmdlet. This parameter works only in file system drives.```yaml +```yaml Type: FileSystemCmdletProviderEncoding Parameter Sets: (All) -Aliases: +Aliases: Accepted values: Unknown, String, Unicode, Byte, BigEndianUnicode, UTF8, UTF7, UTF32, Ascii, Default, Oem Required: False @@ -104,12 +123,13 @@ Accept wildcard characters: False ``` ### -Force + Overrides the read-only attribute, allowing you to add content to a read-only file. ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -119,14 +139,20 @@ Accept wildcard characters: False ``` ### -Stream -Adds the content to the specified alternate data stream. If the stream does not yet, exist, Add-Content creates it. Enter the stream name. Wildcards are not supported. -Stream is a dynamic parameter that the FileSystem provider adds to the Add-Content cmdlet. This parameter works only in file system drives. +Adds the content to the specified alternate data stream. +If the stream does not yet, exist, Add-Content creates it. +Enter the stream name. +Wildcards are not supported. + +Stream is a dynamic parameter that the FileSystem provider adds to the Add-Content cmdlet. +This parameter works only in file system drives. +This parameter is introduced in PowerShell 3.0. -This parameter is introduced in Windows PowerShell 3.0.```yaml +```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -136,6 +162,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -151,6 +178,7 @@ Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. @@ -167,6 +195,7 @@ Accept wildcard characters: False ``` ### -UseTransaction + Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions. @@ -184,18 +213,19 @@ Accept wildcard characters: False ``` ### -Credential + Specifies a user account that has permission to perform this action. The default is the current user. Type a user name, such as "User01" or "Domain01\User01", or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password. -This parameter is not supported by any providers installed with Windows PowerShell. +This parameter is not supported by any providers installed with PowerShell. ```yaml Type: PSCredential Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -205,6 +235,7 @@ Accept wildcard characters: False ``` ### -Exclude + Omits the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as "*.txt". @@ -213,7 +244,7 @@ Wildcards are permitted. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -223,15 +254,16 @@ Accept wildcard characters: True ``` ### -Filter + Specifies a filter in the provider's format or language. The value of this parameter qualifies the Path parameter. The syntax of the filter, including the use of wildcards, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having Windows PowerShell filter the objects after they are retrieved. +Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -241,6 +273,7 @@ Accept wildcard characters: True ``` ### -Include + Adds only the specified items. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as "*.txt". @@ -249,7 +282,7 @@ Wildcards are permitted. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -259,11 +292,12 @@ Accept wildcard characters: True ``` ### -LiteralPath + Specifies the path to the items that receive the additional content. Unlike Path, the value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. -Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. +Single quotation marks tell PowerShell not to interpret any characters as escape sequences. ```yaml Type: String[] @@ -278,17 +312,18 @@ Accept wildcard characters: False ``` ### -PassThru + Returns an object representing the added content. By default, this cmdlet does not generate any output. ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named -Default value: False +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` @@ -301,7 +336,7 @@ If you specify multiple paths, use commas to separate the paths. ```yaml Type: String[] Parameter Sets: Path -Aliases: +Aliases: Required: True Position: 1 @@ -311,6 +346,7 @@ Accept wildcard characters: True ``` ### -Value + Specifies the content to be added. Type a quoted string, such as "This data is for internal use only", or specify an object that contains content, such as the DateTime object that Get-Date generates. @@ -319,7 +355,7 @@ You cannot specify the contents of a file by typing its path, because the path i ```yaml Type: Object[] Parameter Sets: (All) -Aliases: +Aliases: Required: True Position: 2 @@ -329,27 +365,34 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ### System.Object -You can pipe the objects to be added (the Value) to Add-Content. + +You can pipe the objects to be added by Add-Content. + ## OUTPUTS ### None or System.String + When you use the Passthru parameter, Add-Content generates a System.String object representing the content. Otherwise, this cmdlet does not generate any output. + ## NOTES -* When you pipe an object to Add-Content, the object is converted to a string before it is added to the item. The object type determines the string format, but the format might be different than the default display of the object. To control the string format, use the formatting parameters of the sending cmdlet. - You can also refer to Add-Content by its built-in alias, "ac". -For more information, see about_Aliases. +When you pipe an object to Add-Content, the object is converted to a string before it is added to the item. +The object type determines the string format, but the format might be different than the default display of the object. +To control the string format, use the formatting parameters of the sending cmdlet. - The Add-Content cmdlet is designed to work with the data exposed by any provider. +You can also refer to Add-Content by its built-in alias, "ac". For more information, see about_Aliases. + +The Add-Content cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type "Get-PsProvider". For more information, see about_Providers. -* ## RELATED LINKS [Clear-Content](Clear-Content.md) @@ -362,4 +405,3 @@ For more information, see about_Providers. [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) - diff --git a/reference/3.0/Microsoft.PowerShell.Management/Set-Content.md b/reference/3.0/Microsoft.PowerShell.Management/Set-Content.md index 2219dba7cc31..f0d83c19e88b 100644 --- a/reference/3.0/Microsoft.PowerShell.Management/Set-Content.md +++ b/reference/3.0/Microsoft.PowerShell.Management/Set-Content.md @@ -1,5 +1,5 @@ --- -ms.date: 2017-06-09 +ms.date: 2017-11-09 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -18,7 +18,7 @@ Writes or replaces the content in an item with new content. ### Path (Default) -``` +```powershell Set-Content [-Value] [-PassThru] [-Path] [-Filter ] [-Include ] [-Exclude ] [-Force] [-Credential ] [-WhatIf] [-Confirm] [-UseTransaction] [-Encoding ] [-Stream ] [] @@ -26,49 +26,50 @@ Set-Content [-Value] [-PassThru] [-Path] [-Filter ### LiteralPath -``` +```powershell Set-Content [-Value] [-PassThru] -LiteralPath [-Filter ] [-Include ] [-Exclude ] [-Force] [-Credential ] [-WhatIf] [-Confirm] [-UseTransaction] [-Encoding ] [-Stream ] [] ``` ## DESCRIPTION + The Set-Content cmdlet is a string-processing cmdlet that writes or replaces the content in the specified item, such as a file. Whereas the Add-Content cmdlet appends content to a file, Set-Content replaces the existing content. You can type the content in the command or send content through the pipeline to Set-Content. ## EXAMPLES -### Example 1 +### Example 1: Replace the contents of multiple files in a folder -``` -PS C:\> set-content -path C:\Test1\test*.txt -value "Hello, World" +```powershell +PS C:\> Set-Content -Path "C:\Test1\test*.txt" -Value "Hello, World" ``` -This command replaces the contents of all files in the Test1 directory that have names beginning with "test" with "Hello, World". +This command replaces the contents of all files in the Test1 folder that have names that start with "test" with "Hello, World". This example shows how to specify content by typing it in the command. -### Example 2 +### Example 2: Send content to a file -``` -PS C:\> get-date | set-content C:\Test1\date.csv +```powershell +PS C:\> Get-Date | Set-Content -Path "C:\Test1\date.csv" ``` This command creates a comma-separated variable-length (csv) file that contains only the current date and time. It uses the Get-Date cmdlet to get the current system date and time. The pipeline operator passes the result to Set-Content, which creates the file and writes the content. -If the Test1 directory does not exist, the command fails, but if the file does not exist, the command will create it. +If the Test1 directory does not exist, the command fails, but if the file does not exist, the command creates it. -### Example 3 +### Example 3: Replace text in a file -``` -PS C:\> (get-content Notice.txt) | foreach-object {$_ -replace "Warning", "Caution"} | set-content Notice.txt +```powershell +PS C:\> (Get-Content -Path "Notice.txt") | ForEach-Object {$_ -Replace "Warning", "Caution"} | Set-Content -Path "Notice.txt" ``` This command replaces all instances of "Warning" with "Caution" in the Notice.txt file. -It uses the Get-Content cmdlet to get the content of Notice.txt. +It uses Get-Content cmdlet to get the content of Notice.txt. The pipeline operator sends the results to the ForEach-Object cmdlet, which applies the expression to each line of content in Get-Content. The expression uses the "$_" symbol to refer to the current item and the Replace parameter to specify the text to be replaced. @@ -103,16 +104,16 @@ The default is the current user. Type a user name, such as "User01" or "Domain01\User01", or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password. -This parameter is not supported by any providers installed with Windows PowerShell. +This parameter is not supported by any providers installed with PowerShell. ```yaml Type: PSCredential Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named -Default value: Current user +Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` @@ -123,13 +124,13 @@ Specifies the file encoding. The acceptable values for this parameter are: - **ASCII** Uses the encoding for the ASCII (7-bit) character set. -- **BigEndianUnicode** Encodes in UTF-16 format using the big-endian byte order. -- **Byte** Encodes a set of characters into a sequence of bytes. -- **String** Uses the encoding type for a string. -- **Unicode** Encodes in UTF-16 format using the little-endian byte order. +- **BigEndianUnicode** Encodes in UTF-16 format using the big-endian byte order. +- **Byte** Encodes a set of characters into a sequence of bytes. +- **String** Uses the encoding type for a string. +- **Unicode** Encodes in UTF-16 format using the little-endian byte order. - **UTF7** Encodes in UTF-7 format. -- **UTF8** Encodes in UTF-8 format. -- **Unknown** The encoding type is unknown or invalid; the data can be treated as binary. +- **UTF8** Encodes in UTF-8 format. +- **Unknown** The encoding type is unknown or invalid; the data can be treated as binary. The default value is ASCII. @@ -139,7 +140,7 @@ This parameter works only in file system drives. ```yaml Type: FileSystemCmdletProviderEncoding Parameter Sets: (All) -Aliases: +Aliases: Accepted values: Unknown, String, Unicode, Byte, BigEndianUnicode, UTF8, UTF7, UTF32, Ascii, Default, Oem Required: False @@ -159,7 +160,7 @@ Wildcards are permitted. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -170,15 +171,17 @@ Accept wildcard characters: True ### -Filter -Specifies a filter in the provider's format or language. +Specifies a filter in the format or language of the provider. The value of this parameter qualifies the Path parameter. -The syntax of the filter, including the use of wildcards, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having Windows PowerShell filter the objects after they are retrieved. +The syntax of the filter, including the use of wildcard characters, depends on the provider. +Filters are more efficient than other parameters, +because the provider applies them when it is retrieving the objects, +instead of having PowerShell filter the objects after they are retrieved. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -189,19 +192,19 @@ Accept wildcard characters: True ### -Force -Allows the cmdlet to set the contents of a file, even if the file is read-only. +Forces the cmdlet to set the contents of a file, even if the file is read-only. Implementation varies from provider to provider. For more information, see about_Providers. -Even using the Force parameter, the cmdlet cannot override security restrictions. +Using the Force parameter does not override security restrictions. ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named -Default value: False +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` @@ -216,7 +219,7 @@ Wildcards are permitted. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -231,7 +234,7 @@ Specifies the path to the item that will receive the content. Unlike Path, the value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. -Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences. +Single quotation marks tell PowerShell not to interpret any characters as escape sequences. ```yaml Type: String[] @@ -247,30 +250,30 @@ Accept wildcard characters: False ### -PassThru -Returns an object representing the content. +Returns an object that represents the content. By default, this cmdlet does not generate any output. ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named -Default value: False +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` ### -Path -Specifies the path to the item that will receive the content. -Wildcards are permitted. +Specifies the path of the item that receives the content. +Wildcard characters are permitted. ```yaml Type: String[] Parameter Sets: Path -Aliases: +Aliases: Required: True Position: 1 @@ -280,23 +283,24 @@ Accept wildcard characters: True ``` ### -Stream + Specifies an alternative data stream for content. If the stream does not exist, this cmdlet creates it. Wildcard characters are not supported. -Stream is a dynamic parameter that the FileSystem provider adds to **Set-Content**. +Stream is a dynamic parameter that the FileSystem provider adds to `Set-Content`. This parameter works only in file system drives. -You can use the **Set-Content** cmdlet to change the content of the Zone.Identifier alternate data stream. +You can use the `Set-Content` cmdlet to change the content of the Zone.Identifier alternate data stream. However, we do not recommend this as a way to eliminate security checks that block files that are downloaded from the Internet. If you verify that a downloaded file is safe, use the Unblock-File cmdlet. -This parameter was introduced in Windows PowerShell 3.0. +This parameter was introduced in PowerShell 3.0. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -309,9 +313,7 @@ Accept wildcard characters: False Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. -For more information, see Includes the command in the active transaction. -This parameter is valid only when a transaction is in progress. -For more information, see +For more information, see about_Transactions. ```yaml Type: SwitchParameter @@ -332,7 +334,7 @@ Specifies the new content for the item. ```yaml Type: Object[] Parameter Sets: (All) -Aliases: +Aliases: Required: True Position: 2 @@ -360,22 +362,10 @@ Accept wildcard characters: False ### CommonParameters -This cmdlet supports the common parameters: -Parameter | --- | - --Debug | --ErrorAction | --ErrorVariable | --InformationAction | --InformationVariable | --OutBuffer | --OutVariable | --PipelineVariable | --Verbose | --WarningAction | --WarningVariable. | - -For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, +-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters). ## INPUTS @@ -392,14 +382,14 @@ Otherwise, this cmdlet does not generate any output. ## NOTES -You can also refer to Set-Content by its built-in alias, "sc". For more information, see about_Aliases. +You can also refer to Set-Content by its built-in alias, "sc". For more information, see [about_Aliases](../Microsoft.PowerShell.Core/About/about_Aliases.md). Set-Content is designed for string processing. If you pipe non-string objects to Set-Content, it converts the object to a string before writing it. To write objects to files, use Out-File. The Set-Content cmdlet is designed to work with the data exposed by any provider. -To list the providers available in your session, type "Get-PsProvider". +To list the providers available in your session, type `Get-PsProvider`. For more information, see about_Providers. ## RELATED LINKS diff --git a/reference/3.0/Microsoft.PowerShell.Security/Set-Acl.md b/reference/3.0/Microsoft.PowerShell.Security/Set-Acl.md index a4e0470c14df..d5135545bee2 100644 --- a/reference/3.0/Microsoft.PowerShell.Security/Set-Acl.md +++ b/reference/3.0/Microsoft.PowerShell.Security/Set-Acl.md @@ -34,18 +34,19 @@ Set-Acl -LiteralPath [-AclObject] [[-CentralAccessPolicy] $DogACL = Get-Acl C:\Dog.txt -PS C:\> Set-Acl -Path C:\Cat.txt -AclObject $DogACL +PS C:\> $DogACL = Get-Acl -Path "C:\Dog.txt" +PS C:\> Set-Acl -Path "C:\Cat.txt" -AclObject $DogACL ``` These commands copy the values from the security descriptor of the Dog.txt file to the security descriptor of the Cat.txt file. @@ -54,26 +55,28 @@ When the commands complete, the security descriptors of the Dog.txt and Cat.txt The first command uses the Get-Acl cmdlet to get the security descriptor of the Dog.txt file. The assignment operator (=) stores the security descriptor in the value of the $DogACL variable. -The second command uses **Set-Acl** to change the values in the ACL of Cat.txt to the values in $DogACL. +The second command uses `Set-Acl` to change the values in the ACL of Cat.txt to the values in $DogACL. The value of the **Path** parameter is the path to the Cat.txt file. The value of the **AclObject** parameter is the model ACL, in this case, the ACL of Dog.txt as saved in the $DogACL variable. -### Example 2 + +### Example 2: Use the pipeline operator to pass a descriptor ``` -PS C:\> Get-Acl C:\Dog.txt | Set-Acl -Path C:\Cat.txt +PS C:\> Get-Acl -Path "C:\Dog.txt" | Set-Acl -Path "C:\Cat.txt" ``` -This command is almost the same as the command in the previous example, except that it uses a pipeline operator to send the security descriptor from a Get-Aclcommand to a **Set-Acl** command. +This command is almost the same as the command in the previous example, except that it uses a pipeline operator to send the security descriptor from a Get-Aclcommand to a `Set-Acl` command. The first command uses the **Get-Acl** cmdlet to get the security descriptor of the Dog.txt file. -The pipeline operator (|) passes an object that represents the Dog.txt security descriptor to the **Set-Acl** cmdlet. +The pipeline operator (|) passes an object that represents the Dog.txt security descriptor to the `Set-Acl` cmdlet. -The second command uses **Set-Acl** to apply the security descriptor of Dog.txt to Cat.txt. +The second command uses `Set-Acl` to apply the security descriptor of Dog.txt to Cat.txt. When the command completes, the ACLs of the Dog.txt and Cat.txt files are identical. -### Example 3 + +### Example 3: Apply a security descriptor to multiple files ``` PS C:\> $NewAcl = Get-Acl File0.txt -PS C:\> Get-ChildItem c:\temp -Recurse -Include *.txt -Force | Set-Acl -AclObject $NewAcl +PS C:\> Get-ChildItem -Path "C:\temp" -Recurse -Include "*.txt" -Force | Set-Acl -AclObject $NewAcl ``` These commands apply the security descriptors in the File0.txt file to all text files in the C:\Temp directory and all of its subdirectories. @@ -86,24 +89,25 @@ The **Include** parameter limits the files retrieved to those with the ".txt" fi The **Force** parameter gets hidden files, which would otherwise be excluded. (You cannot use "c:\temp\*.txt", because the **Recurse** parameter works on directories, not on files.) -The pipeline operator (|) sends the objects representing the retrieved files to the **Set-Acl** cmdlet, which applies the security descriptor in the **AclObject** parameter to all of the files in the pipeline. +The pipeline operator (|) sends the objects representing the retrieved files to the `Set-Acl` cmdlet, which applies the security descriptor in the **AclObject** parameter to all of the files in the pipeline. -In practice, it is best to use the **Whatif** parameter with all **Set-Acl** commands that can affect more than one item. +In practice, it is best to use the **Whatif** parameter with all `Set-Acl` commands that can affect more than one item. In this case, the second command in the pipeline would be "`Set-Acl -AclObject $NewAcl -WhatIf`". This command lists the files that would be affected by the command. After reviewing the result, you can run the command again without the **Whatif** parameter. + ## PARAMETERS ### -AclObject Specifies an ACL with the desired property values. -**Set-Acl** changes the ACL of item specified by the **Path** or **InputObject** parameter to match the values in the specified security object. +`Set-Acl` changes the ACL of item specified by the **Path** or **InputObject** parameter to match the values in the specified security object. You can save the output of a Get-Acl command in a variable and then use the **AclObject** parameter to pass the variable, or type a Get-Acl command. ```yaml Type: Object Parameter Sets: (All) -Aliases: +Aliases: Required: True Position: 2 @@ -121,7 +125,7 @@ Wildcards are permitted. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -139,7 +143,7 @@ Filters are more efficient than other parameters, because the provider applies t ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -157,7 +161,7 @@ Wildcards are permitted. ```yaml Type: String[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -167,13 +171,13 @@ Accept wildcard characters: True ``` ### -Passthru -Returns an object that represents the security descriptor that was changed. +Returns an object that represents the security descriptor that was changed. By default, this cmdlet does not generate any output. ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -187,12 +191,12 @@ Changes the security descriptor of the specified item. Enter the path to an item, such as a path to a file or registry key. Wildcards are permitted. -If you pass a security object to **Set-Acl** (either by using the **AclObject** or **SecurityDescriptor** parameters or by passing a security object from Get-Acl to **Set-Acl**), and you omit the **Path** parameter (name and value), **Set-Acl** uses the path that is included in the security object. +If you pass a security object to `Set-Acl` (either by using the **AclObject** or **SecurityDescriptor** parameters or by passing a security object from Get-Acl to `Set-Acl`), and you omit the **Path** parameter (name and value), `Set-Acl` uses the path that is included in the security object. ```yaml Type: String[] Parameter Sets: ByPath -Aliases: +Aliases: Required: True Position: 1 @@ -213,7 +217,7 @@ This parameter is introduced in Windows PowerShell 3.0. ```yaml Type: String Parameter Sets: ByPath, ByLiteralPath -Aliases: +Aliases: Required: False Position: 3 @@ -233,7 +237,7 @@ This parameter is introduced in Windows PowerShell 3.0. ```yaml Type: SwitchParameter Parameter Sets: ByPath, ByLiteralPath -Aliases: +Aliases: Required: False Position: Named @@ -246,7 +250,7 @@ Accept wildcard characters: False Changes the security descriptor of the specified object. Enter a variable that contains the object or a command that gets the object. -You cannot pipe the object to be changed to **Set-Acl**. +You cannot pipe the object to be changed to `Set-Acl`. Instead, use the **InputObject** parameter explicitly in the command. This parameter is introduced in Windows PowerShell 3.0. @@ -254,7 +258,7 @@ This parameter is introduced in Windows PowerShell 3.0. ```yaml Type: PSObject Parameter Sets: ByInputObject -Aliases: +Aliases: Required: True Position: 1 @@ -334,22 +338,23 @@ Accept wildcard characters: False ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ### System.Security.AccessControl.ObjectSecurity, System.Security.AccessControl.CommonSecurityDescriptor -You can pipe an ACL object or a security descriptor to **Set-Acl**. +You can pipe an ACL object or a security descriptor to `Set-Acl`. + ## OUTPUTS ### System.Security.AccessControl.FileSecurity -By default, **Set-Acl** does not generate any output. +By default, `Set-Acl` does not generate any output. However, if you use the **Passthru** parameter, it generates a security object. The type of the security object depends on the type of the item. + ## NOTES -* The **Set-Acl** cmdlet is supported by the Windows PowerShell file system and registry providers. As such, you can use it to change the security descriptors of files, directories, and registry keys. -* + The `Set-Acl` cmdlet is supported by the Windows PowerShell file system and registry providers. As such, you can use it to change the security descriptors of files, directories, and registry keys. + ## RELATED LINKS [Get-Acl](Get-Acl.md) - - diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Format-Custom.md b/reference/3.0/Microsoft.PowerShell.Utility/Format-Custom.md index 02dd4734a64e..34356d29d590 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Format-Custom.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Format-Custom.md @@ -9,8 +9,10 @@ title: Format-Custom --- # Format-Custom + ## SYNOPSIS Uses a customized view to format the output. + ## SYNTAX ``` @@ -19,25 +21,28 @@ Format-Custom [[-Property] ] [-Depth ] [-GroupBy ] [-Vi ``` ## DESCRIPTION -The Format-Custom cmdlet formats the output of a command as defined in an alternate view. -Format-Custom is designed to display views that are not just tables or just lists. +The `Format-Custom` cmdlet formats the output of a command as defined in an alternate view. +`Format-Custom` is designed to display views that are not just tables or just lists. You can use the views defined in the *format.PS1XML files in the Windows PowerShell directory, or you can create your own views in new PS1XML files and use the Update-FormatData cmdlet to add them to Windows PowerShell. + ## EXAMPLES ### Example 1 -``` -PS C:\> get-command start-transcript | format-custom -view MyView +```powershell +PS C:\> Get-Command Start-Transcript | Format-Custom -View MyView ``` -This command formats information about the Start-Transcript cmdlet in the format defined by the MyView view, a custom view created by the user. +This command formats information about the `Start-Transcript` cmdlet in the format defined by the MyView view, a custom view created by the user. To run this command successfully, you must first create a new PS1XML file, define the MyView view, and then use the Update-FormatData command to add the PS1XML file to Windows PowerShell. + ### Example 2 -``` -PS C:\> get-process Winlogon | format-custom +```powershell +PS C:\> Get-Process Winlogon | Format-Custom ``` This command formats information about the Winlogon process in an alternate customized view. -Because the command does not use the View parameter, Format-Custom uses a default custom view to format the data. +Because the command does not use the **View** parameter, `Format-Custom` uses a default custom view to format the data. + ## PARAMETERS ### -Depth @@ -46,7 +51,7 @@ Specifies the number of columns in the display. ```yaml Type: Int32 Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -58,17 +63,20 @@ Accept wildcard characters: False ### -DisplayError Displays errors at the command line. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a Format-Custom command, and the expressions do not appear to be working. -The following shows an example of the results of adding the DisplayError parameter with an expression. +The following shows an example of the results of adding the **DisplayError** parameter with an expression. + +```powershell +PS \> Get-Date | Format-Custom DayOfWeek,{ $_ / $null } -DisplayError -PS \> Get-Date | Format-Custom DayOfWeek,{ $_ / $null } -ShowError DayOfWeek $_ / $null --------- ------------ Wednesday #ERR +``` ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -80,7 +88,7 @@ Accept wildcard characters: False ### -Expand Formats the collection object, as well as the objects in the collection. This parameter is designed to format objects that support the ICollection (System.Collections) interface. -The default value is EnumOnly. +The default value is **EnumOnly**. Valid values are: @@ -91,7 +99,7 @@ Valid values are: ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -108,7 +116,7 @@ By default, when an error object is written to the error or display streams, onl ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -132,7 +140,7 @@ Valid keys are: ```yaml Type: Object Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -148,7 +156,7 @@ Enter a variable that contains the objects or type a command or expression that ```yaml Type: PSObject Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -175,7 +183,7 @@ Valid keys are: ```yaml Type: Object[] Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: 1 @@ -187,8 +195,9 @@ Accept wildcard characters: False ### -ShowError Sends errors through the pipeline. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a Format-Custom command, and the expressions do not appear to be working. -The following shows an example of the results of adding the ShowError parameter with an expression. +The following shows an example of the results of adding the **ShowError** parameter with an expression. +```powershell PS \> Get-Date | Format-Custom DayOfWeek,{ $_ / $null } -ShowError DayOfWeek $_ / $null --------- ------------ @@ -197,11 +206,12 @@ Wednesday Failed to evaluate expression " $_ / $null ". + CategoryInfo : InvalidArgument: (10/30/2013 2:28:07 PM:PSObject) \[\], RuntimeException + FullyQualifiedErrorId : mshExpressionError +``` ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -211,13 +221,13 @@ Accept wildcard characters: False ``` ### -View -Specifies the name of an alternate format or "view." If you omit this parameter, Format-Custom uses a default custom view. +Specifies the name of an alternate format or "view." If you omit this parameter, `Format-Custom` uses a default custom view. You cannot use the Property and View parameters in the same command. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -227,24 +237,30 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + ## INPUTS ### System.Management.Automation.PSObject -You can pipe any object to Format-Custom + +You can pipe any object to Format-Custom. + ## OUTPUTS ### Microsoft.PowerShell.Commands.Internal.Format + Format-Custom returns the format objects that represent the display. + ## NOTES -* Format-Custom is designed to display views that are not just tables or just lists. To display an alternate table view, use Format-Table. To display an alternate list view, use Format-List. - You can also refer to Format-Custom by its built-in alias, "fc". -For more information, see about_Aliases. +Format-Custom is designed to display views that are not just tables or just lists. To display an alternate table view, use Format-Table. To display an alternate list view, use Format-List. + +You can also refer to `Format-Custom` by its built-in alias, "fc". +For more information, see [about_Aliases](../Microsoft.PowerShell.Core/About/about_Aliases.md). - The GroupBy parameter assumes that the objects are sorted. -Before using Format-Custom to group the objects, use Sort-Object to sort them. +The **GroupBy** parameter assumes that the objects are sorted. +Before using `Format-Custom` to group the objects, use `Sort-Object` to sort them. -* ## RELATED LINKS diff --git a/reference/3.0/Microsoft.PowerShell.Utility/Format-Table.md b/reference/3.0/Microsoft.PowerShell.Utility/Format-Table.md index c9542ce4b85f..90e3c095f97a 100644 --- a/reference/3.0/Microsoft.PowerShell.Utility/Format-Table.md +++ b/reference/3.0/Microsoft.PowerShell.Utility/Format-Table.md @@ -9,38 +9,42 @@ title: Format-Table --- # Format-Table + ## SYNOPSIS Formats the output as a table. + ## SYNTAX -``` +```powershell Format-Table [-AutoSize] [-HideTableHeaders] [-Wrap] [[-Property] ] [-GroupBy ] [-View ] [-ShowError] [-DisplayError] [-Force] [-Expand ] [-InputObject ] [] ``` ## DESCRIPTION -The Format-Table cmdlet formats the output of a command as a table with the selected properties of the object in each column. -The object type determines the default layout and properties that are displayed in each column, but you can use the Property parameter to select the properties that you want to see. +The `Format-Table` cmdlet formats the output of a command as a table with the selected properties of the object in each column. +The object type determines the default layout and properties that are displayed in each column, but you can use the **Property** parameter to select the properties that you want to see. You can also use a hash table to add calculated properties to an object before displaying it and to specify the column headings in the table. -To add a calculated property, use the Property or GroupBy parameters. +To add a calculated property, use the **Property** or **GroupBy** parameter. + ## EXAMPLES -### Example 1 -``` -PS C:\> get-pssnapin | format-table -auto +### Example 1: Format PowerShell snap-ins +```powershell +PS C:\> Get-PSSnapin | Format-Table -Auto ``` This command formats information about Windows PowerShell snap-ins in a table. By default, they are formatted in a list. The Get-PSSnapin cmdlet gets objects representing the snap-ins. -The pipeline operator (|) passes the object to the Format-Table command. -Format-Table formats the objects in a table. -The Autosize parameter adjusts the column widths to minimize truncation. -### Example 2 -``` -PS C:\> get-process | sort-object -property basepriority | format-table -groupby basepriority -wrap +The pipeline operator (|) passes the object to the `Format-Table` command. +`Format-Table` formats the objects in a table. +The **Autosize** parameter adjusts the column widths to minimize truncation. + +### Example 2: Format processes by BasePriority +```powershell +PS C:\> Get-Process | Sort-Object -Property basepriority | Format-Table -GroupBy basepriority -Wrap ``` This command displays the processes on the computer in groups with the same base priority. @@ -48,117 +52,123 @@ This command displays the processes on the computer in groups with the same base The Get-Process cmdlet gets objects representing each process on the computer. The pipeline operator (|) passes the object to the Sort-Object cmdlet, which sorts the objects in order of their base priority. -Another pipeline operator passes the results to the Format-Table cmdlet. -The GroupBy parameter arranges the data about the processes into groups based on the value of their BasePriority property. -The Wrap parameter ensures that data is not truncated. -### Example 3 -``` -PS C:\> get-process | sort-object starttime | format-table -view starttime +Another pipeline operator passes the results to the `Format-Table` cmdlet. +The **GroupBy** parameter arranges the data about the processes into groups based on the value of their BasePriority property. +The **Wrap** parameter ensures that data is not truncated. + +### Example 3: Format processes by start date +```powershell +PS C:\> Get-Process | Sort-Object starttime | Format-Table -View starttime ``` This command displays information about the processes on the computer in group based on the start date of the process. It uses the Get-Process cmdlet to get objects representing the processes on the computer. The pipeline operator (|) sends the output of Get-Process to the Sort-Object cmdlet, which sorts it based on the StartTime property. -Another pipeline operator sends the sorted results to Format-Table. +Another pipeline operator sends the sorted results to `Format-Table`. -The View parameter is used to select the StartTime view that is defined in the DotNetTypes.format.ps1xml formatting file for System.Diagnostics.Process objects, such as those returned by Get-Process. +The **View** parameter is used to select the StartTime view that is defined in the DotNetTypes.format.ps1xml formatting file for **System.Diagnostics.Process** objects, such as those returned by `Get-Process`. This view converts the StartTime of the process to a short date and then groups the processes by start date. The DotNetTypes.format.ps1xml formatting file also contains a Priority view for processes, and you can create your own format.ps1xml files with customized views. -### Example 4 -``` -PS C:\> get-service | format-table -property Name, DependentServices + +### Example 4: Format services +```powershell +PS C:\> Get-Service | Format-Table -Property Name, DependentServices ``` This command displays all of the services on the computer in a table with two columns, Name and DependentServices. The command uses the Get-Service cmdlet to get all of the services on the computer. -The pipeline operator (|) sends the results to the Format-Table cmdlet, which formats the output in a table. -The Property parameter specifies the properties that appear in the table as columns. -The name of the Property parameter is optional, so you can omit it ("format-table name, dependentservices"). +The pipeline operator (|) sends the results to the `Format-Table` cmdlet, which formats the output in a table. +The **Property** parameter specifies the properties that appear in the table as columns. +The name of the **Property** parameter is optional, so you can omit it, for example `format-table name, dependentservices`. -Property and DependentServices are just two of the properties of service objects. -To view all of the properties, type "get-service | get-member". -### Example 5 -``` -PS C:\> get-process notepad | format-table ProcessName, @{Label="TotalRunningTime"; Expression={(get-date) - $_.StartTime}} +Name and DependentServices are just two of the properties of service objects. +To view all of the properties, type `get-service | get-member`. + +### Example 5: Format a process and calculate its running time +```powershell +PS C:\> Get-Process Notepad | Format-Table ProcessName, @{Label="TotalRunningTime"; Expression={(Get-Date) - $_.StartTime}} ``` This command shows how to use a calculated property in a table. The command displays a table with the process name and total running time of all Notepad processes on the local computer. The total running time is calculated by subtracting the start time of each process from the current time. -The command uses the Get-Process cmdlet to get all processes named "Notepad" on the local computer. -The pipeline operator (|) sends the results to Format-Table, which displays a table with two columns: ProcessName, a standard property of processes, and TotalRunningTime, a calculated property. +The command uses the Get-Process cmdlet to get all processes named Notepad on the local computer. +The pipeline operator (|) sends the results to `Format-Table`, which displays a table with two columns: ProcessName, a standard property of processes, and TotalRunningTime, a calculated property. The TotalRunningTime property is specified by a hash table with two keys, Label and Expression. The name of the property is assigned to the Label key. The calculation is assigned to the Expression key. -The expression gets the StartTime property of each process object and subtracts it from the result of a Get-Date command, which gets the current date (and time). -### Example 6 -``` -PS C:\> $processes = get-wmiobject -ComputerName Server01 win32_process -filter "name='notepad.exe'" -PS C:\> $processes | format-table ProcessName, @{ Label = "Total Running Time"; Expression={(get-date) - $_.ConvertToDateTime($_.CreationDate)}} +The expression gets the StartTime property of each process object and subtracts it from the result of a `Get-Date` command, which gets the current date and time. + +### Example 6: Format Notepad processes +```powershell +PS C:\> $Processes = Get-WmiObject -ComputerName "Server01" -Class win32_process -Filter "name='notepad.exe'" +PS C:\> $Processes | Format-Table ProcessName, @{ Label = "Total Running Time"; Expression={(Get-Date) - $_.ConvertToDateTime($_.CreationDate)}} ``` These commands are similar to the previous command, except that these commands use the Get-WmiObject cmdlet and the Win32_Process class to display information about Notepad processes on a remote computer. -The first command uses the Get-WmiObject cmdlet to get instances of the Windows Management Instrumentation (WMI) Win32_Process class that describes all of the processes on the Server01 computer that are named Notepad.exe. -The command stores the process information in the $processes variable. +The first command uses the `Get-WmiObject` cmdlet to get instances of the Windows Management Instrumentation (WMI) Win32_Process class that describes all of the processes on the Server01 computer that are named Notepad.exe. +The command stores the process information in the $Processes variable. -The second command uses a pipeline operator (|) to send the process information in the $processes variable to the Format-Table cmdlet, which displays the ProcessName of each process along with a new calculated property. +The second command uses a pipeline operator (|) to send the process information in the $Processes variable to the `Format-Table` cmdlet, which displays the ProcessName of each process along with a new calculated property. The command assigns the name of the new calculated property, Total Running Time, to the Label key. The script block that is assigned to the Expression key calculates how long the process has been running by subtracting the creation date of the process from the current date. The Get-Date cmdlet gets the current date. -The ConvertToDateTime method converts the CreationDate property of the Win32_Process object from a WMI CIM_DATETIME object to a Microsoft .NET Framework DateTime object that can be compared with the output of Get-Date. +The ConvertToDateTime method converts the CreationDate property of the Win32_Process object from a WMI CIM_DATETIME object to a Microsoft .NET Framework **DateTime** object that can be compared with the output of `Get-Date`. Then, the converted creation date is subtracted from the current date. The result is the value of Total Running Time. + ## PARAMETERS ### -AutoSize -Adjusts the column size and number of columns based on the width of the data. +Indicates that the cmdlet adjusts the column size and number of columns based on the width of the data. By default, the column size and number are determined by the view. ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named -Default value: False +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` ### -DisplayError -Displays errors at the command line. -This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a Format-Table command, and the expressions do not appear to be working. +Indicates that the cmdlet displays errors at the command line. +This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a `Format-Table` command, and the expressions do not appear to be working. The following shows an example of the results of adding the DisplayError parameter with an expression. +```powershell PS \> Get-Date | Format-Table DayOfWeek,{ $_ / $null } -ShowError DayOfWeek $_ / $null --------- ------------ Wednesday #ERR +``` ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named -Default value: False +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` ### -Expand -Formats the collection object, as well as the objects in the collection. +Specifies the format of the collection object, as well as the objects in the collection. This parameter is designed to format objects that support the ICollection (System.Collections) interface. The default value is EnumOnly. - -Valid values are: +The acceptable values for this parameter are: - EnumOnly: Displays the properties of the objects in the collection. - CoreOnly: Displays the properties of the collection object. @@ -167,40 +177,41 @@ Valid values are: ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: +Accepted values: CoreOnly, EnumOnly, Both Required: False Position: Named -Default value: EnumOnly +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` ### -Force -Directs the cmdlet to display all of the error information. -Use with the DisplayError or ShowError parameters. +Indicates that the cmdlet directs the cmdlet to display all of the error information. +Use with the **DisplayError** or **ShowError** parameter. By default, when an error object is written to the error or display streams, only some of the error information is displayed. ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named -Default value: False +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` ### -GroupBy -Arranges sorted output in separate tables based on a property value. -For example, you can use GroupBy to list services in separate tables based on their status. +Specifies sorted output in separate tables based on a property value. +For example, you can use **GroupBy** to list services in separate tables based on their status. Enter an expression or a property of the output. -The output must be sorted before you send it to Format-Table. +The output must be sorted before you send it to `Format-Table`. -The value of the GroupBy parameter can be a new calculated property. +The value of the **GroupBy** parameter can be a new calculated property. To create a calculated, property, use a hash table. Valid keys are: @@ -211,7 +222,7 @@ Valid keys are: ```yaml Type: Object Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -226,23 +237,23 @@ Omits the column headings from the table. ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named -Default value: False +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` ### -InputObject -Specifies the objects to be formatted. +Specifies the objects to format. Enter a variable that contains the objects, or type a command or expression that gets the objects. ```yaml Type: PSObject Parameter Sets: (All) -Aliases: +Aliases: Required: False Position: Named @@ -257,36 +268,37 @@ Type one or more property names (separated by commas), or use a hash table to di Wildcards are permitted. If you omit this parameter, the properties that appear in the display depend on the object being displayed. -The parameter name ("Property") is optional. -You cannot use the Property and View parameters in the same command. +The parameter name (**Property**) is optional. +You cannot use the **Property** and **View** parameters in the same command. -The value of the Property parameter can be a new calculated property. -To create a calculated, property, use a hash table. +The value of the **Property** parameter can be a new calculated property. +To create a calculated property, use a hash table. Valid keys are: - Name (or Label) \ - Expression \ or \