• Narrow screen resolution
  • Wide screen resolution
  • Increase font size
  • Decrease font size
  • Default font size
  • default color
  • red color
© Diana Scherff, Amas-Veritas.com

Welcome to Amas Veritas [dot] com

Updates: Media (lyrics) has a new layout. I could never figure out how to lay it out, but it's easier to navigate now. I'm still working on a better duplicate Mamblog mod. I'm trying to make submittions easier but the poetry form died for some reason. Quizzes are also on their way from the old site. Joomla content isn't very code friendly so I'm having to rewrite old code. You can still click on News > AH v21 > Screen if you wish to use the quizzes.
 
Home arrow Tools arrow Windows PowerShell arrow Clear-Content [clc]
Clear-Content [clc] Print E-mail
Written by Diana, on 03-09-2007 23:12
Views 119    
Favoured None

PS C:\Users\Admin> help clc -full

NAME
    Clear-Content

SYNOPSIS
    Deletes the contents of a item, such as deleting the text from a file, but does not delete the item.

SYNTAX
    Clear-Content [-path] <string[]> [-include <string[]>] [-exclude <string[]>] [-filter <string>] [-force] [-credential <PSCredential>] [-whatIf] [-confirm] [<CommonParameters>]

    Clear-Content [-literalPath] <string[]> [-include <string[]>] [-exclude <string[]>] [-filter <string>] [-force] [-credential <PSCredential>] [-whatIf] [-confirm] [<CommonParameters>]


DETAILED DESCRIPTION
    The Clear-Content cmdlet deletes the contents of an item, such as deleting the text from a file, but does not delete the item. As a result, the item exists, but is empty. Clear-Content is similar to Clear-Item, but works on files, instead of aliases and variables.


PARAMETERS
    -path <string[]>
        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 more files, not a path to a directory. Wildcards are permitted. This parameter is required, but the param
        eter name ("-Path") is optional.

        Required?                    true
        Position?                    1
        Default value                N/A - The path must be specified
        Accept pipeline input?       true (ByPropertyName)
        Accept wildcard characters?  true

    -include <string[]>
        Clears 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.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?  true

    -exclude <string[]>
        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.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?  true

    -filter <string>
        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 retr
        ieving the objects, rather than having Windows PowerShell filter the objects after they are retrieved.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?  false

    -force <SwitchParameter>
        Overrides restrictions that prevent the command from succeeding, just so the changes do not compromise security. For example, Force will override the read-only attribute or create directories to complete a file path, but it will not attempt to change file permissions.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?       false
        Accept wildcard characters?  false

    -credential <PSCredential>
        Uses a credential to validate access to the file. <Credential> represents a user-name, such as "User01" or "Domain01\User01", or a PSCredential object, such as the one retrieved by using the Get-Credential cmdlet. If you type a user name, you will be prompted for a password. This parameter
        appears, but it is not supported in any Windows PowerShell core cmdlets or providers.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?       true (ByPropertyName)
        Accept wildcard characters?  false

    -literalPath <string[]>
        Specifies the paths to the items from which content is deleted. Unlike Path, the value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows
         PowerShell not to interpret any characters as escape sequences.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?       true (ByPropertyName)
        Accept wildcard characters?  false

    -whatIf
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?  false

    -confirm
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?  false

    <CommonParameters>
        This cmdlet supports the common parameters: -Verbose, -Debug,
        -ErrorAction, -ErrorVariable, and -OutVariable. For more information,
        type, "get-help about_commonparameters".


INPUT TYPE
    String


RETURN TYPE
    None.


NOTES


        For more information, type "Get-Help Clear-Content -detailed". For technical information, type "Get-Help Clear-Content -full".

        When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

        You can also refer to Clear-Content by its built-in alias, "clc". For more information, see About_Alias.

        If you omit the -Path parameter name, the value of -Path must be the first parameter in the command. For example, "clear-content c:\mydir\*.txt" If you include the parameter name, you can list the parameters in any order.

        You can use Clear-Content with the PowerShell File System 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.


    -------------------------- EXAMPLE 1 --------------------------

    C:\PS>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 --------------------------

    C:\PS>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 --------------------------

    C:\PS>clear-content c:\Temp\* -Include Smp* -Exclude *2* -whatif


    This command requests a prediction of what would happen if you submitted the command: "clear-content c:\temp\* -include smp* -exclude *2*". The result lists the files that would be cleared, in this case, files in the Temp directory whose names begin with "Smp", unless the file names include a "2". To execute the command, run it again without the Whatif parameter.






RELATED LINKS
    Get-Content
    Set-Content
    Add-Content
    Get-Item
    about_namespace


Last update: 03-09-2007 23:12

Published in : Tools, Windows PowerShell

Users' Comments (0) RSS feed comment

No comment posted

Add your comment



mXcomment 1.0.4 © 2007-2009 - visualclinic.fr
License Creative Commons - Some rights reserved
 
< Prev   Next >




Double click any word on this page for a definition.
Using Firefox? Enable definitions by downloading the extension.
Sorry, this feature does not currently work in Opera or Safari.

No Users Online

Statistics

OS: FreeBSD
PHP: 5.2.1
MySQL: 4.1.21-log
Time: 22:41
Caching: Disabled
GZIP: Disabled
Members: 36
News: 2448
Web Links: 39
Visitors: 1443682

Syndicate

Login

Particls