diff --git a/reference/6/Microsoft.PowerShell.Management/Add-Content.md b/reference/6/Microsoft.PowerShell.Management/Add-Content.md index f55c41c4b879..53ccc17878fa 100644 --- a/reference/6/Microsoft.PowerShell.Management/Add-Content.md +++ b/reference/6/Microsoft.PowerShell.Management/Add-Content.md @@ -1,5 +1,5 @@ --- -ms.date: 1/28/2019 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -50,11 +50,9 @@ their file name. Add-Content -Path .\*.txt -Exclude help* -Value 'End of file' ``` -The `Add-Content` cmdlet uses the **Path** parameter to specify all .txt files in the current -directory. The **Exclude** parameter ignores file names that match the specified pattern. The -**Value** parameter specifies the text string that is written to the files. - -Use [Get-Content](Get-Content.md) to display the contents of these files. +The **Path** parameter to specifies all `.txt` files in the current directory, but the **Exclude** +parameter ignores file names that match the specified pattern. The **Value** parameter specifies the +text string that is written to the files. ### Example 2: Add a date to the end of the specified files @@ -66,45 +64,46 @@ Add-Content -Path .\DateTimeFile1.log, .\DateTimeFile2.log -Value (Get-Date) -Pa Get-Content -Path .\DateTimeFile1.log ``` -The `Add-Content` cmdlet uses the **Path** and **Value** parameters to create two new files in the -current directory. The **Value** parameter specifies the `Get-Date` cmdlet to get the date and -passes the date to `Add-Content`. The `Add-Content` cmdlet writes the date to each file. The -**PassThru** parameter passes an object that represents the date object. Because there is no other -cmdlet to receive the passed object, it is displayed in the PowerShell console. The `Get-Content` -cmdlet displays the updated file, DateTimeFile1.log. +```Output +Tuesday, May 14, 2019 8:24:27 AM +Tuesday, May 14, 2019 8:24:27 AM +5/14/2019 8:24:27 AM +``` + +The `Add-Content` creates two new files in the current directory. The **Value** parameter contains +the output of the `Get-Date` The **PassThru** parameter outputs the added contents to the pipeline. +Because there is no other cmdlets to receive the output, it is displayed in the PowerShell console. +The `Get-Content` cmdlet displays the updated file, `DateTimeFile1.log`. ### Example 3: Add the contents of a specified file to another file -This example gets the content from a file and appends that content into another file. +This example gets the content from a file and stores the content in a variable. The variable is +used to append the content into another file. ```powershell -Add-Content -Path .\CopyToFile.txt -Value (Get-Content -Path .\CopyFromFile.txt) +$From = Get-Content -Path .\CopyFromFile.txt +Add-Content -Path .\CopyToFile.txt -Value $From Get-Content -Path .\CopyToFile.txt ``` -The `Add-Content` cmdlet uses the **Path** parameter to specify the new file in the current -directory, CopyToFile.txt. The **Value** parameter uses the `Get-Content` cmdlet to get the -contents of the file, CopyFromFile.txt. The parentheses around the `Get-Content` cmdlet ensure that -the command finishes before the `Add-Content` command begins. The **Value** parameter is passed to -`Add-Content`. The `Add-Content` cmdlet appends the data to the CopyToFile.txt file. The -`Get-Content` cmdlet displays the updated file, CopyToFile.txt. +- The `Get-Content` cmdlet gets the contents of `CopyFromFile.txt` and stores the contents in the + `$From` variable. +- The `Add-Content` cmdlet updates the `CopyToFile.txt` file using the contents of the `$From` + variable. +- The `Get-Content` cmdlet displays CopyToFile.txt. -### Example 4: Use a variable to add the contents of a specified file to another file +### Example 4: Add the contents of a specified file to another file using the pipeline -This example gets the content from a file and stores the content in a variable. The variable is -used to append the content into another file. +This example gets the content from a file and pipes it to the `Add-Content` cmdlet. ```powershell -$From = Get-Content -Path .\CopyFromFile.txt -Add-Content -Path .\CopyToFile.txt -Value $From +Get-Content -Path .\CopyFromFile.txt | Add-Content -Path .\CopyToFile.txt Get-Content -Path .\CopyToFile.txt ``` -The `Get-Content` cmdlet gets the contents of CopyFromFile.txt and stores the contents in the -`$From` variable. The `Add-Content` cmdlet uses the **Path** parameter to specify the -CopyToFile.txt file in the current directory. The **Value** parameter uses the `$From` variable and -passes the content to `Add-Content`. The `Add-Content` cmdlet updates the CopyToFile.txt file. The -`Get-Content` cmdlet displays CopyToFile.txt. +The `Get-Content` cmdlet gets the contents of `CopyFromFile.txt`. The results are piped to the +`Add-Content` cmdlet, which updates the `CopyToFile.txt`. +The last `Get-Content` cmdlet displays `CopyToFile.txt`. ### Example 5: Create a new file and copy content @@ -115,16 +114,16 @@ Add-Content -Path .\NewFile.txt -Value (Get-Content -Path .\CopyFromFile.txt) Get-Content -Path .\NewFile.txt ``` -The `Add-Content` cmdlet uses the **Path** and **Value** parameters to create a new file in the -current directory. The **Value** parameter uses the `Get-Content` cmdlet to get the contents of an -existing file, CopyFromFile.txt. The parentheses around the `Get-Content` cmdlet ensure that the -command finishes before the `Add-Content` command begins. The **Value** parameter passes the -content to `Add-Content` which updates the NewFile.txt file. The `Get-Content` cmdlet displays the -contents of the new file, NewFile.txt. +- The `Add-Content` cmdlet uses the **Path** and **Value** parameters to create a new file in the + current directory. +- The `Get-Content` cmdlet gets the contents of an existing file, `CopyFromFile.txt` + and passes it to the **Value** parameter. The parentheses around the `Get-Content` cmdlet ensure + that the command finishes before the `Add-Content` command begins. +- The `Get-Content` cmdlet displays the contents of the new file, `NewFile.txt`. ### Example 6: Add content to a read-only file -This command adds the value to the file even if the **IsReadOnly** file attribute is set to True. +This command adds a value to the file even if the **IsReadOnly** file attribute is set to **True**. The steps to create a read-only file are included in the example. ```powershell @@ -141,17 +140,32 @@ Mode LastWriteTime Length Name -ar-- 1/28/2019 13:35 0 IsReadOnlyTextFile.txt ``` -The `New-Item` cmdlet uses the **Path** and **ItemType** parameters to create the file -IsReadOnlyTextFile.txt in the current directory. The `Set-ItemProperty` cmdlet uses the **Name** -and **Value** parameters to change the file's **IsReadOnly** property to True. The `Get-ChildItem` -cmdlet shows the file is empty (0) and has the read-only attribute (`r`). The `Add-Content` cmdlet -uses the **Path** parameter to specify the file. The **Value** parameter includes the text string -to append to the file. The **Force** parameter writes the text to the read-only file. The -`Get-Content` cmdlet uses the **Path** parameter to display the file's contents. +- The `New-Item` cmdlet uses the **Path** and **ItemType** parameters to create the file + `IsReadOnlyTextFile.txt` in the current directory. +- The `Set-ItemProperty` cmdlet uses the **Name** and **Value** parameters to change the file's + **IsReadOnly** property to True. +- The `Get-ChildItem` cmdlet shows the file is empty (0) and has the read-only attribute (`r`). +- The `Add-Content` cmdlet uses the **Path** parameter to specify the file. The **Value** parameter + includes the text string to append to the file. The **Force** parameter writes the text to the + read-only file. +- The `Get-Content` cmdlet uses the **Path** parameter to display the file's contents. To remove the read-only attribute, use the `Set-ItemProperty` command with the **Value** parameter set to `False`. +### Example 7: Use Filters with Add-Content + +You can specify a filter to the `Add-Content` cmdlet. When using filters to qualify the **Path** +parameter, you need to include a trailing asterisk (`*`) to indicate the contents of the +path. + +The following command adds the word "Done" the content of all `*.txt` files in the `C:\Temp` +directory. + +```powershell +Add-Content -Path C:\Temp\* -Filter *.txt -Value "Done" +``` + ## PARAMETERS ### -AsByteStream @@ -176,15 +190,10 @@ 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. - -> [!WARNING] +> [!NOTE] > This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -237,8 +246,11 @@ 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**. Wildcards are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -249,16 +261,16 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +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 filters -when objects are retrieved. Otherwise, PowerShell processes filters after the objects are -retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -269,7 +281,7 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Force @@ -292,8 +304,11 @@ Accept wildcard characters: False ### -Include -Adds only the specified items. The value of this parameter qualifies the **Path** parameter. Enter -a path element or pattern, such as **\*.txt**. Wildcards are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -304,15 +319,17 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +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 -PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -364,8 +381,11 @@ Accept wildcard characters: False ### -Path -Specifies the path to the items that receive the additional content. Wildcards are permitted. If -you specify multiple paths, use commas to separate the paths. +Specifies the path to the items that receive the additional content. +Wildcard characters are permitted. +The paths must be paths to items, not to containers. +For example, you must specify a path to one or more files, not a path to a directory. +If you specify multiple paths, use commas to separate the paths. ```yaml Type: String[] @@ -376,7 +396,7 @@ Required: True Position: 0 Default value: None Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Stream @@ -464,7 +484,7 @@ Accept wildcard characters: False This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`, `-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`, `-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see -[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). ## INPUTS @@ -481,17 +501,15 @@ represents 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](../Microsoft.PowerShell.Core/About/about_Aliases.md). - -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](../Microsoft.PowerShell.Core/About/about_Providers.md). +- 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](../Microsoft.PowerShell.Core/About/about_Aliases.md). +- 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](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -507,4 +525,4 @@ providers available in your session, type `Get-PSProvider`. For more information [New-Item](New-Item.md) -[Set-Content](Set-Content.md) \ No newline at end of file +[Set-Content](Set-Content.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Clear-Content.md b/reference/6/Microsoft.PowerShell.Management/Clear-Content.md index 68901f5b1310..622f2b63f941 100644 --- a/reference/6/Microsoft.PowerShell.Management/Clear-Content.md +++ b/reference/6/Microsoft.PowerShell.Management/Clear-Content.md @@ -1,5 +1,5 @@ --- -ms.date: 10/18/2018 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -30,54 +30,86 @@ Clear-Content -LiteralPath [-Filter ] [-Include ] [ ## DESCRIPTION -The `Clear-Content` cmdlet deletes the contents of an item, such as deleting the text from a file, but it does not delete the item. -As a result, the item exists, but it is empty. -The `Clear-Content` is similar to `Clear-Item`, but it works on items with contents, instead of items with values. +The `Clear-Content` cmdlet deletes the contents of an item, such as deleting the text from a file, +but it does not delete the item. As a result, the item exists, but it is empty. +The `Clear-Content` is similar to `Clear-Item`, but it works on items with contents, instead of +items with values. ## EXAMPLES ### Example 1: Delete all content from a directory +This command deletes all of the content from the `init.txt` files in all subdirectories of the +SmpUsers directory. The files are not deleted, but they are empty. + ```powershell Clear-Content "..\SmpUsers\*\init.txt" ``` -This command deletes all of the content from the "init.txt" files in all subdirectories of the SmpUsers directory. -The files are not deleted, but they are empty. - ### Example 2: Delete content of all files with a wildcard +This command deletes the contents of all files in the current directory with the `.log` file name +extension, including files with the read-only attribute. +The asterisk (`*`) in the path represents all items in the current directory. +The **Force** parameter makes the command effective on read-only files. +Using a filter to restrict the command to files with the `.log` file name extension instead of +specifying `*.log` in the path makes the operation faster. + ```powershell Clear-Content -Path "*" -Filter "*.log" -Force ``` -This command deletes the contents of all files in the current directory with the ".log" file name extension, including files with the read-only attribute. -The asterisk (*) in the path represents all items in the current directory. -The **Force** parameter makes the command effective on read-only files. -Using a filter to restrict the command to files with the .log file name extension instead of specifying *.log in the path makes the operation faster. - ### Example 3: Clear all data from a stream -This example shows how the `Clear-Content` cmdlet clears the content from an alternate data stream while leaving the stream intact. +This example shows how the `Clear-Content` cmdlet clears the content from an alternate data stream +while leaving the stream intact. -The first command uses the `Get-Content` cmdlet to get the content of the Zone.Identifier stream in the Copy-Script.ps1 file, which was downloaded from the Internet. - -The second command uses the `Clear-Content` cmdlet to clear the content. +```powershell +Get-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier +``` -The third command repeats the first command. It verifies that the content is cleared, but the stream remains. If the stream were deleted, the command would generate an error. +```Output +[ZoneTransfer] +ZoneId=3 +``` -You can use a method like this one to clear the content of an alternate data stream. However, it is not the recommended 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. +```powershell +Clear-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier +Get-Item C:\Test\Copy-Script.ps1 -Stream * | Select-Object Stream,Length,Filename +``` +```Output +Stream Length FileName +------ ------ -------- +:$DATA 125 C:\Test\Copy-Script.ps1 +Zone.Identifier 0 C:\Test\Copy-Script.ps1 ``` -PS C:\> Get-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier -[ZoneTransfer] -ZoneId=3 +The `Get-Content` cmdlet gets the content of the **Zone.Identifier** stream in the `Copy-Script.ps1` +file, which was downloaded from the Internet. The **ZoneId** shows that the script will be blocked +by **ExecutionPolicy**. The `Clear-Content` cmdlet clears the content of the **Zone.Identifier** +stream. The last command uses `Get-Item` to show that the **Zone.Identifier** stream has been +cleared. -PS C:\>Clear-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier +> [!NOTE] +> You can use a method like this one to clear the content of an alternate data stream. However, it is +> not the recommended way to eliminate security checks that block files that are downloaded from the +> Internet. If you want to verify that a downloaded file is safe, use the [Unblock-File](../Microsoft.PowerShell.Utility/Unblock-File.md) +> cmdlet. -PS C:\>Get-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier -PS C:\> +For more about execution policies, see [about_Execution_Policies](../Microsoft.PowerShell.Core/About/about_Execution_Policies.md). + +### Example 4: Use Filters with Clear-Content + +You can specify a filter to the `Clear-Content` cmdlet. When using filters to qualify the **Path** +parameter, you need to include a trailing asterisk (`*`) to indicate the contents of the +path. + +The following command clears the content of all `*.log` files in the `C:\Temp` +directory. + +```powershell +Clear-Content -Path C:\Temp\* -Filter *.log ``` ## PARAMETERS @@ -91,10 +123,6 @@ Wildcard characters are not supported. Stream is a dynamic parameter that the FileSystem provider adds to `Clear-Content`. This parameter works only in file system drives. -You can use the `Clear-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. - ```yaml Type: String Parameter Sets: (All) @@ -109,14 +137,10 @@ 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. - -> [!WARNING] -> This parameter is not supported by any providers installed with Windows PowerShell. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -132,10 +156,11 @@ Accept wildcard characters: False ### -Exclude -Specifies, as a string array, strings that this cmdlet omits from the path to the content. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcards are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -146,15 +171,16 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +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 PowerShell filter the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -186,10 +212,11 @@ Accept wildcard characters: False ### -Include -Specifies, as a string array, content that this cmdlet clears. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcards are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -205,11 +232,12 @@ Accept wildcard characters: True ### -LiteralPath -Specifies the paths to the items from which content is deleted. -Unlike the **Path** parameter, 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 having PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -226,11 +254,10 @@ Accept wildcard characters: False ### -Path Specifies the paths to the items from which content is deleted. -Wildcards are permitted. The paths must be paths to items, not to containers. For example, you must specify a path to one or more files, not a path to a directory. -Wildcards are permitted. -This parameter is required, but the parameter name ("Path") is optional. +Wildcard characters are permitted. +This parameter is required, but the parameter name **Path** is optional. ```yaml Type: String[] @@ -241,7 +268,7 @@ Required: True Position: 0 Default value: None Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Confirm @@ -279,7 +306,10 @@ 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). +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.md). ## INPUTS @@ -295,12 +325,13 @@ This cmdlet does not return any objects. ## NOTES -You can use `Clear-Content` with the PowerShell FileSystem provider and with other providers that manipulate content. -To clear items that are not considered to be content, such as items managed by the PowerShell Certificate or Registry providers, use `Clear-Item`. - -The `Clear-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](../Microsoft.PowerShell.Core/About/about_Providers.md). +- You can use `Clear-Content` with the PowerShell FileSystem provider and with other providers that + manipulate content. +- To clear items that are not considered to be content, such as items managed by the PowerShell + **Certificate** or **Registry** providers, use `Clear-Item`. +- The `Clear-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](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -310,4 +341,4 @@ For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/a [Get-Item](Get-Item.md) -[Set-Content](Set-Content.md) \ No newline at end of file +[Set-Content](Set-Content.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Clear-Item.md b/reference/6/Microsoft.PowerShell.Management/Clear-Item.md index 6b113ea635fa..9d50f35117e6 100644 --- a/reference/6/Microsoft.PowerShell.Management/Clear-Item.md +++ b/reference/6/Microsoft.PowerShell.Management/Clear-Item.md @@ -1,5 +1,5 @@ --- -ms.date: 10/18/2018 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -31,8 +31,8 @@ Clear-Item -LiteralPath [-Force] [-Filter ] [-Include Clear-Item TestVar1 ``` -### Example 2: Clear all registry entries +The variable remains and is valid, but its value is set to `$null`. The variable name is prefixed +with `Variable:` to indicate the PowerShell **Variable** provider. The alternate commands show that, +to get the same result, you can switch to the PowerShell `Variable:` drive and then run the +`Clear-Item` command. -This command clears all registry entries in the "MyKey" subkey, but only after prompting you to confirm your intent. -It does not delete the "MyKey" subkey or affect any other registry keys or entries. -You can use the **Include** and **Exclude** parameters to identify particular registry keys, but you cannot use them to identify registry entries. +### Example 2: Clear all registry entries -- To delete particular registry entries, use the `Remove-ItemProperty` cmdlet. -- To delete the value of a registry entry, use the `Clear-ItemPropertycmdlet`. +This command clears all registry entries in the "MyKey" subkey, but only after prompting you to +confirm your intent. ```powershell Clear-Item HKLM:\Software\MyCompany\MyKey -Confirm ``` -## PARAMETERS +This command does not delete the "MyKey" subkey or affect any other registry keys or entries. +You can use the **Include** and **Exclude** parameters to identify particular registry keys, but you +cannot use them to identify registry entries. -### -Credential +- To delete particular registry entries, use the `Remove-ItemProperty` cmdlet. +- To delete the value of a registry entry, use the `Clear-ItemPropertycmdlet`. -Specifies a user account that has permission to perform this action. -The default is the current user. +## PARAMETERS -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 are prompted for a password. +### -Credential -> [!WARNING] -> This parameter is not supported by any providers installed with Windows PowerShell. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -94,10 +94,11 @@ Accept wildcard characters: False ### -Exclude -Specifies, as a string array, items to exclude. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as *.txt. -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -113,11 +114,11 @@ Accept wildcard characters: True ### -Filter -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 wildcard characters, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects rather than having PowerShell filter the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -153,10 +154,11 @@ Accept wildcard characters: False ### -Include -Specifies, as a string array, items to that this cmdlet clears. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -172,11 +174,12 @@ Accept wildcard characters: True ### -LiteralPath -Specifies the path to the items being cleared. -Unlike the **Path** parameter, 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 PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -193,8 +196,8 @@ Accept wildcard characters: False ### -Path Specifies the path to the items being cleared. -Wildcards are permitted. -This parameter is required, but the parameter name (Path) is optional. +Wildcard characters are permitted. +This parameter is required, but the parameter name **Path** is optional. ```yaml Type: String[] @@ -205,7 +208,7 @@ Required: True Position: 0 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Confirm @@ -243,7 +246,10 @@ 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). +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.md). ## INPUTS @@ -259,9 +265,12 @@ This cmdlet does not generate any output. ## NOTES -The `Clear-Item` cmdlet is supported only by several PowerShell providers, including the Alias, Environment, Function, Registry, and Variable providers. As such, you can use `Clear-Item` to delete the content of items in the provider namespaces. To list the providers available in your session, type `Get-PsProvider`. For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). - -You cannot use `Clear-Item` to delete the contents of a file, because the PowerShell FileSystem provider does not support this cmdlet. To clear files, use the `Clear-Content`. +- The `Clear-Item` cmdlet is supported only by several PowerShell providers, including the **Alias**, + **Environment**, **Function**, **Registry**, and **Variable** providers. As such, you can use + `Clear-Item` to delete the content of items in the provider namespaces. To list the providers + available in your session, type `Get-PsProvider`. For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). +- You cannot use `Clear-Item` to delete the contents of a file, because the PowerShell FileSystem + provider does not support this cmdlet. To clear files, use the `Clear-Content`. ## RELATED LINKS @@ -281,4 +290,4 @@ You cannot use `Clear-Item` to delete the contents of a file, because the PowerS [Set-Item](Set-Item.md) -[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) \ No newline at end of file +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Clear-ItemProperty.md b/reference/6/Microsoft.PowerShell.Management/Clear-ItemProperty.md index 319e8126115b..f416ddd10f1e 100644 --- a/reference/6/Microsoft.PowerShell.Management/Clear-ItemProperty.md +++ b/reference/6/Microsoft.PowerShell.Management/Clear-ItemProperty.md @@ -1,5 +1,5 @@ --- -ms.date: 10/18/2018 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -39,10 +39,8 @@ You can use this cmdlet to delete the data from a registry value. ### Example 1: Clear the value of registry key -This command clear the data in the "Options" registry value in the "MyApp" subkey of "HKEY_LOCAL_MACHINE\Software\MyCompany". - -Because the command is being issued from a file system drive (`C:`), it uses the fully qualified path to the `HKLM:` drive and the "Software\MyCompany\MyApp" subkey. -It uses the **Name** parameter to specify the "Options" value. +This command clears the data in the "Options" registry value in the "MyApp" subkey of +`HKEY_LOCAL_MACHINE\Software\MyCompany`. ```powershell Clear-ItemProperty -Path "HKLM:\Software\MyCompany\MyApp" -Name "Options" @@ -52,14 +50,10 @@ Clear-ItemProperty -Path "HKLM:\Software\MyCompany\MyApp" -Name "Options" ### -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 are prompted for a password. - -> [!WARNING] -> This parameter is not supported by any providers installed with Windows PowerShell. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -75,10 +69,11 @@ Accept wildcard characters: False ### -Exclude -Specifies, as a string array, an item or items that this cmdlet excludes. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -94,11 +89,11 @@ Accept wildcard characters: True ### -Filter -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 wildcard characters, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects rather than having PowerShell filter the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -114,8 +109,8 @@ Accept wildcard characters: True ### -Force -Indicates that this cmdlet deletes properties from items that cannot otherwise be accessed by the user. -Implementation varies from provider to provider. +Indicates that this cmdlet deletes properties from items that cannot otherwise be accessed by the +user. Implementation varies from provider to provider. For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). ```yaml @@ -132,10 +127,11 @@ Accept wildcard characters: False ### -Include -Specifies, as a string array, an item or items that this cmdlet clears. -The value of this parameter qualifies the *Path* parameter. -Enter a path element or pattern, such as *.txt. -Wildcards are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -146,16 +142,17 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -LiteralPath -Specifies the path to the property being cleared. -Unlike the **Path** parameter, 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 PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -172,7 +169,7 @@ Accept wildcard characters: False ### -Name Specifies the name of the property to be cleared, such as the name of a registry value. -Wildcards are not permitted. +Wildcard characters are permitted. ```yaml Type: String @@ -183,7 +180,7 @@ Required: True Position: 1 Default value: None Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -PassThru @@ -206,7 +203,7 @@ Accept wildcard characters: False ### -Path Specifies the path to the property being cleared. -Wildcards are permitted. +Wildcard characters are permitted. ```yaml Type: String[] @@ -217,7 +214,7 @@ Required: True Position: 0 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Confirm @@ -255,7 +252,10 @@ 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). +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.md). ## INPUTS @@ -267,14 +267,17 @@ You can pipe a path string to this cmdlet. ### None or System.Management.Automation.PSCustomObject -When you use the *PassThru* parameter, `Clear-ItemProperty` generates a **PSCustomObject** object that represents the cleared item property. -Otherwise, this cmdlet does not generate any output. +When you use the **PassThru** parameter, `Clear-ItemProperty` generates a **PSCustomObject** object +that represents the cleared item property. Otherwise, this cmdlet does not generate any output. ## NOTES -You can use `Clear-ItemProperty` to delete the data in registry values without deleting the value. If the data type of the value is Binary or DWORD, clearing the data sets the value to zero. Otherwise, the value is empty. - -The `Clear-ItemProperty` 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. +- You can use `Clear-ItemProperty` to delete the data in registry values without deleting the value. + If the data type of the value is Binary or DWORD, clearing the data sets the value to zero. + Otherwise, the value is empty. +- The `Clear-ItemProperty` 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](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -288,4 +291,4 @@ The `Clear-ItemProperty` cmdlet is designed to work with the data exposed by any [Rename-ItemProperty](Rename-ItemProperty.md) -[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) \ No newline at end of file +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Copy-Item.md b/reference/6/Microsoft.PowerShell.Management/Copy-Item.md index b143ad93919f..3ba033bdcd0f 100644 --- a/reference/6/Microsoft.PowerShell.Management/Copy-Item.md +++ b/reference/6/Microsoft.PowerShell.Management/Copy-Item.md @@ -1,5 +1,5 @@ --- -ms.date: 10/18/2018 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -35,9 +35,9 @@ Copy-Item -LiteralPath [[-Destination] ] [-Container] [-Force The `Copy-Item` cmdlet copies an item from one location to another location in the same namespace. For instance, it can copy a file to a folder, but it cannot copy a file to a certificate drive. -This cmdlet does not cut or delete the items being copied. -The particular items that the cmdlet can copy depend on the PowerShell provider that exposes the item. -For instance, it can copy files and directories in a file system drive and registry keys and entries in the registry drive. +This cmdlet does not cut or delete the items being copied. The particular items that the cmdlet can +copy depend on the PowerShell provider that exposes the item. For instance, it can copy files and +directories in a file system drive and registry keys and entries in the registry drive. This cmdlet can copy and rename items in the same command. To rename an item, enter the new name in the value of the **Destination** parameter. @@ -47,7 +47,7 @@ To rename an item and not copy it, use the `Rename-Item` cmdlet. ### Example 1: Copy a file to the specified directory -This command copies the "mar1604.log.txt" file to the "C:\Presentation" directory. +This command copies the `mar1604.log.txt` file to the `C:\Presentation` directory. The command does not delete the original file. ```powershell @@ -57,17 +57,19 @@ Copy-Item "C:\Wabash\Logfiles\mar1604.log.txt" -Destination "C:\Presentation" ### Example 2: Copy the contents of a directory to another directory This command copies the entire contents of the "Logfiles" directory into the "Drawings" directory. -If the "LogFiles" directory contains files in subdirectories, those subdirectories are copied with their file trees intact. -The **Container** parameter is set to "true" by default. -This preserves the directory structure. ```powershell Copy-Item "C:\Logfiles\*" -Destination "C:\Drawings" -Recurse ``` +If the "LogFiles" directory contains files in subdirectories, those subdirectories are copied with +their file trees intact. The **Container** parameter is set to "true" by default. + +This preserves the directory structure. + ### Example 3: Copy the contents of a directory to another directory and create the destination directory if it does not exist -This command copies the contents of the "C:\Logfiles" directory to the "C:\Drawings\Logs" directory. +This command copies the contents of the `C:\Logfiles` directory to the `C:\Drawings\Logs` directory. It creates the "\Logs" subdirectory if it does not already exist. ```powershell @@ -76,8 +78,10 @@ Copy-Item C:\Logfiles -Destination C:\Drawings\Logs -Recurse ### Example 4: Copy a file to the specified directory and rename the file -This command uses the `Copy-Item` cmdlet to copy the "Get-Widget.ps1" script from the "\\\\Server01\Share" directory to the "\\\\Server12\ScriptArchive" directory. -As part of the copy operation, the command also changes the item name from "Get-Widget.ps1" to "Get-Widget.ps1.txt", so it can be attached to email messages. +This command uses the `Copy-Item` cmdlet to copy the `Get-Widget.ps1` script from the +`\\Server01\Share` directory to the `\\Server12\ScriptArchive` directory. +As part of the copy operation, the command also changes the item name from `Get-Widget.ps1` to +`Get-Widget.ps1.txt`, so it can be attached to email messages. ```powershell Copy-Item "\\Server01\Share\Get-Widget.ps1" -Destination "\\Server12\ScriptArchive\Get-Widget.ps1.txt" @@ -85,10 +89,12 @@ Copy-Item "\\Server01\Share\Get-Widget.ps1" -Destination "\\Server12\ScriptArchi ### Example 5: Copy a file to a remote computer -The first command creates a session to the remote computer named "Server01" with the credential of "Contoso\PattiFul" and stores the results in the variable named `$Session`. +The first command creates a session to the remote computer named "Server01" with the credential of +"Contoso\PattiFu" and stores the results in the variable named `$Session`. -The second command uses the `Copy-Item` cmdlet to copy "test.log" from the "D:\Folder001" folder to the "C:\Folder001_Copy" folder on the remote computer using the session information stored in the `$Session` variable. -This command does not delete the original file. +The second command uses the `Copy-Item` cmdlet to copy `test.log` from the `D:\Folder001` folder to +the `C:\Folder001_Copy` folder on the remote computer using the session information stored in the +`$Session` variable. This command does not delete the original file. ```powershell $Session = New-PSSession -ComputerName "Server01" -Credential "Contoso\PattiFul" @@ -97,10 +103,12 @@ Copy-Item "D:\Folder001\test.log" -Destination "C:\Folder001_Copy\" -ToSession $ ### Example 6: Copy the entire contents of a folder to a remote computer -The first command creates a session to the remote computer named "Server01" with the credential of "Contoso\PattiFul" and stores the results in the variable named `$Session`. +The first command creates a session to the remote computer named "Server01" with the credential of +`Contoso\PattiFul` and stores the results in the variable named `$Session`. -The second command uses the `Copy-Item` cmdlet to copy the entire contents from the "D:\Folder002" folder to the "C:\Folder002_Copy" directory on the remote computer using the session information stored in the `$Session` variable. -The subfolders are copied with their file trees intact. +The second command uses the `Copy-Item` cmdlet to copy the entire contents from the `D:\Folder002` +folder to the `C:\Folder002_Copy` directory on the remote computer using the session information +stored in the `$Session` variable. The subfolders are copied with their file trees intact. ```powershell $Session = New-PSSession -ComputerName "Server02" -Credential "Contoso\PattiFul" @@ -109,11 +117,14 @@ Copy-Item "D:\Folder002\" -Destination "C:\Folder002_Copy\" -ToSession $Session ### Example 7: Recursively copy the entire contents of a folder to a remote computer -The first command creates a session to the remote computer named Server01 with the credential of "Contoso\PattiFul" and stores the results in the variable named `$Session`. +The first command creates a session to the remote computer named Server01 with the credential of +"Contoso\PattiFul" and stores the results in the variable named `$Session`. -The second command uses the `Copy-Item` cmdlet to copy the entire contents from the "D:\Folder003" folder to the "C:\Folder003_Copy" directory on the remote computer using the session information stored in the `$Session` variable. -The subfolders are copied with their file trees intact. -Since this command uses the **Recurse** parameter, the operation creates the "Folder003_Copy" folder if it does not already exist. +The second command uses the `Copy-Item` cmdlet to copy the entire contents from the `D:\Folder003` +folder to the `C:\Folder003_Copy` directory on the remote computer using the session information +stored in the `$Session` variable. The subfolders are copied with their file trees intact. +Since this command uses the **Recurse** parameter, the operation creates the "Folder003_Copy" folder +if it does not already exist. ```powershell $Session = New-PSSession -ComputerName "Server04" -Credential "Contoso\PattiFul" @@ -122,10 +133,14 @@ Copy-Item "D:\Folder003\" -Destination "C:\Folder003_Copy\" -ToSession $Session ### Example 8: Copy a file to a remote computer and then rename the file -The first command creates a session to the remote computer named "Server01" with the credential of "Contoso\PattiFul" and stores the results in the variable named `$Session`. +The first command creates a session to the remote computer named "Server01" with the credential of +"Contoso\PattiFul" and stores the results in the variable named `$Session`. -The second command uses the `Copy-Item` cmdlet to copy "scriptingexample.ps1" from the "D:\Folder004" folder to the "C:\Folder004_Copy" folder on the remote computer using the session information stored in the `$Session` variable. -As part of the copy operation, the command also changes the item name from "scriptingexample.ps1" to "scriptingexample_copy.ps1", so it can be attached to email messages. +The second command uses the `Copy-Item` cmdlet to copy `scriptingexample.ps1` from the +`D:\Folder004` folder to the "C:\Folder004_Copy" folder on the remote computer using the session +information stored in the `$Session` variable. +As part of the copy operation, the command also changes the item name from `scriptingexample.ps1` to +`scriptingexample_copy.ps1`, so it can be attached to email messages. This command does not delete the original file. ```powershell @@ -135,10 +150,12 @@ Copy-Item "D:\Folder004\scriptingexample.ps1" -Destination "C:\Folder004_Copy\sc ### Example 9: Copy a remote file to the local computer -The first command creates a session to the remote computer named "Server01" with the credential of "Contoso\PattiFul" and stores the results in the variable named `$Session`. +The first command creates a session to the remote computer named "Server01" with the credential of +"Contoso\PattiFul" and stores the results in the variable named `$Session`. -The second command uses the `Copy-Item` cmdlet to copy test.log from the remote "C:\MyRemoteData\" to the local "D:\MyLocalData" folder using the session information stored in the `$Session` variable. -This command does not delete the original file. +The second command uses the `Copy-Item` cmdlet to copy test.log from the remote `C:\MyRemoteData\` +to the local `D:\MyLocalData` folder using the session information stored in the `$Session` +variable. This command does not delete the original file. ```powershell $Session = New-PSSession -ComputerName "Server01" -Credential "Contoso\PattiFul" @@ -147,10 +164,14 @@ Copy-Item "C:\MyRemoteData\test.log" -Destination "D:\MyLocalData\" -FromSession ### Example 10: Copy the entire contents of a remote folder to the local computer -The first command creates a session to the remote computer named "Server01" with the credential of "Contoso\PattiFul" and stores the results in the variable named `$Session`. +The first command creates a session to the remote computer named "Server01" with the credential of +"Contoso\PattiFul" and stores the results in the variable named `$Session`. -The second command uses the `Copy-Item` cmdlet to copy the entire contents from the remote "C:\MyRemoteData\scripts" folder to the local "D:\MyLocalData" folder using the session information stored in the `$Session` variable. -If the scripts folder contains files in subfolders, those subfolders are copied with their file trees intact. +The second command uses the `Copy-Item` cmdlet to copy the entire contents from the remote +`C:\MyRemoteData\scripts` folder to the local `D:\MyLocalData` folder using the session information +stored in the `$Session` variable. +If the scripts folder contains files in subfolders, those subfolders are copied with their file +trees intact. ```powershell $Session = New-PSSession -ComputerName "Server01" -Credential "Contoso\PattiFul" @@ -159,10 +180,15 @@ Copy-Item "C:\MyRemoteData\scripts" -Destination "D:\MyLocalData\" -FromSession ### Example 11: Recursively copy the entire contents of a remote folder to the local computer -The first command creates a session to the remote computer named "Server01" with the credential of "Contoso\PattiFul" and stores the results in the variable named `$Session`. +The first command creates a session to the remote computer named "Server01" with the credential of +"Contoso\PattiFul" and stores the results in the variable named `$Session`. -The second command uses the `Copy-Item` cmdlet to copy the entire contents from the remote "C:\MyRemoteData\scripts" folder to the local "D:\MyLocalData\scripts" folder using the session information stored in the `$Session` variable. -Since this command uses the **Recurse** parameter, the operation creates the scripts folder if it does not already exist. If the scripts folder contains files in subfolders, those subfolders are copied with their file trees intact. +The second command uses the `Copy-Item` cmdlet to copy the entire contents from the remote +`C:\MyRemoteData\scripts` folder to the local `D:\MyLocalData\scripts` folder using the session +information stored in the `$Session` variable. +Since this command uses the **Recurse** parameter, the operation creates the scripts folder if it +does not already exist. If the scripts folder contains files in subfolders, those subfolders are +copied with their file trees intact. ```powershell $Session = New-PSSession -ComputerName "Server01" -Credential "Contoso\PattiFul" @@ -189,14 +215,10 @@ 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 are prompted for a password. - -> [!WARNING] -> This parameter is not supported by any providers installed with Windows PowerShell. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -213,7 +235,9 @@ Accept wildcard characters: False ### -Destination Specifies the path to the new location. -To rename a copied item, include the new name in the value. +The default is the current directory. + +To rename the item being copied, specify a new name in the value of the **Destination** parameter. ```yaml Type: String @@ -229,10 +253,11 @@ Accept wildcard characters: False ### -Exclude -Specifies, as a string array, an item or items that this cmdlet excludes from the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -248,11 +273,11 @@ Accept wildcard characters: True ### -Filter -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 wildcard characters, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects rather than having PowerShell filter the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -268,7 +293,8 @@ Accept wildcard characters: True ### -Force -Indicates that this cmdlet copies items that cannot otherwise be changed, such as copying over a read-only file or alias. +Indicates that this cmdlet copies items that cannot otherwise be changed, such as copying over a +read-only file or alias. ```yaml Type: SwitchParameter @@ -285,7 +311,8 @@ Accept wildcard characters: False ### -FromSession Specifies the **PSSession** object from which a remote file is being copied. -When you use this parameter, the *Path* and *LiteralPath* parameters refer to the local path on the remote machine. +When you use this parameter, the *Path* and *LiteralPath* parameters refer to the local path on the +remote machine. ```yaml Type: PSSession @@ -301,10 +328,11 @@ Accept wildcard characters: False ### -Include -Specifies, as a string array, an item or items that this cmdlet includes in the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -315,16 +343,17 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -LiteralPath -Specifies a path to the item. -Unlike the **Path** parameter, 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 PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -358,6 +387,7 @@ Accept wildcard characters: False ### -Path Specifies, as a string array, the path to the items to copy. +Wildcard characters are permitted. ```yaml Type: String[] @@ -368,7 +398,7 @@ Required: True Position: 0 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Recurse @@ -390,7 +420,8 @@ Accept wildcard characters: False ### -ToSession Specifies the **PSSession** object to which a remote file is being copied. -When you use this parameter, the *Path* and *LiteralPath* parameters refer to the local path on the remote machine. +When you use this parameter, the **Path** and **LiteralPath** parameters refer to the local path on the +remote machine. ```yaml Type: PSSession @@ -439,7 +470,10 @@ 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). +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.md). ## INPUTS @@ -451,8 +485,8 @@ You can pipe a string that contains a path to this cmdlet. ### None or an object representing the copied item. -When you use the *PassThru* parameter, this cmdlet returns an object that represents the copied item. -Otherwise, this cmdlet does not generate any output. +When you use the *PassThru* parameter, this cmdlet returns an object that represents the copied +item. Otherwise, this cmdlet does not generate any output. ## NOTES @@ -480,4 +514,4 @@ For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/a [Get-PSProvider](Get-PSProvider.md) -[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) \ No newline at end of file +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Copy-ItemProperty.md b/reference/6/Microsoft.PowerShell.Management/Copy-ItemProperty.md index e62d6ba274ce..89361557f4ee 100644 --- a/reference/6/Microsoft.PowerShell.Management/Copy-ItemProperty.md +++ b/reference/6/Microsoft.PowerShell.Management/Copy-ItemProperty.md @@ -1,5 +1,5 @@ --- -ms.date: 10/18/2018 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -32,14 +32,17 @@ Copy-ItemProperty -LiteralPath [-Name] [-Destination] [!WARNING] -> This parameter is not supported by any providers installed with Windows PowerShell. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -88,10 +87,11 @@ Accept wildcard characters: False ### -Exclude -Specifies, as a string array, an item or items that this cmdlet excludes. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -107,11 +107,11 @@ Accept wildcard characters: True ### -Filter -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 wildcard characters, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects rather than having PowerShell filter the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -129,6 +129,7 @@ Accept wildcard characters: True Forces the command to run without asking for user confirmation. Implementation varies from provider to provider. + For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). ```yaml @@ -145,10 +146,11 @@ Accept wildcard characters: False ### -Include -Specifies, as a string array, an item or items that this cmdlet includes in the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -159,16 +161,17 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -LiteralPath -Specifies the path to the current location of the property. -Unlike the **Path** parameter, 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 PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -218,6 +221,7 @@ Accept wildcard characters: False ### -Path Specifies, as a string array, the path to the property to be copied. +Wildcard characters are permitted. ```yaml Type: String[] @@ -228,7 +232,7 @@ Required: True Position: 0 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Confirm @@ -266,7 +270,10 @@ 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). +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.md). ## INPUTS @@ -278,12 +285,13 @@ You can pipe a string that contains a path to this cmdlet. ### None or System.Management.Automation.PSCustomObject -When you use the **Passthru** parameter, this cmdlet generates a **PsCustomObject** representing the copied item property. -Otherwise, this cmdlet does not generate any output. +When you use the **Passthru** parameter, this cmdlet generates a **PsCustomObject** representing the +copied item property. Otherwise, this cmdlet does not generate any output. ## NOTES -This 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. +This 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](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -301,4 +309,4 @@ This cmdlet is designed to work with the data exposed by any provider. To list t [Get-PSProvider](Get-PSProvider.md) -[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) \ No newline at end of file +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Get-ChildItem.md b/reference/6/Microsoft.PowerShell.Management/Get-ChildItem.md index 3ae941fc5037..49144a9d6524 100644 --- a/reference/6/Microsoft.PowerShell.Management/Get-ChildItem.md +++ b/reference/6/Microsoft.PowerShell.Management/Get-ChildItem.md @@ -1,5 +1,5 @@ --- -ms.date: 03/22/2019 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -53,15 +53,14 @@ This example gets the child items from a file system directory. The file names a names are displayed. For empty locations the command does not return any output and returns to the PowerShell prompt. -By default `Get-ChildItem` lists the mode (attributes), last write time, file size (length), and the -name of the item. The letters in the **Mode** property can be interperted as follows: `l` (link), -`d` (directory), `a` (archive), `r` (read-only), `h` (hidden), and `s` (system). For more -information about the mode flags, see -[about_Filesystem_Provider](../microsoft.powershell.core/about/about_filesystem_provider.md#attributes-flagsexpression). +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory `C:\Test`. +`Get-ChildItem` displays the files and directories in the PowerShell console. +```powershell +Get-ChildItem -Path C:\Test ``` -PS> Get-ChildItem -Path C:\Test +```Output Directory: C:\Test Mode LastWriteTime Length Name @@ -73,16 +72,31 @@ d----- 2/15/2019 08:29 Logs -ar--- 2/12/2019 14:31 27 ReadOnlyFile.txt ``` -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory **C:\Test**. -`Get-ChildItem` displays the files and directories in the PowerShell console. +By default `Get-ChildItem` lists the mode (**Attributes**), **LastWriteTime**, file size (**Length**), +and the **Name** of the item. The letters in the **Mode** property can be interperted as follows: + +- `l` (link) +- `d` (directory) +- `a` (archive) +- `r` (read-only) +- `h` (hidden) +- `s` (system). + +For more information about the mode flags, see +[about_Filesystem_Provider](../microsoft.powershell.core/about/about_filesystem_provider.md#attributes-flagsexpression). ### Example 2: Get child item names in a directory This command lists only the names of items in a directory. +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory `C:\Test`. The +**Name** parameter returns only the file or directory names from the specified path. + +```powershell +Get-ChildItem -Path C:\Test -Name ``` -PS> Get-ChildItem -Path C:\Test -Name +```Output Logs anotherfile.txt Command.txt @@ -90,17 +104,16 @@ CreateTestFile.ps1 ReadOnlyFile.txt ``` -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory **C:\Test**. The -**Name** parameter returns only the file or directory names from the specified path. - ### Example 3: Get child items in the current directory and subdirectories This example displays **.txt** files that are located in the current directory and its subdirectories. +```powershell +Get-ChildItem -Path C:\Test\*.txt -Recurse -Force ``` -PS> Get-ChildItem -Path C:\Test\*.txt -Recurse -Force +```Output Directory: C:\Test\Logs\Adirectory Mode LastWriteTime Length Name @@ -145,9 +158,21 @@ of **h**. In this example `Get-ChildItem` uses the **Include** parameter to find specific items from the directory specified by the **Path** parameter. +```powershell +# When using the -Include parameter, if you do not include an asterisk in the path +# the command returns no output. +Get-ChildItem -Path C:\Test\ -Include *.txt +``` + +```Output + ``` -PS> Get-ChildItem -Path C:\Test\* -Include *.txt +```powershell +Get-ChildItem -Path C:\Test\* -Include *.txt +``` + +```Output Directory: C:\Test Mode LastWriteTime Length Name @@ -165,21 +190,22 @@ extension **.txt**. When the **Include** parameter is used, the **Path** parameter needs a trailing asterisk (`*`) wildcard to specify the directory's contents. For example, `-Path C:\Test\*`. -If a trailing asterisk (`*`) is not included in the **Path** parameter, the command does not return -any output and returns to the PowerShell prompt. For example, `-Path C:\Test\`. - -If the **Recurse** parameter is added to the command, a trailing asterisk (`*`) in the **Path** -parameter is optional. The **Recurse** parameter gets items from the **Path** directory and its -subdirectories. +- If the **Recurse** parameter is added to the command, the trailing asterisk (`*`) in the **Path** + parameter is optional. The **Recurse** parameter gets items from the **Path** directory and its + subdirectories. For example, `-Path C:\Test\ -Recurse -Include *.txt` +- If a trailing asterisk (`*`) is not included in the **Path** parameter, the command does not return + any output and returns to the PowerShell prompt. For example, `-Path C:\Test\`. ### Example 5: Get child items using the Exclude parameter -In this example `Get-ChildItem` uses the **Exclude** parameter to exclude the output of specific -items from the directory specified by the **Path** parameter. +The example's output shows the contents of the directory **C:\Test\Logs**. The output is a reference +for the other commands that use the **Exclude** and **Recurse** parameters. +```powershell +Get-ChildItem -Path C:\Test\Logs ``` -PS> Get-ChildItem -Path C:\Test\Logs +```Output Directory: C:\Test\Logs Mode LastWriteTime Length Name @@ -190,93 +216,45 @@ d----- 2/15/2019 13:21 Backup -a---- 2/12/2019 16:16 20 Afile.txt -a---- 2/13/2019 13:26 20 LogFile1.txt -a---- 2/12/2019 16:24 23 systemlog1.log +``` +```powershell +Get-ChildItem -Path C:\Test\Logs\* -Exclude A* +``` -PS> Get-ChildItem -Path C:\Test\Logs -Exclude A* - - Directory: C:\Test\Logs - -Mode LastWriteTime Length Name ----- ------------- ------ ---- -d----- 2/15/2019 13:21 Backup --a---- 2/13/2019 13:26 20 LogFile1.txt --a---- 2/12/2019 16:24 23 systemlog1.log - - -PS> Get-ChildItem -Path C:\Test\Logs\* -Exclude A* - - Directory: C:\Test\Logs\Backup - -Mode LastWriteTime Length Name ----- ------------- ------ ---- --a---- 2/12/2019 15:50 20 LogFile3.txt --a---- 2/12/2019 16:24 23 systemlog1.log - - Directory: C:\Test\Logs - -Mode LastWriteTime Length Name ----- ------------- ------ ---- --a---- 2/13/2019 13:26 20 LogFile1.txt --a---- 2/12/2019 16:24 23 systemlog1.log - - -PS> Get-ChildItem -Path C:\Test\Logs\* -Exclude A* -Recurse - - Directory: C:\Test\Logs\Adirectory - -Mode LastWriteTime Length Name ----- ------------- ------ ---- --a---- 2/13/2019 13:26 20 LogFile4.txt --a---- 2/12/2019 16:24 23 systemlog1.log - +```Output Directory: C:\Test\Logs Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2/15/2019 13:21 Backup - - Directory: C:\Test\Logs\Backup - -Mode LastWriteTime Length Name ----- ------------- ------ ---- --a---- 2/12/2019 15:50 20 LogFile3.txt --a---- 2/12/2019 16:24 23 systemlog1.log - - Directory: C:\Test\Logs - -Mode LastWriteTime Length Name ----- ------------- ------ ---- -a---- 2/13/2019 13:26 20 LogFile1.txt -a---- 2/12/2019 16:24 23 systemlog1.log ``` -The example's output shows the contents of the directory **C:\Test\Logs**. The output is a reference -for the other commands that use the **Exclude** and **Recurse** parameters. - -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory **C:\Test\Logs**. +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the directory `C:\Test\Logs`. The **Exclude** parameter uses the asterisk (`*`) wildcard to specify any files or directories that begin with **A** or **a** are excluded from the output. When the **Exclude** parameter is used, a trailing asterisk (`*`) in the **Path** parameter is optional. For example, `-Path C:\Test\Logs` or `-Path C:\Test\Logs\*`. -If a trailing asterisk (`*`) is not included in the **Path** parameter, the contents of the **Path** -parameter are displayed. The exceptions are file names or subdirectory names that match the -**Exclude** parameter's value. - -If a trailing asterisk (`*`) is included in the **Path** parameter, the command recurses into the -**Path** parameter's subdirectories. The exceptions are file names or subdirectory names that match -the **Exclude** parameter's value. - -If the **Recurse** parameter is added to the command, the recursion output is the same whether or -not the **Path** parameter includes a trailing asterisk (`*`). The **Recurse** parameter does a -recursion of the directory **Adirectory** even though the directory name matches the **Exclude** -parameter's value. The files in **Adirectory** that match the **Exclude** parameter's value are -excluded from the output. +- If a trailing asterisk (`*`) is not included in the **Path** parameter, the contents of the **Path** + parameter are displayed. The exceptions are file names or subdirectory names that match the + **Exclude** parameter's value. +- If a trailing asterisk (`*`) is included in the **Path** parameter, the command **recurses** into the + **Path** parameter's subdirectories. The exceptions are file names or subdirectory names that match + the **Exclude** parameter's value. +- If the **Recurse** parameter is added to the command, the recursion output is the same whether or + not the **Path** parameter includes a trailing asterisk (`*`). ### Example 6: Get the registry keys from a registry hive This command gets all of the registry keys from the **HKEY_LOCAL_MACHINE\HARDWARE** registry hive. + +`Get-ChildItem` uses the **Path** parameter to specify the registry hive **HKLM:\HARDWARE**. The +hive's path and top level of registry keys are displayed in the PowerShell console. + For more information, see [about_Registry_Provider](../Microsoft.PowerShell.Core/About/about_Registry_Provider.md). ```powershell @@ -295,22 +273,21 @@ RESOURCEMAP UEFI ``` -`Get-ChildItem` uses the **Path** parameter to specify the registry hive **HKLM:\HARDWARE**. The -hive's path and top level of registry keys are displayed in the PowerShell console. - ### Example 7: Get all certificates with code-signing authority This command gets each certificate in the PowerShell **Cert:** drive that has code-signing -authority. For more information about the Certificate provider and the Cert: drive, -see [about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). +authority. + +The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the **Cert:** provider. The +**Recurse** parameter searches the directory specified by **Path** and its subdirectories. The +**CodeSigningCert** parameter gets only certificates that have code-signing authority. ```powershell Get-ChildItem -Path Cert:\* -Recurse -CodeSigningCert ``` -The `Get-ChildItem` cmdlet uses the **Path** parameter to specify the **Cert:** provider. The -**Recurse** parameter searches the directory specified by **Path** and its subdirectories. The -**CodeSigningCert** parameter gets only certificates that have code-signing authority. +For more information about the Certificate provider and the Cert: drive, +see [about_Certificate_Provider](../Microsoft.PowerShell.Security/About/about_Certificate_Provider.md). ### Example 8: Get items using the Depth parameter @@ -318,9 +295,11 @@ This command displays the items in a directory and its subdirectories. The **Dep determines the number of subdirectory levels to include in the recursion. Empty directories are excluded from the output. -``` +```powershell Get-ChildItem -Path C:\Parent -Depth 2 +``` +```Output Directory: C:\Parent Mode LastWriteTime Length Name @@ -349,7 +328,7 @@ specified by the **Path** parameter and the two levels of subdirectories. ### Example 9: Getting hard link information -In 6.2, an alternate view was added to get hard link information. +In PowerShell 6.2, an alternate view was added to get hard link information. ```powershell Get-ChildItem -Path C:\PathContainingHardLink | Format-Table -View childrenWithHardLink @@ -429,8 +408,9 @@ For example, `Depth 2` includes the **Path** parameter's directory, first level and second level of subdirectories. By default directory names and file names are included in the output. -On a Windows computer from PowerShell or **cmd.exe**, you can display a graphical view of a -directory structure with the **tree.com** command. +> [!NOTE] +> On a Windows computer from PowerShell or **cmd.exe**, you can display a graphical view of a +> directory structure with the **tree.com** command. ```yaml Type: UInt32 @@ -503,12 +483,11 @@ Accept wildcard characters: False ### -Filter -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 wildcard characters, depends on the provider. Filters -are more efficient than other parameters, because the provider applies them when the cmdlet gets the -objects. Otherwise, PowerShell filters the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -516,10 +495,10 @@ Parameter Sets: (All) Aliases: Required: False -Position: 1 +Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -FollowSymlink @@ -581,12 +560,9 @@ Accept wildcard characters: False Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as -`*.txt`. Wildcard characters are accepted. - -**Include** needs the **Path** parameter to use a trailing asterisk (`*`) to specify the directory's -contents, such as: `-Path C:\Test\Logs\*` If there is no trailing asterisk (`*`), add the -**Recurse** parameter to the command. Otherwise the `Get-ChildItem` command fails. More details are -included in Example 4 and the Notes section. +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -605,7 +581,9 @@ Accept wildcard characters: True Specifies a path to one or more locations. 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 PowerShell not to interpret any characters -as escape sequences. For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -707,7 +685,7 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). ## INPUTS @@ -727,27 +705,13 @@ If you use the **Name** parameter, `Get-ChildItem` returns the object names as s ## NOTES -You can investigate the file names or directories that `Get-ChildItem` searches when you use the -**Include** or **Exclude** parameters. Use the `ForEach-Object` and `Split-Path` cmdlets as shown in -these examples: - -`PS> Get-ChildItem -Path C:\Test\Logs\* -Include *.txt -Recurse | ForEach-Object {Split-Path $_.FullName -Parent}` - -`PS> Get-ChildItem -Path C:\Test\Logs\* -Include *.txt -Recurse | ForEach-Object {Split-Path $_.FullName -Leaf}` - -`PS> Get-ChildItem -Path C:\Test\Logs -Exclude A* -Recurse | ForEach-Object {Split-Path $_.FullName -Parent}` - -`PS> Get-ChildItem -Path C:\Test\Logs -Exclude A* -Recurse | ForEach-Object {Split-Path $_.FullName -Leaf}` - -You can refer to `Get-ChildItem` by its built-in aliases, `ls`, `dir`, and `gci`. For more -information, see [about_Aliases](../Microsoft.PowerShell.Core/About/about_Aliases.md). - -`Get-ChildItem` does not get hidden items by default. To get hidden items, use the **Force** -parameter. - -The `Get-ChildItem` 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](../Microsoft.PowerShell.Core/About/about_Providers.md). +- You can refer to `Get-ChildItem` by its built-in aliases, `ls`, `dir`, and `gci`. For more + information, see [about_Aliases](../Microsoft.PowerShell.Core/About/about_Aliases.md). +- `Get-ChildItem` does not get hidden items by default. To get hidden items, use the **Force** + parameter. +- The `Get-ChildItem` 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](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -771,4 +735,4 @@ For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/a [Get-PSProvider](Get-PSProvider.md) -[Split-Path](Split-Path.md) \ No newline at end of file +[Split-Path](Split-Path.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Get-Content.md b/reference/6/Microsoft.PowerShell.Management/Get-Content.md index e358dc160b15..a333d9700fe9 100644 --- a/reference/6/Microsoft.PowerShell.Management/Get-Content.md +++ b/reference/6/Microsoft.PowerShell.Management/Get-Content.md @@ -1,5 +1,5 @@ --- -ms.date: 4/1/2019 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -7,7 +7,6 @@ online version: http://go.microsoft.com/fwlink/?LinkId=821583 external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml title: Get-Content --- - # Get-Content ## SYNOPSIS @@ -92,13 +91,6 @@ This command gets a specific number of lines from a file and then displays only that content. The **TotalCount** parameter gets the first 25 lines of content. This example uses the `LineNumbers.txt` file that was created in Example 1. -The `Get-Content` command is wrapped in parentheses so that the command completes before going to -the next step. - -The `Get-Content` cmdlet returns an array of lines, this allows you to add the index notation after -the parenthesis to retrieve a specific line number. In this case, the `[-1]` index specifies the -last index in the returned array of 25 retrieved lines. - ```powershell (Get-Content -Path .\LineNumbers.txt -TotalCount 25)[-1] ``` @@ -107,17 +99,16 @@ last index in the returned array of 25 retrieved lines. This is Line 25 ``` +The `Get-Content` command is wrapped in parentheses so that the command completes before going to +the next step. `Get-Content`returns an array of lines, this allows you to add the index notation after +the parenthesis to retrieve a specific line number. In this case, the `[-1]` index specifies the +last index in the returned array of 25 retrieved lines. + ### Example 4: Get the last line of a text file This command gets the first line and last line of content from a file. This example uses the `LineNumbers.txt` file that was created in Example 1. -This example uses the `Get-Item` cmdlet to demonstrate that you can pipe files into the -`Get-Content` parameter. - -The **Tail** parameter gets the last line of the file. This method is faster than retrieving all of -the lines and using the `[-1]` index notation. - ```powershell Get-Item -Path .\LineNumbers.txt Get-Content -Tail 1 ``` @@ -126,18 +117,16 @@ Get-Item -Path .\LineNumbers.txt Get-Content -Tail 1 This is Line 100 ``` +This example uses the `Get-Item` cmdlet to demonstrate that you can pipe files into the +`Get-Content` parameter. The **Tail** parameter gets the last line of the file. This method is +faster than retrieving all of the lines and using the `[-1]` index notation. + ### Example 5: Get the content of an alternate data stream This example describes how to use the **Stream** parameter to get the content of an alternate data stream for files stored on a Windows NTFS volume. In this example, the `Set-Content` cmdlet is used to create sample content in a file named `Stream.txt`. -The **Stream** parameter is a dynamic parameter of the -[FileSystem provider](../microsoft.powershell.core/about/about_filesystem_provider.md#stream-systemstring). -By default `Get-Content` only retrieves data from the primary, or `$DATA` stream. - -**Streams** can be used to store hidden data such as attributes, security settings, or other data. - ```powershell Set-Content -Path .\Stream.txt -Value 'This is the content of the Stream.txt file' # Specify a wildcard to the Stream parameter to display all streams of the recently created file. @@ -203,6 +192,11 @@ Get-Content -Path .\Stream.txt -Stream NewStream Added a stream named NewStream to Stream.txt ``` +The **Stream** parameter is a dynamic parameter of the +[FileSystem provider](../microsoft.powershell.core/about/about_filesystem_provider.md#stream-systemstring). +By default `Get-Content` only retrieves data from the primary, or `$DATA` stream. **Streams** can be +used to store hidden data such as attributes, security settings, or other data. + ### Example 6: Get raw content The commands in this example get the contents of a file as one string, instead of an array of @@ -222,11 +216,26 @@ Raw contains 1 lines. Lines contains 100 lines. ``` +### Example 7: Use Filters with Get-Content + +You can specify a filter to the `Get-Content` cmdlet. When using filters to qualify the **Path** +parameter, you need to include a trailing asterisk (`*`) to indicate the contents of the +path. + +The following command gets the content of all `*.log` files in the `C:\Temp` directory. + +```powershell +Get-Content -Path C:\Temp\* -Filter *.log +``` + ## PARAMETERS ### -Path -Specifies the path to an item where `Get-Content` gets the content. Wildcards are permitted. +Specifies the path to an item where `Get-Content` gets the content. +Wildcard characters are permitted. +The paths must be paths to items, not to containers. +For example, you must specify a path to one or more files, not a path to a directory. ```yaml Type: String[] @@ -242,10 +251,12 @@ Accept wildcard characters: True ### -LiteralPath -Specifies the path to an item. Unlike the **Path** parameter, 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 PowerShell not to -interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -319,10 +330,11 @@ Accept wildcard characters: False ### -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 filters -when objects are retrieved. Otherwise, PowerShell processes filters after the objects are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -338,9 +350,11 @@ Accept wildcard characters: True ### -Include -Specifies, as a string array, the item that this cmdlet includes in the operation. The value of this -parameter qualifies the **Path** parameter. Enter a path element or pattern, such as `*.txt`. -Wildcards are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -356,9 +370,15 @@ Accept wildcard characters: True ### -Exclude -Specifies, as a string array, the item that this cmdlet omits when performing the operation. The -value of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as -`*.txt`. Wildcards are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. +The value of this parameter qualifies the **Path** parameter. + +Enter a path element or pattern, such as `*.txt`. +Wildcard characters are permitted. + +The **Exclude** parameter is effective only when the command includes the contents of an item, +such as `C:\Windows\*`, where the wildcard character specifies the contents of the `C:\Windows` +directory. ```yaml Type: String[] @@ -391,12 +411,10 @@ 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. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -423,12 +441,12 @@ as the delimiter. The delimiter is preserved (not discarded) and becomes the las section. **Delimiter** is a dynamic parameter that the **FileSystem** provider adds to the `Get-Content` -cmdlet This parameter works only in file system drives. +cmdlet. This parameter works only in file system drives. > [!NOTE] > Currently, when the value of the **Delimiter** parameter is an empty string, `Get-Content` does -> not return anything. This is a known issue To force `Get-Content` to return the entire file as a -> single, undelimited string, enter a value that does not exist in the file. +> not return anything. This is a known issue. To force `Get-Content` to return the entire file as +> a single, undelimited string. Enter a value that does not exist in the file. ```yaml Type: String @@ -573,7 +591,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`, `-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`, -`-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +`-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see +[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). ## INPUTS @@ -591,7 +610,8 @@ specify as input. ## NOTES The `Get-Content` cmdlet is designed to work with the data exposed by any provider. To get the -providers in your session, use the `Get-PSProvider` cmdlet. For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). +providers in your session, use the `Get-PSProvider` cmdlet. For more information, see +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -607,4 +627,4 @@ providers in your session, use the `Get-PSProvider` cmdlet. For more information [Get-PSProvider](Get-PSProvider.md) -[Set-Content](Set-Content.md) \ No newline at end of file +[Set-Content](Set-Content.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Get-Item.md b/reference/6/Microsoft.PowerShell.Management/Get-Item.md index 5b216ff7f27a..d07080817cb5 100644 --- a/reference/6/Microsoft.PowerShell.Management/Get-Item.md +++ b/reference/6/Microsoft.PowerShell.Management/Get-Item.md @@ -1,5 +1,5 @@ --- -ms.date: 03/22/2019 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -10,7 +10,6 @@ title: Get-Item # Get-Item ## SYNOPSIS - Gets the item at the specified location. ## SYNTAX @@ -32,7 +31,8 @@ Get-Item -LiteralPath [-Filter ] [-Include ] [-Excl ## DESCRIPTION The `Get-Item` cmdlet gets the item at the specified location. -It does not get the contents of the item at the location unless you use a wildcard character ('*') to request all the contents of the item. +It does not get the contents of the item at the location unless you use a wildcard character ('*') +to request all the contents of the item. This cmdlet is used by PowerShell providers to navigate through different types of data stores. @@ -89,18 +89,19 @@ Get-Item C:\ ### Example 4: Get items in the specified drive This command gets the items in the C: drive. -The wildcard character ('*') represents all the items in the container, not just the container. - -In PowerShell, use a single asterisk ('*') to get contents, instead of the traditional "*.*". -The format is interpreted literally, so "*.*" would not retrieve directories or file names without a dot. +The wildcard character (`*`) represents all the items in the container, not just the container. ```powershell Get-Item C:\* ``` +In PowerShell, use a single asterisk (`*`) to get contents, instead of the traditional `*.*`. +The format is interpreted literally, so `*.*` would not retrieve directories or file names without a +dot. + ### Example 5: Get a property in the specified directory -This command gets the **LastAccessTime** property of the "C:\Windows" directory. +This command gets the **LastAccessTime** property of the `C:\Windows` directory. **LastAccessTime** is just one property of file system directories. To see all of the properties of a directory, type `(Get-Item \) | Get-Member`. @@ -111,7 +112,8 @@ To see all of the properties of a directory, type `(Get-Item \) ### Example 6: Show the contents of a registry key This command shows the contents of the **Microsoft.PowerShell** registry key. -You can use this cmdlet with the PowerShell Registry provider to get registry keys and subkeys, but you must use the `Get-ItemProperty` cmdlet to get the registry values and data. +You can use this cmdlet with the PowerShell Registry provider to get registry keys and subkeys, +but you must use the `Get-ItemProperty` cmdlet to get the registry values and data. ```powershell Get-Item HKLM:\Software\Microsoft\Powershell\1\Shellids\Microsoft.Powershell\ @@ -119,16 +121,17 @@ Get-Item HKLM:\Software\Microsoft\Powershell\1\Shellids\Microsoft.Powershell\ ### Example 7: Get items in a directory that have an exclusion -This command gets items in the Windows directory with names that include a dot ('.'), but do not begin with "w*". -This command works only when the path includes a wildcard character ('*') to specify the contents of the item. +This command gets items in the Windows directory with names that include a dot (`.`), but do not +begin with `w*`.This command works only when the path includes a wildcard character (`*`) to specify +the contents of the item. ```powershell -Get-Item c:\Windows\*.* -Exclude "w*" +Get-Item C:\Windows\*.* -Exclude "w*" ``` ### Example 8: Getting hardlink information -In 6.2, an alternate view was added to get hardlink information. +In PowerShell 6.2, an alternate view was added to get hardlink information. To get the hardlink information, pipe the output to `Format-Table -View childrenWithHardlink` ```powershell @@ -139,9 +142,11 @@ Get-Item -Path C:\PathWhichIsAHardLink | Format-Table -View childrenWithHardlink ### -Stream -Gets the specified alternate NTFS file stream from the file. Enter the stream name. Wildcards are supported. To get all streams, use an asterisk (*). This parameter is not valid on folders. +Gets the specified alternate NTFS file stream from the file. Enter the stream name. Wildcards are +supported. To get all streams, use an asterisk (`*`). This parameter is not valid on folders. -Stream is a dynamic parameter that the FileSystem provider adds to the `Get-Item` cmdlet. This parameter works only in file system drives. +**Stream** is a dynamic parameter that the **FileSystem** provider adds to the `Get-Item` cmdlet. +This parameter works only in file system drives. ```yaml Type: String[] @@ -157,14 +162,10 @@ Accept wildcard characters: True ### -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 are prompted for a password. - -> [!WARNING] -> This parameter is not supported by any providers installed with Windows PowerShell. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -180,12 +181,11 @@ Accept wildcard characters: False ### -Exclude -Specifies, as a string array, an item or items that this cmdlet excludes in the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. - -The **Exclude** parameter is effective only when the command includes the contents of an item, such as "C:\Windows\*", where the wildcard character specifies the contents of the "C:\Windows" directory. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -201,11 +201,11 @@ Accept wildcard characters: True ### -Filter -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 wildcard characters, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects rather than having PowerShell filter the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -240,12 +240,11 @@ Accept wildcard characters: False ### -Include -Specifies, as a string array, an item or items that this cmdlet includes in the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. - -The **Include** parameter is effective only when the command includes the contents of an item, such as "C:\Windows\*", where the wildcard character specifies the contents of the "C:\Windows" directory. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -261,11 +260,12 @@ Accept wildcard characters: True ### -LiteralPath -Specifies a path to the item. -Unlike the **Path** parameter, 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 PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -283,11 +283,11 @@ Accept wildcard characters: False Specifies the path to an item. This cmdlet gets the item at the specified location. -Wildcards are permitted. -This parameter is required, but the parameter name ("Path") is optional. +Wildcard characters are permitted. +This parameter is required, but the parameter name **Path** is optional. -Use a dot ('.') to specify the current location. -Use the wildcard character ('*') to specify all the items in the current location. +Use a dot (`.`) to specify the current location. +Use the wildcard character (`*`) to specify all the items in the current location. ```yaml Type: String[] @@ -298,12 +298,15 @@ Required: True Position: 0 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). +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.md). ## INPUTS @@ -320,15 +323,12 @@ The type is determined by the type of objects in the path. ## NOTES -This cmdlet does not have a **Recurse** parameter, because it gets only an item, not its contents. -To get the contents of an item recursively, use `Get-ChildItem`. - -To navigate through the registry, use this cmdlet to get registry keys and the `Get-ItemProperty` to get registry values and data. -The registry values are considered to be properties of the registry key. - -This 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](../Microsoft.PowerShell.Core/About/about_Providers.md). +- To navigate through the registry, use this cmdlet to get registry keys and the `Get-ItemProperty` to + get registry values and data. The registry values are considered to be properties of the registry + key. +- This 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](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -354,4 +354,4 @@ For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/a [Get-PSProvider](Get-PSProvider.md) -[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) \ No newline at end of file +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Get-ItemProperty.md b/reference/6/Microsoft.PowerShell.Management/Get-ItemProperty.md index 34979720621f..6cb9e121f984 100644 --- a/reference/6/Microsoft.PowerShell.Management/Get-ItemProperty.md +++ b/reference/6/Microsoft.PowerShell.Management/Get-ItemProperty.md @@ -1,5 +1,5 @@ --- -ms.date: 10/18/2018 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -31,14 +31,14 @@ Get-ItemProperty -LiteralPath [[-Name] ] [-Filter ] ## DESCRIPTION The `Get-ItemProperty` cmdlet gets the properties of the specified items. -For example, you can use this cmdlet to get the value of the LastAccessTime property of a file object. -You can also use this cmdlet to view registry entries and their values. +For example, you can use this cmdlet to get the value of the LastAccessTime property of a file +object. You can also use this cmdlet to view registry entries and their values. ## EXAMPLES ### Example 1: Get information about a specific directory -This command gets information about the "C:\Windows" directory. +This command gets information about the `C:\Windows` directory. ```powershell Get-ItemProperty C:\Windows @@ -46,7 +46,7 @@ Get-ItemProperty C:\Windows ### Example 2: Get the properties of a specific file -This command gets the properties of the "C:\Test\Weather.xls" file. +This command gets the properties of the `C:\Test\Weather.xls` file. The result is piped to the `Format-List` cmdlet to display the output as a list. ```powershell @@ -55,23 +55,29 @@ Get-ItemProperty C:\Test\Weather.xls | Format-List ### Example 3: Display the value name and data of registry entries in a registry subkey -This command displays the value name and data of each of the registry entries contained in the "CurrentVersion" registry subkey. -Note that the command requires that there is a PowerShell drive named `HKLM:` that is mapped to the "HKEY_LOCAL_MACHINE" hive of the registry. -A drive with that name and mapping is available in PowerShell by default. -Alternatively, the path to this registry subkey can be specified by using the following alternative path that begins with the provider name followed by two colons: - -"Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion". +This command displays the value name and data of each of the registry entries contained in the +"CurrentVersion" registry subkey. ```powershell Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion ``` -### Example 4: Get the value name and data of a registry entry in a registry subkey +> [!NOTE] +> This command requires that there is a PowerShell drive named `HKLM:` that is mapped to the +> "HKEY_LOCAL_MACHINE" hive of the registry. +> +> A drive with that name and mapping is available in PowerShell by default. +> Alternatively, the path to this registry subkey can be specified by using the following alternative +> path that begins with the provider name followed by two colons: +> +> `Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion`. -This command gets the value name and data of the "ProgramFilesDir" registry entry in the "CurrentVersion" registry subkey. -The command uses the **Path** parameter to specify the subkey and the Name parameter to specify the value name of the entry. +### Example 4: Get the value name and data of a registry entry in a registry subkey -The command uses a back tick or grave accent (\`), the PowerShell continuation character, to continue the command on the second line. +This command gets the value name and data of the "ProgramFilesDir" registry entry in the +"CurrentVersion" registry subkey. +The **Path** specifies the subkey and the **Name** parameter specifies the +value name of the entry. ```powershell Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "ProgramFilesDir" @@ -79,8 +85,8 @@ Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "Pr ### Example 5: Get the value names and data of registry entries in a registry key -This command gets the value names and data of the registry entries in the "PowerShellEngine" registry key. -The results are shown in the following sample output. +This command gets the value names and data of the registry entries in the "PowerShellEngine" +registry key. The results are shown in the following sample output. ```powershell Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine @@ -95,62 +101,14 @@ CTPVersion : 5 PSCompatibleVersion : 1.0,2.0 ``` -### Example 6: Get, format, and display the results of registry values and data - -This example shows how to format the output of a `Get-ItemProperty` command in a list to make it easy to see the registry values and data and to make it easy to interpret the results. - -The first command uses the `Get-ItemProperty` cmdlet to get the registry entries in the **Microsoft.PowerShell** subkey. -This subkey stores options for the default shell for PowerShell. -The results are shown in the following sample output. - -The output shows that there are two registry entries, "Path" and "ExecutionPolicy". -When a registry key contains fewer than five entries, by default it is displayed in a table, but it is often easier to view in a list. - -The second command uses the same `Get-ItemProperty` command. -However, this time, the command uses a pipeline operator (`|`) to send the results of the command to the `Format-List` cmdlet. -The `Format-List` command uses the Property parameter with a value of '*' (all) to display all of the properties of the objects in a list. -The results are shown in the following sample output. - -The resulting display shows the "Path" and "ExecutionPolicy" registry entries, along with several less familiar properties of the registry key object. -The other properties, prefixed with PS, are properties of PowerShell custom objects, such as the objects that represent the registry keys. - -```powershell -Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell -``` - -```output -Path ExecutionPolicy ----- --------------- -C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe RemoteSigned -``` - -```powershell -Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell | Format-List -Property * -``` - -```output -PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\PowerShell\1\ShellIds\Micro -soft.PowerShell -PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\PowerShell\1\ShellIds -PSChildName : Microsoft.PowerShell -PSDrive : HKLM -PSProvider : Microsoft.PowerShell.Core\Registry -Path : C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy : RemoteSigned -``` - ## PARAMETERS ### -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 are prompted for a password. - -> [!WARNING] -> This parameter is not supported by any providers installed with Windows PowerShell. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -166,10 +124,11 @@ Accept wildcard characters: False ### -Exclude -Specifies, as a string array, an item or items that this cmdlet excludes from the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -180,16 +139,16 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Filter -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 wildcard characters, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects rather than having PowerShell filter the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -205,10 +164,11 @@ Accept wildcard characters: True ### -Include -Specifies, as a string array, an item or items that this cmdlet includes in the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -219,16 +179,17 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -LiteralPath -Specifies the path to the current location of the property. -Unlike the **Path** parameter, 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 PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -245,6 +206,7 @@ Accept wildcard characters: False ### -Name Specifies the name of the property or properties to retrieve. +Wildcard characters are permitted. ```yaml Type: String[] @@ -255,12 +217,13 @@ Required: False Position: 1 Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Path Specifies the path to the item or items. +Wildcard characters are permitted. ```yaml Type: String[] @@ -271,12 +234,15 @@ Required: True Position: 0 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). +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.md). ## INPUTS @@ -288,13 +254,14 @@ You can pipe a string that contains a path to `Get-ItemProperty`. ### System.Boolean, System.String, System.DateTime -`Get-ItemProperty` returns an object for each item property that it gets. -The object type depends on the object that is retrieved. -For example, in a file system drive, it might return a file or folder. +`Get-ItemProperty` returns an object for each item property that it gets. The object type depends on +the object that is retrieved. For example, in a file system drive, it might return a file or folder. ## NOTES -The `Get-ItemProperty` 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. +The `Get-ItemProperty` 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](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -312,4 +279,4 @@ The `Get-ItemProperty` cmdlet is designed to work with the data exposed by any p [Set-ItemProperty](Set-ItemProperty.md) -[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) \ No newline at end of file +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Get-ItemPropertyValue.md b/reference/6/Microsoft.PowerShell.Management/Get-ItemPropertyValue.md index ce1ba03c51e9..2b712ea120ed 100644 --- a/reference/6/Microsoft.PowerShell.Management/Get-ItemPropertyValue.md +++ b/reference/6/Microsoft.PowerShell.Management/Get-ItemPropertyValue.md @@ -1,5 +1,5 @@ --- -ms.date: 10/18/2018 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -30,13 +30,16 @@ Get-ItemPropertyValue -LiteralPath [-Name] [-Filter [!WARNING] -> This parameter is not supported by any providers installed with Windows PowerShell. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -117,10 +118,11 @@ Accept wildcard characters: False ### -Exclude -Specifies, as a string array, an item or items that this cmdlet excludes from the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -136,11 +138,11 @@ Accept wildcard characters: True ### -Filter -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 wildcard characters, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects rather than having PowerShell filter the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -156,10 +158,11 @@ Accept wildcard characters: True ### -Include -Specifies, as a string array, an item or items that this cmdlet includes in the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -175,11 +178,12 @@ Accept wildcard characters: True ### -LiteralPath -Specifies the path to the current location of the property. -Unlike the **Path** parameter, 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 PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -196,6 +200,7 @@ Accept wildcard characters: False ### -Name Specifies the name of the property or properties to retrieve. +Wildcard characters are permitted. ```yaml Type: String[] @@ -206,12 +211,13 @@ Required: True Position: 1 Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Path Specifies the path to the item or items. +Wildcard characters are permitted. ```yaml Type: String[] @@ -222,12 +228,15 @@ Required: False Position: 0 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). +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.md). ## INPUTS @@ -245,7 +254,9 @@ For example, in a file system drive, the cmdlet might return a file or folder. ## NOTES -This cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, run the `Get-PSProvider` cmdlet. For more information, see about_Providers. +This cmdlet is designed to work with the data exposed by any provider. To list the providers +available in your session, run the `Get-PSProvider` cmdlet. For more information, see +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -267,4 +278,4 @@ This cmdlet is designed to work with the data exposed by any provider. To list t [Set-ItemProperty](Set-ItemProperty.md) -[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) \ No newline at end of file +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Get-PSDrive.md b/reference/6/Microsoft.PowerShell.Management/Get-PSDrive.md index 83b22eff3dc9..a911503bc80c 100644 --- a/reference/6/Microsoft.PowerShell.Management/Get-PSDrive.md +++ b/reference/6/Microsoft.PowerShell.Management/Get-PSDrive.md @@ -3,7 +3,7 @@ external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml keywords: powershell,cmdlet locale: en-us Module Name: Microsoft.PowerShell.Management -ms.date: 06/09/2017 +ms.date: 5/14/2019 online version: http://go.microsoft.com/fwlink/?linkid=821591 schema: 2.0.0 title: Get-PSDrive @@ -258,7 +258,7 @@ 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](https://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.md). ## INPUTS @@ -283,6 +283,6 @@ This cmdlet returns objects that represent the drives in the session. [Remove-PSDrive](Remove-PSDrive.md) -[Get-WmiObject](https://msdn.microsoft.com/en-us/powershell/reference/5.1/Microsoft.PowerShell.Management/Get-WmiObject) +[Get-WmiObject](../../5.1/Microsoft.PowerShell.Management/Get-WmiObject.md) [Get-PSProvider](Get-PSProvider.md) \ No newline at end of file diff --git a/reference/6/Microsoft.PowerShell.Management/Invoke-Item.md b/reference/6/Microsoft.PowerShell.Management/Invoke-Item.md index 67a1e1e68f41..011f3d42f236 100644 --- a/reference/6/Microsoft.PowerShell.Management/Invoke-Item.md +++ b/reference/6/Microsoft.PowerShell.Management/Invoke-Item.md @@ -1,5 +1,5 @@ --- -ms.date: 10/18/2018 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -31,8 +31,10 @@ Invoke-Item -LiteralPath [-Filter ] [-Include ] [-E ## DESCRIPTION The `Invoke-Item` cmdlet performs the default action on the specified item. -For example, it runs an executable file or opens a document file in the application associated with the document file type. -The default action depends on the type of item and is determined by the PowerShell provider that provides access to the data. +For example, it runs an executable file or opens a document file in the application associated with +the document file type. +The default action depends on the type of item and is determined by the PowerShell provider that +provides access to the data. ## EXAMPLES @@ -47,9 +49,9 @@ Invoke-Item "C:\Test\aliasApr04.doc" ### Example 2: Open all files of a specific type -This command opens all of the Microsoft Office Excel spreadsheets in the "C:\Documents and Settings\Lister\My Documents" folder. -Each spreadsheet is opened in a new instance of Excel. -In this case, opening in Excel is the default action for ".xls" files. +This command opens all of the Microsoft Office Excel spreadsheets in the `C:\Documents and +Settings\Lister\My Documents` folder. Each spreadsheet is opened in a new instance of Excel. +In this case, opening in Excel is the default action for `.xls` files. ```powershell Invoke-Item "C:\Documents and Settings\Lister\My Documents\*.xls" @@ -59,14 +61,10 @@ Invoke-Item "C:\Documents and Settings\Lister\My Documents\*.xls" ### -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 are prompted for a password. - -> [!WARNING] -> This parameter is not supported by any providers installed with Windows PowerShell. +> [!NOTE] +> This parameter is not supported by any providers installed with PowerShell. +> To impersonate another user, or elevate your credentials when running this cmdlet, +> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md). ```yaml Type: PSCredential @@ -82,10 +80,11 @@ Accept wildcard characters: False ### -Exclude -Specifies, as a string array, an item or items that this cmdlet excludes from the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet excludes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`*.txt`. Wildcard characters are permitted. The **Exclude** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -101,11 +100,11 @@ Accept wildcard characters: True ### -Filter -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 wildcard characters, depends on the provider. -Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects rather than having PowerShell filter the objects after they are retrieved. +Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) +provider is the only installed PowerShell provider that supports the use of filters. You can find +the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). +Filters are more efficient than other parameters, because the provider applies them when the cmdlet +gets the objects rather than having PowerShell filter the objects after they are retrieved. ```yaml Type: String @@ -121,10 +120,11 @@ Accept wildcard characters: True ### -Include -Specifies, as a string array, an item or items that this cmdlet includes in the operation. -The value of this parameter qualifies the **Path** parameter. -Enter a path element or pattern, such as "*.txt". -Wildcard characters are permitted. +Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value +of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as +`"*.txt"`. Wildcard characters are permitted. The **Include** parameter is effective only when the +command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character +specifies the contents of the `C:\Windows` directory. ```yaml Type: String[] @@ -135,16 +135,17 @@ Required: False Position: Named Default value: None Accept pipeline input: False -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -LiteralPath -Specifies a path to the item. -Unlike the **Path** parameter, 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 PowerShell not to interpret any characters as escape sequences. +Specifies a path to one or more locations. 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 PowerShell not to interpret any characters +as escape sequences. + +For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md). ```yaml Type: String[] @@ -161,6 +162,7 @@ Accept wildcard characters: False ### -Path Specifies the path to the selected item. +Wildcard characters are permitted. ```yaml Type: String[] @@ -171,7 +173,7 @@ Required: True Position: 0 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False +Accept wildcard characters: True ``` ### -Confirm @@ -209,7 +211,10 @@ 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md). +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.md). ## INPUTS @@ -226,7 +231,8 @@ However, output might be generated by the item that it invokes. ## NOTES -This 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. +This 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](../Microsoft.PowerShell.Core/About/about_Providers.md). ## RELATED LINKS @@ -246,4 +252,4 @@ This cmdlet is designed to work with the data exposed by any provider. To list t [Set-Item](Set-Item.md) -[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) \ No newline at end of file +[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md) diff --git a/reference/6/Microsoft.PowerShell.Management/Move-Item.md b/reference/6/Microsoft.PowerShell.Management/Move-Item.md index f500a4d9f31a..43304fbb6f58 100644 --- a/reference/6/Microsoft.PowerShell.Management/Move-Item.md +++ b/reference/6/Microsoft.PowerShell.Management/Move-Item.md @@ -1,5 +1,5 @@ --- -ms.date: 10/18/2018 +ms.date: 5/14/2019 schema: 2.0.0 locale: en-us keywords: powershell,cmdlet @@ -30,16 +30,18 @@ Move-Item -LiteralPath [[-Destination] ] [-Force] [-Filter