Tag Archives: Exclude

Restart-Service

NAME
    Restart-Service

SYNOPSIS
    Stops and then starts one or more services.

SYNTAX
    Restart-Service [-Name] <string[]> [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Restart-Service -DisplayName <string[]> [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Restart-Service [-InputObject <ServiceController[]>] [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Restart-Service cmdlet sends a stop message and then a start message to the Windows Service Controller for a specified service. If a service was already stopped, it is started without notifying you of an error. You can specify the services by their service names or display names, or you can use the InputObject parameter to pass an object that represents each service that you want to restart.

PARAMETERS
    -DisplayName <string[]>
        Specifies the display names of services to be restarted. Wildcards are permitted.

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

    -Exclude <string[]>
        Omits the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

        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 stop and restart a service that has dependent services.

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

    -Include <string[]>
        Restarts only the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

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

    -InputObject <ServiceController[]>
        Specifies ServiceController objects that represent the services to be restarted. Enter a Variable that contains the objects, or type a command or expression that gets the objects.

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

    -Name <string[]>
        Specifies the service names of the services to be restarted.

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

    -PassThru [<SwitchParameter>]
        Returns an object that represents the service. By default, this cmdlet does not generate any output.

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

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

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

    -WhatIf [<SwitchParameter>]
        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

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.ServiceProcess.ServiceController, System.String
        You can pipe a service object or a string that contains a service name to Restart-Service.

OUTPUTS
    None or System.ServiceProcess.ServiceController
        When you use the PassThru parameter, Restart-Service generates a System.ServiceProcess.ServiceController object that represents the restarted service. Otherwise, this cmdlet does not generate any output.

NOTES

        Restart-Service can control services only when the current user has permission to do so. If a command does not work correctly, you might not have the required permissions.

        To find the service names and display names of the services on your system, type “Get-Service“. The service names appears in the Name column, and the display names appear in the DisplayName column.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Restart-Service wmi

    Description
    ———–
    This command restarts the Windows Management Instrumentation (WMI) service on the local computer.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Restart-Service -displayname net* -Exclude “net logon”

    Description
    ———–
    This command restarts the services that have a display name that begins with “Net”, except for the “Net Logon” service.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Get-Service net* | Where-Object {$_.Status -eq “Stopped”} | Restart-Service

    Description
    ———–
    This command starts all of the stopped network services on the computer.

    It uses the Get-Service cmdlet to get objects representing the services whose service name begins with “net”. (The optional Name parameter name is omitted.) The pipeline operator (|) sends the services object to the Where-Object cmdlet, which selects only the services with a status of “stopped.” Another pipeline operator sends the selected services to Restart-Service. In practice, you would use the WhatIf parameter to see the effect of the command before using it.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113385
    Start-Service
    Stop-Service
    Suspend-Service
    Resume-Service
    New-Service
    Get-Service
    Set-Service

Resume-Service

NAME
    Resume-Service

SYNOPSIS
    Resumes one or more suspended (paused) services.

SYNTAX
    Resume-Service [-Name] <string[]> [-Exclude <string[]>] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Resume-Service -DisplayName <string[]> [-Exclude <string[]>] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Resume-Service [-InputObject <ServiceController[]>] [-Exclude <string[]>] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Resume-Service cmdlet sends a resume message to the Windows Service Controller for each of the specified services. If they have been suspended, they will resume service. If they are currently running, the message is ignored. You can specify the services by their service names or display names, or you can use the InputObject parameter to pass a service object that represents the services that you want to resume.

PARAMETERS
    -DisplayName <string[]>
        Specifies the display names of the services to be resumed. Wildcards are permitted.

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

    -Exclude <string[]>
        Omits the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

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

    -Include <string[]>
        Resumes only the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

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

    -InputObject <ServiceController[]>
        Specifies ServiceController objects representing the services to be resumed. Enter a Variable that contains the objects, or type a command or expression that gets the objects.

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

    -Name <string[]>
        Specifies the service names of the services to be resumed.

        The parameter name is optional. You can use “-Name” or its Alias, “-ServiceName”, or you can omit the parameter name.

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

    -PassThru [<SwitchParameter>]
        Returns an object representing the service. By default, this cmdlet does not generate any output.

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

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

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

    -WhatIf [<SwitchParameter>]
        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

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.ServiceProcess.ServiceController or System.String
        You can pipe a service object or a string that contains a service name to Resume-Service.

OUTPUTS
    None or System.ServiceProcess.ServiceController
        When you use the PassThru parameter, Resume-Service generates a System.ServiceProcess.ServiceController object representing the resumed service. Otherwise, this cmdlet does not generate any output.

NOTES

        The status of services that have been suspended is “Paused”. When services are resumed, their status is “Running”.

        Resume-Service can control services only when the current user has permission to do so. If a command does not work correctly, you might not have the required permissions.

        To find the service names and display names of the services on your system, type “Get-Service“. The service names appear in the Name column, and the display names appear in the DisplayName column.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Resume-Service sens

    Description
    ———–
    This command resumes the System Event Notification service (the service name is represented in the command by “sens”) on the local computer. The command uses the Name parameter to specify the service name of the service, but the command omits the parameter name because the parameter name is optional.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Get-Service | Where-Object {$_.Status -eq “Paused”} | Resume-Service

    Description
    ———–
    This command resumes all of the suspended (paused) services on the computer. The first command gets all of the services on the computer. The pipeline operator (|) passes the results to the Where-Object cmdlet, which selects the services with a Status property of “Paused”. The next pipeline operator sends the results to Resume-Service, which resumes the paused services.

    In practice, you would use the WhatIf parameter to determine the effect of the command before running it without WhatIf.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113386
    Get-Service
    Start-Service
    Stop-Service
    Restart-Service
    Suspend-Service
    Set-Service
    New-Service

Select-String

NAME
    Select-String

SYNOPSIS
    Finds text in strings and files.

SYNTAX
    Select-String [-Path] <string[]> [-Pattern] <string[]> [-AllMatches] [-CaseSensitive] [-Context <Int32[]>] [-Encoding <string>] [-Exclude <string[]>] [-Include <string[]>] [-List] [-NotMatch] [-Quiet] [-SimpleMatch] [<CommonParameters>]

    Select-String -InputObject <psobject> [-Pattern] <string[]> [-AllMatches] [-CaseSensitive] [-Context <Int32[]>] [-Encoding <string>] [-Exclude <string[]>] [-Include <string[]>] [-List] [-NotMatch] [-Quiet] [-SimpleMatch] [<CommonParameters>]

DESCRIPTION
    The Select-String cmdlet searches for text and text patterns in input strings and files. You can use it like Grep in UNIX and Findstr in Windows.

    Select-String is based on lines of text. By default, Select-String finds the first match in each line and, for each match, it displays the file name, line number, and all text in the line containing the match.

    However, you can direct it to detect multiple matches per line, display text before and after the match, or display only a Boolean value (true or false) that indicates whether a match is found.

    Select-String uses regular expression matching, but it can also perform a simple match that searches the input for the text that you specify.

    Select-String can display all of the text matches or stop after the first match in each input file. It can also display all text that does not match the specified pattern.

    You can also specify that Select-String should expect a particular character encoding, such as when you are searching files of Unicode text.

PARAMETERS
    -AllMatches [<SwitchParameter>]
        Searches for more than one match in each line of text. Without this parameter, Select-String finds only the first match in each line of text.

        When Select-String finds more than one match in a line of text, it still emits only one MatchInfo object for the line, but the Matches property of the object contains all of the matches.

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

    -CaseSensitive [<SwitchParameter>]
        Makes matches case-sensitive. By default, matches are not case-sensitive.

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

    -Context <Int32[]>
        Captures the specified number of lines before and after the line with the match. This allows you to view the match in context.

        If you enter one number as the value of this parameter, that number determines the number of lines captured before and after the match. If you enter two numbers as the value, the first number determines the number of lines before the match and the second number determines the number of lines after the match.

        In the default display, lines with a match are indicated by a right angle bracket (ASCII 62) in the first column of the display. Unmarked lines are the context.

        This parameter does not change the number of objects generated by Select-String. Select-String generates one MatchInfo (Microsoft.PowerShell.Commands.MatchInfo) object for each match. The context is stored as an array of strings in the Context property of the object.

        When you pipe the output of a Select-String command to another Select-String command, the receiving command searches only the text in the matched line (the value of the Line property of the MatchInfo object), not the text in the context lines. As a result, the Context parameter is not valid on the receiving Select-String command.

        When the context includes a match, the MatchInfo object for each match includes all of the context lines, but the overlapping lines appear only once in the display.

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

    -Encoding <string>
        Specifies the character encoding that Select-String should assume when searching the file. The default is UTF8.

        Valid values are “UTF7”, “UTF8”, “UTF32”, “ASCII”, “Unicode”, “BigEndianUnicode”, “Default”, and “OEM”. “Default” is the encoding of the system’s current ANSI code page. “OEM” is the current original equipment manufacturer code page identifier for the operating system.

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

    -Exclude <string[]>
        Exclude 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? false

    -Include <string[]>
        Include 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? false

    -InputObject <psobject>
        Specifies the text to be searched. Enter a Variable that contains the text, or type a command or expression that gets the text.

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

    -List [<SwitchParameter>]
        Returns only the first match in each input file. By default, Select-String returns a MatchInfo object for each match it finds.

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

    -NotMatch [<SwitchParameter>]
        Finds text that does not match the specified pattern.

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

    -Path <string[]>
        Specifies the path to the files to be searched. Wildcards are permitted. The default location is the local directory.

        Specify files in the directory, such as “log1.txt”, “*.doc”, or “*.*”. If you specify only a directory, the command fails.

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

    -Pattern <string[]>
        Specifies the text to find. Type a string or regular expression. If you type a string, use the SimpleMatch parameter.

        To learn about regular expressions, see about_regular_expressions.

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

    -Quiet [<SwitchParameter>]
        Returns a Boolean value (true or false), instead of a MatchInfo object. The value is “true” if the pattern is found; otherwise, the value is “false”.

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

    -SimpleMatch [<SwitchParameter>]
        Uses a simple match rather than a regular expression match. In a simple match, Select-String searches the input for the text in the Pattern parameter. It does not interpret the value of the Pattern parameter as a regular expression statement.

        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, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Management.Automation.PSObject
        You can pipe any object that has a ToString method to Select-String.

OUTPUTS
    Microsoft.PowerShell.Commands.MatchInfo or System.Boolean
        By default, the output is a set of MatchInfo objects, one for each match found. If you use the Quiet parameter, the output is a Boolean value indicating whether the pattern was found.

NOTES

        Select-String is like the Grep command in UNIX and the FindStr command in Windows.

        To use Select-String, type the text that you want to find as the value of the Pattern parameter.

        To specify the text to be searched, do the following:

        — Type the text in a quoted string, and then pipe it to Select-String.
        — Store a text string in a Variable, and then specify the Variable as the value of the InputObject parameter.
        — If the text is stored in files, use the Path parameter to specify the path to the files.

        By default, Select-String interprets the value of the Pattern parameter as a regular expression. (For more information, see about_regular_expressions.) However, you can use the SimpleMatch parameter to override the regular expression matching. The SimpleMatch parameter finds instances of the value of the Pattern parameter in the input.

        The default output of Select-String is a MatchInfo object, which includes detailed information about the matches. The information in the object is useful when you are searching for text in files, because MatchInfo objects have properties such as Filename and Line. When the input is not from the file, the value of these parameters is “InputStream”.

        If you do not need the information in the MatchInfo object, use the Quiet parameter, which returns a Boolean value (true or false) to indicate whether it found a match, instead of a MatchInfo object.

        When matching phrases, Select-String uses the current that is set for the system. To find the current culture, use the Get-Culture cmdlet.

        To find the properties of a MatchInfo object, type the following:

        Select-String -path test.txt -Pattern “test” | Get-Member | Format-List -property *

    ————————– EXAMPLE 1 ————————–

    C:\PS>”Hello”,”HELLO” | Select-String -Pattern “HELLO” -CaseSensitive

    Description
    ———–
    This command performs a case-sensitive match of the text that was piped to the Select-String command.

    As a result, Select-String finds only “HELLO”, because “Hello” does not match.

    Because each of the quoted strings is treated as a line, without the CaseSensitive parameter, Select-String would recognize both of the strings as matches.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Select-String -path *.xml -Pattern “the the”

    Description
    ———–
    This command searches through all files with the .xml file name extension in the current directory and displays the lines in those files that include the string “the the”.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Select-String -path $pshome\en-US\*.txt -Pattern “@”

    Description
    ———–
    This command searches the Windows PowerShell conceptual Help files (about_*.txt) for information about the use of the at sign (@).

    To indicate the path, this command uses the value of the $pshome automatic Variable, which stores the path to the Windows PowerShell installation directory. In this example, the command searches the en-US subdirectory, which contains the English (US) language Help files for Windows PowerShell.

    ————————– EXAMPLE 4 ————————–

    C:\PS>function search-help
    {
        $pshelp = “$pshome\es\about_*.txt”, “$pshome\en-US\*dll-help.xml”
        Select-String -path $pshelp -Pattern $args[0]
    }

    Description
    ———–
    This simple Function uses the Select-String cmdlet to search the Windows PowerShell Help files for a particular string. In this example, the Function searches the “en-US” subdirectory for English-United States language files.

    To use the Function to find a string, such as “psdrive”, type “search-help psdrive”.

    To use this Function in any Windows PowerShell console, change the path to point to the Windows PowerShell Help files on your system, and then paste the Function in your Windows PowerShell profile.

    ————————– EXAMPLE 5 ————————–

    C:\PS>$events = Get-Eventlog -logname application -newest 100

    C:\PS> $events | Select-String -InputObject {$_.message} -Pattern “failed”

    Description
    ———–
    This example searches for the string “failed” in the 100 newest events in the Application log in Event Viewer.

    The first command uses the Get-EventLog cmdlet to get the 100 most recent events from the Application event log. Then it stores the events in the $events Variable.

    The second command uses a pipeline operator (|) to send the objects in the $events Variable to Select-String. It uses the InputObject parameter to represent the input from the $events Variable. The value of the InputObject parameter is the Message property of each object as it travels through the pipeline. The current object is represented by the $_ symbol.

    As each event arrives in the pipeline, Select-String searches the value of its Message property for the “failed” string, and then displays any lines that include a match.

    ————————– EXAMPLE 6 ————————–

    C:\PS>Get-ChildItem c:\windows\system32\* -Include *.txt -recurse |
    Select-String -Pattern “Microsoft” -CaseSensitive

    Description
    ———–
    This command examines all files in the subdirectories of C:\Windows\System32 with the .txt file name extension and searches for the string “Microsoft”. The CaseSensitive parameter indicates that the “M” in “Microsoft” must be capitalized and that the rest of the characters must be lowercase for Select-String to find a match.

    ————————– EXAMPLE 7 ————————–

    C:\PS>Select-String -path process.txt -Pattern idle, svchost -NotMatch

    Description
    ———–
    This command finds lines of text in the Process.txt file that do not include the words “idle” or “svchost”.

    ————————– EXAMPLE 8 ————————–

    C:\PS>$f = Select-String -path audit.log -Pattern “logon failed” -Context 2, 3

    C:\PS> $f.count

    C:\PS> ($f)[0].context | Format-List

    Description
    ———–
    The first command searches the Audit.Log file for the phrase “logon failed.” It uses the Context parameter to capture 2 lines before the match and 3 lines after the match.

    The second command uses the Count property of object arrays to display the number of matches found, in this case, 2.

    The third command displays the lines stored in the Context property of the first MatchInfo object. It uses array notation to indicate the first match (match 0 in a zero-based array), and it uses the Format-List cmdlet to display the value of the Context property as a list.

    The output consists of two MatchInfo objects, one for each match detected. The context lines are stored in the Context property of the MatchInfo object.

    ————————– EXAMPLE 9 ————————–

    C:\PS>$a = Get-ChildItem $pshome\en-us\about*.help.txt | Select-String -Pattern transcript

    C:\PS> $b = Get-ChildItem $pshome\en-us\about*.help.txt | Select-String -Pattern transcript -AllMatches

    C:\PS> $a
    C:\Windows\system32\WindowsPowerShell\v1.0\en-us\about_Pssnapins.help.txt:39:     Start-Transcript and Stop-Transcript.

    C:\PS> $b
    C:\Windows\system32\WindowsPowerShell\v1.0\en-us\about_Pssnapins.help.txt:39:     Start-Transcript and Stop-Transcript.

    C:\PS>> $a.matches
    Groups : {Transcript}
    Success : True
    Captures : {Transcript}
    Index    : 13
    Length : 10
    Value    : Transcript

    C:\PS> $b.matches
    Groups : {Transcript}
    Success : True
    Captures : {Transcript}
    Index    : 13
    Length : 10
    Value    : Transcript

    Groups : {Transcript}
    Success : True
    Captures : {Transcript}
    Index    : 33
    Length : 10
    Value    : Transcript

    Description
    ———–
    This example demonstrates the effect of the AllMatches parameter of Select-String. AllMatches finds all pattern matches in a line, instead of just finding the first match in each line.

    The first command in the example searches the Windows PowerShell conceptual Help files (“about” Help) for instances of the word “transcript”. The second command is identical, except that it uses the AllMatches parameter.

    The output of the first command is saved in the $a Variable. The output of the second command is saved in the $b Variable.

    When you display the value of the Variables, the default display is identical, as shown in the example output.

    However, the fifth and sixth commands display the value of the Matches property of each object. The Matches property of the first command contains just one match (that is, one System.Text.RegularExpressions.Match object), whereas the Matches property of the second command contains objects for both of the matches in the line.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113388
    about_Comparison_Operators
    about_regular_expressions

Remove-Item

NAME
    Remove-Item

SYNOPSIS
    Deletes the specified items.

SYNTAX
    Remove-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Recurse] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

    Remove-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Recurse] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Remove-Item cmdlet deletes one or more items. Because it is supported by many providers, it can delete many different types of items, including files, directories, Registry keys, Variables, Aliases, and Functions.

PARAMETERS
    -Credential <PSCredential>
        Specifies a user account that has permission to perform this action. The default is the current user.

        Type a user name, such as “User01” or “Domain01\User01”, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

        This parameter is not supported by any providers installed with Windows PowerShell.

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

    -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? false

    -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 retrieving 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>]
        Allows the cmdlet to remove items that cannot otherwise be changed, such as hidden or read-only files or read-only Aliases or Variables. The cmdlet cannot remove constant Aliases or Variables. Implementation varies from provider to provider. For more information, see about_providers. Even using the Force parameter, the cmdlet cannot override security restrictions.

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

    -Include <string[]>
        Deletes 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? false

    -LiteralPath <string[]>
        Specifies a path to the items being removed. 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

    -Path <string[]>
        Specifies a path to the items being removed. Wildcards are permitted. The parameter name (“-Path“) is optional.

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

    -Recurse [<SwitchParameter>]
        Deletes the items in the specified locations and in all child items of the locations.

        The Recurse parameter in this cmdlet does not work properly.

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

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

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

    -WhatIf [<SwitchParameter>]
        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

    -UseTransaction [<SwitchParameter>]
        Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_transactions.

        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, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains a path (but not a literal path) to Remove-Item.

OUTPUTS
    None
        This cmdlet does not return any output.

NOTES

        You can also refer to Remove-Item by any of its built-in Aliases, “del”, “erase”, “rmdir”, “rd”, “ri”, or “rm”. For more information, see about_aliases.

        The Remove-Item 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.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Remove-Item C:\Test\*.*

    Description
    ———–
    This command deletes all of the files with names that include a dot (.) from the C:\Test directory. Because the command specifies a dot, the command does not delete directories or files with no file name extension.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Remove-Item * -Include *.doc -Exclude *1*

    Description
    ———–
    This command deletes from the current directory all files with a .doc file name extension and a name that does not include “1”. It uses the wildcard character (*) to specify the contents of the current directory. It uses the Include and Exclude parameters to specify the files to delete.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Remove-Item -Path C:\Test\hidden-RO-file.txt -Force

    Description
    ———–
    This command deletes a file that is both hidden and read-only. It uses the Path parameter to specify the file. It uses the Force parameter to give permission to delete it. Without Force, you cannot delete read-only or hidden files.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Get-ChildItem * -Include *.csv -Recurse | Remove-Item

    Description
    ———–
    This command deletes all of the CSV files in the current directory and all subdirectories recursively.

    Because the Recurse parameter in this cmdlet is faulty, the command uses the Get-ChildItem cmdlet to get the desired files, and it uses the pipeline operator to pass them to the Remove-Item cmdlet.

    In the Get-ChildItem command, the Path parameter has a value of *, which represents the contents of the current directory. It uses the Include parameter to specify the CSV file type, and it uses the Recurse parameter to make the retrieval recursive.

    If you try to specify the file type in the path, such as “-Path *.csv”, the cmdlet interprets the subject of the search to be a file that has no child items, and Recurse fails.

    ————————– EXAMPLE 5 ————————–

    C:\PS>Remove-Item hklm:\software\mycompany\OldApp -Recurse

    Description
    ———–
    This command deletes the OldApp Registry key and all of its subkeys and values. It uses the Remove-Item cmdlet to remove the key. The path is specified, but the optional parameter name (Path) is omitted.

    The Recurse parameter deletes all of the contents of the OldApp key recursively. If the key contains subkeys and you omit the Recurse parameter, you are prompted to confirm that you want to delete the contents of the key.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113373
    about_providers
    Clear-Item
    Copy-Item
    Get-Item
    Invoke-Item
    Move-Item
    New-Item
    Remove-ItemProperty
    Rename-Item
    Set-Item

Remove-ItemProperty

NAME
    Remove-ItemProperty

SYNOPSIS
    Deletes the property and its value from an item.

SYNTAX
    Remove-ItemProperty [-LiteralPath] <string[]> [-Name] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

    Remove-ItemProperty [-Path] <string[]> [-Name] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Remove-ItemProperty cmdlet deletes a property and its value from an item. You can use it to delete Registry values and the data that they store.

PARAMETERS
    -Credential <PSCredential>
        Specifies a user account that has permission to perform this action. The default is the current user.

        Type a user name, such as “User01” or “Domain01\User01”, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

        This parameter is not supported by any providers installed with Windows PowerShell.

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

    -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? false

    -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 retrieving 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>]
        Allows the cmdlet to remove a property of an object that cannot otherwise be accessed by the user. Implementation varies from provider to provider. For more information, see about_providers.

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

    -Include <string[]>
        Deletes 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? false

    -LiteralPath <string[]>
        Specifies a path to the item property. 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

    -Name <string[]>
        Specifies the names of the properties to be retrieved.

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

    -Path <string[]>
        Specifies the path to the item whose properties are being removed. Wildcards are permitted.

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

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

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

    -WhatIf [<SwitchParameter>]
        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

    -UseTransaction [<SwitchParameter>]
        Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_transactions.

        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, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains a path (but not a literal path) to Remove-ItemProperty.

OUTPUTS
    None
        This cmdlet does not return any output.

NOTES

        You can also refer to Remove-ItemProperty by its built-in Alias, “rp”. For more information, see about_Alias.

        In the Windows PowerShell Registry provider, Registry values are considered to be properties of a Registry key or subkey. You can use the ItemProperty cmdlets to manage these values.

        The Remove-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.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Remove-Itemproperty -Path HKLM:\Software\SmpApplication -Name SmpProperty

    Description
    ———–
    This command deletes the SmpProperty Registry value, and its data, from the SmpApplication subkey of the HKEY_LOCAL_MACHINE\Software Registry key.

    Because the command is issued from a file system drive (C:\PS>), it includes the fully qualified path to the SmpApplication subkey, including the drive, HKLM:, and the Software key.

    It uses the Name parameter to identify the Registry value that is being deleted.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Set-Location HKCU:\Software\MyCompany\MyApp

    PS HKCU:\Software\MyCompany\MyApp> Remove-Itemproperty -Path . -Name Options -Confirm

    Description
    ———–
    These commands delete the Options Registry value, and its data, from the MyApp subkey of HKEY_CURRENT_USER\Software\MyCompany.

    The first command uses the Set-Location cmdlet to change the current location to the HKEY_CURRENT_USER drive (HKCU:) and the Software\MyCompany\MyApp subkey.

    The second command uses the Remove-Item cmdlet to remove the Options Registry value, and its data, from the MyApp subkey. Because the Path parameter is required, the command uses a dot (.) to indicate the current location. It uses the Name parameter to specify which Registry value to delete. It uses the Confirm parameter to request a user prompt before deleting the value.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Get-Item -Path HKLM:\Software\MyCompany | Remove-Itemproperty -Name NoOfEmployees

    Description
    ———–
    This command deletes the NoOfEmployees Registry value, and its data, from the HKLM\Software\MyCompany Registry key.

    The command uses the Get-Item cmdlet to get an item that represents the Registry key. It uses a pipeline operator (|) to send the object to the Remove-ItemProperty cmdlet. Then, it uses the Name parameter of Remove-ItemProperty to specify the name of the Registry value.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113374
    about_providers
    Clear-ItemProperty
    Copy-ItemProperty
    Get-ItemProperty
    Move-ItemProperty
    New-ItemProperty
    Remove-Item
    Rename-ItemProperty
    Set-ItemProperty

Remove-Variable

NAME
    Remove-Variable

SYNOPSIS
    Deletes a Variable and its value.

SYNTAX
    Remove-Variable [-Name] <string[]> [-Exclude <string[]>] [-Force] [-Include <string[]>] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Remove-Variable cmdlet deletes a Variable and its value from the scope in which it is defined, such as the current session. You cannot use this cmdlet to delete Variables that are set as constants or those that are owned by the system.

PARAMETERS
    -Exclude <string[]>
        Omits the specified items. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

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

    -Force [<SwitchParameter>]
        Allows the cmdlet to remove a Variable even if it is read-only. Even using the Force parameter, the cmdlet cannot remove a constant.

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

    -Include <string[]>
        Deletes only the specified items. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

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

    -Name <string[]>
        Specifies the name of the Variable to be removed. The parameter name (“Name”) is optional.

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

    -Scope <string>
        Specifies the scope in which this Alias is valid. Valid values are “Global”, “Local”, or “Script”, or a number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent). “Local” is the default. For more information, see about_scopes.

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

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

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

    -WhatIf [<SwitchParameter>]
        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

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Management.Automation.PSVariable
        You can pipe a Variable object to Remove-Variable.

OUTPUTS
    None
        This cmdlet does not return any output.

NOTES

        Changes affect only the current scope, such as a session. To delete a Variable from all sessions, add a Remove-Variable command to your Windows PowerShell profile.

        You can also refer to RemoveVariable by its built-in Alias, “rv”. For more information, see about_aliases.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Remove-Variable Smp

    Description
    ———–
    This command deletes the $Smp Variable.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113380
    Set-Variable
    Get-Variable
    Clear-Variable
    New-Variable
    about_profiles

Move-Item

NAME
    Move-Item

SYNOPSIS
    Moves an item from one location to another.

SYNTAX
    Move-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

    Move-Item [-Path] <string[]> [[-Destination] <string>] [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Move-Item cmdlet moves an item, including its properties, contents, and child items, from one location to another location. The locations must be supported by the same provider. For example, it can move a file or subdirectory from one directory to another or move a Registry subkey from one key to another. When you move an item, it is added to the new location and deleted from its original location.

PARAMETERS
    -Credential <PSCredential>
        Specifies a user account that has permission to perform this action. The default is the current user.

        Type a user name, such as “User01” or “Domain01\User01”, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

        This parameter is not supported by any providers installed with Windows PowerShell.

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

    -Destination <string>
        Specifies the path to the location where the items are being moved. The default is the current directory. Wildcards are permitted, but the result must specify a single location.

        To rename the item being moved, specify a new name in the value of the Destination parameter.

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

    -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? false

    -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 retrieving 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>]
        Allows the cmdlet to move an item that writes over an existing read-only item. Implementation varies from provider to provider. For more information, see about_providers. Even using the Force parameter, the cmdlet cannot override security restrictions.

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

    -Include <string[]>
        Moves 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? false

    -LiteralPath <string[]>
        Specifies the path to the current location of the items. 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

    -PassThru [<SwitchParameter>]
        Passes an object representing the item to the pipeline. By default, this cmdlet does not generate any output.

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

    -Path <string[]>
        Specifies the path to the current location of the items. The default is the current directory. Wildcards are permitted.

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

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

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

    -WhatIf [<SwitchParameter>]
        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

    -UseTransaction [<SwitchParameter>]
        Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_transactions.

        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, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains a path to Move-Item.

OUTPUTS
    None or an object representing the moved item.
        When you use the Passthru parameter, Move-Item generates an object representing the moved item. Otherwise, this cmdlet does not generate any output.

NOTES

        Move-Item will move files between drives that are supported by the same provider, but it will move directories only within the same drive.

        Because a Move-Item command moves the properties, contents, and child items of an item, all moves are recursive by default.

        You can also refer to Move-Item by its built-in Aliases, “move”, “mv”, and “mi”. For more information, see about_aliases.

        The Move-Item 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.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Move-Item -Path C:\test.txt -Destination E:\Temp\tst.txt

    Description
    ———–
    This command moves the Test.txt file from the C: drive to the E:\Temp directory and renames it from “test.txt” to “tst.txt”.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Move-Item -Path C:\Temp -Destination C:\Logs

    Description
    ———–
    This command moves the C:\Temp directory and its contents to the C:\Logs directory. The Temp directory, and all of its subdirectories and files, then appear in the Logs directory.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Move-Item -Path .\*.txt -Destination C:\Logs

    Description
    ———–
    This command moves all of the text files (*.txt) in the current directory (represented by a dot (.)) to the C:\Logs directory.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Get-ChildItem -Path . -recurse -Include *.txt | Move-Item -Destination C:\TextFiles

    Description
    ———–
    This command moves all of the text files from the current directory and all subdirectories, recursively, to the C:\TextFiles directory.

    The command uses the Get-ChildItem cmdlet to get all of the child items in the current directory (represented by the dot [.]) and its subdirectories that have a *.txt file name extension. It uses the Recurse parameter to make the retrieval recursive and the Include parameter to limit the retrieval to *.txt files.

    The pipeline operator (|) sends the results of this command to Move-Item, which moves the text files to the TextFiles directory.

    If files being moved to C:\Textfiles have the same name, Move-Item displays an error and continues, but it moves only one file with each name to C:\Textfiles. The other files remain in their original directories.

    If the Textfiles directory (or any other element of the destination path) does not exist, the command fails. The missing directory is not created for you, even if you use the Force parameter. Move-Item moves the first item to a file called “Textfiles” and then displays an error explaining that the file already exists.

    Also, by default, Get-ChildItem does not move hidden files. To move hidden files, use the Force parameter with Get-ChildItem.

    ————————– EXAMPLE 5 ————————–

    C:\PS>Move-Item hklm:\software\mycompany\* hklm:\software\mynewcompany

    Description
    ———–
    This command moves the Registry keys and values within the MyCompany Registry key in HKLM\Software to the MyNewCompany key. The wildcard character (*) indicates that the contents of the MyCompany key should be moved, not the key itself. In this command, the optional Path and Destination parameter names are omitted.

    ————————– EXAMPLE 6 ————————–

    C:\PS>Move-Item -literalpath ‘Logs[Sept`06]’ -Destination ‘Logs[2006]’

    Description
    ———–
    This command moves the Logs[Sept`06] directory (and its contents) into the Logs[2006] directory.

    The LiteralPath parameter is used instead of Path, because the original directory name includes left bracket and right bracket characters (“[” and “]”). The path is also enclosed in single quotation marks (‘ ‘), so that the backtick symbol (`) is not misinterpreted.

    The Destination parameter does not require a literal path, because the Destination Variable also must be enclosed in single quotation marks, because it includes brackets that can be misinterpreted.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113350
    about_providers
    Clear-Item
    Get-Item
    Invoke-Item
    Set-Item
    New-Item
    Remove-Item
    Rename-Item
    Copy-Item

Move-ItemProperty

NAME
    Move-ItemProperty

SYNOPSIS
    Moves a property from one location to another.

SYNTAX
    Move-ItemProperty [-LiteralPath] <string[]> [-Destination] <string> [-Name] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

    Move-ItemProperty [-Path] <string[]> [-Destination] <string> [-Name] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Move-ItemProperty cmdlet moves a property of an item from one item to another item. For example, it can move a Registry entry from one Registry key to another Registry key. When you move an item property, it is added to the new location and deleted from its original location.

PARAMETERS
    -Credential <PSCredential>
        Specifies a user account that has permission to perform this action. The default is the current user.

        Type a user name, such as “User01” or “Domain01\User01”, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

        This parameter is not supported by any providers installed with Windows PowerShell.

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

    -Destination <string>
        Specifies the path to the destination location.

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

    -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? false

    -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 retrieving 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>]
        Allows the cmdlet to move properties to or from items that cannot otherwise be accessed by the user. Implementation varies from provider to provider. For more information, see about_providers.

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

    -Include <string[]>
        Moves 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? false

    -LiteralPath <string[]>
        Specifies the path to the current location of the property. 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

    -Name <string[]>
        Specifies the name of the property to be moved.

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

    -PassThru [<SwitchParameter>]
        Passes an object representing the item property. By default, this cmdlet does not generate any output.

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

    -Path <string[]>
        Specifies the path to the current location of the property. Wildcards are permitted.

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

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

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

    -WhatIf [<SwitchParameter>]
        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

    -UseTransaction [<SwitchParameter>]
        Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_transactions.

        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, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains a path to Move-ItemProperty.

OUTPUTS
    None or System.Management.Automation.PSCustomObject
        When you use the PassThru parameter, Move-ItemProperty generates a PSCustomObject representing the moved item property. Otherwise, this cmdlet does not generate any output.

NOTES

        The names of the Path, Destination, and Name parameters are optional. If you omit the parameter names, the unnamed parameter values must appear in this order: Path, Destination, Name. If you include the parameter names, the parameters can appear in any order.

        You can also refer to Move-ItemProperty by its built-in Alias, “mp”. For more information, see about_aliases.

        The Move-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.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Move-Itemproperty HKLM:\Software\MyCompany\MyApp -Name `
    Version -Destination HKLM:\Software\MyCompany\NewApp

    Description
    ———–
    This command moves the “Version” Registry value, and its data, from the MyApp subkey to the NewApp subkey of the HKLM\Software\MyCompany Registry key.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113351
    about_providers
    Clear-ItemProperty
    New-ItemProperty
    Copy-ItemProperty
    Rename-ItemProperty
    Get-ItemProperty
    Set-ItemProperty
    Remove-ItemProperty

New-ItemProperty

NAME
    New-ItemProperty

SYNOPSIS
    Creates a new property for an item and sets its value. For example, you can use New-ItemProperty to create and change Registry values and data, which are properties of a Registry key.

SYNTAX
    New-ItemProperty [-LiteralPath] <string[]> [-Name] <string> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PropertyType <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

    New-ItemProperty [-Path] <string[]> [-Name] <string> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PropertyType <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The New-ItemProperty cmdlet creates a new property for a specified item and sets its value. Typically, this cmdlet is used to create new Registry values, because Registry values are properties of a Registry key item.

    This cmdlet does not add properties to an object. To add a property to an instance of an object, use the Add-Member cmdlet. To add a property to all objects of a particular type, edit the Types.ps1xml file.

PARAMETERS
    -Credential <PSCredential>
        Specifies a user account that has permission to perform this action. The default is the current user.

        Type a user name, such as “User01” or “Domain01\User01”, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

        This parameter is not supported by any providers installed with Windows PowerShell.

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

    -Exclude <string[]>
        Omits the specified items. Wildcards are permitted.

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

    -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 retrieving 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>]
        Allows the cmdlet to create a property on an object that cannot otherwise be accessed by the user. Implementation varies from provider to provider. For more information, see about_providers.

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

    -Include <string[]>
        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? false

    -LiteralPath <string[]>
        Specifies a path to the item property. 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

    -Name <string>
        Specifies a name for the new property. If the property is a Registry entry, this parameter specifies the name of the entry.

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

    -Path <string[]>
        Specifies the path to the item. This parameter identifies the item to which the new property will be added.

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

    -PropertyType <string>
        Specifies the type of property that will be added.

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

    -Value <Object>
        Specifies the property value. If the property is a Registry entry, this parameter specifies the value of the entry.

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

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

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

    -WhatIf [<SwitchParameter>]
        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

    -UseTransaction [<SwitchParameter>]
        Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_transactions.

        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, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        You cannot pipe input to New-ItemProperty.

OUTPUTS
    System.Management.Automation.PSCustomObject
        New-ItemProperty returns a custom object that contains the new property.

NOTES

        The New-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.

    ————————– EXAMPLE 1 ————————–

    C:\PS>New-Itemproperty -Path HKLM:\Software\MyCompany -Name NoOfEmployees -Value 822

    C:\PS> Get-Itemproperty hklm:\software\mycompany

    PSPath        : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\mycompany
    PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software
    PSChildName : mycompany
    PSDrive     : HKLM
    PSProvider    : Microsoft.PowerShell.Core\Registry
    NoOfLocations : 2
    NoOfEmployees : 822

    Description
    ———–
    This command adds a new Registry entry, NoOfEmployees, to the MyCompany key of the HKLM:\Software hive.

    The first command uses the Path parameter to specify the path to the MyCompany Registry key. It uses the Name parameter to specify a name for the entry and the Value parameter to specify its value.

    The second command uses the Get-ItemProperty cmdlet to see the new Registry entry.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Get-Item -Path HKLM:\Software\MyCompany | New-Itemproperty -Name NoOfLocations -Value 3

    Description
    ———–
    This command adds a new Registry entry to a Registry key. To specify the key, it uses a pipeline operator (|) to send an object representing the key to the New-ItemProperty cmdlet.

    The first part of the command uses the Get-Item cmdlet to get the MyCompany Registry key. The pipeline operator (|) sends the results of the command to the New-ItemProperty cmdlet, which adds the new Registry entry, NoOfLocations, and its value, 3, to the MyCompany key.

    This command works because the parameter-binding feature of Windows PowerShell associates the path of the RegistryKey object that Get-Item returns with the LiteralPath parameter of New-ItemProperty. For more information, see about_pipelines.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113354
    about_providers
    Clear-ItemProperty
    Copy-ItemProperty
    Move-ItemProperty
    Rename-ItemProperty
    Get-ItemProperty
    Set-ItemProperty
    Remove-ItemProperty

Invoke-Item

NAME
    Invoke-Item

SYNOPSIS
    Performs the default action on the specified item.

SYNTAX
    Invoke-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Include <string[]>] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

    Invoke-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Include <string[]>] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

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 Windows PowerShell provider that provides access to the data.

PARAMETERS
    -Credential <PSCredential>
        Specifies a user account that has permission to perform this action. The default is the current user.

        Type a user name, such as “User01” or “Domain01\User01”, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

        This parameter is not supported by any providers installed with Windows PowerShell.

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

    -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? false

    -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 retrieving 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

    -Include <string[]>
        Performs the default action only on 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? false

    -LiteralPath <string[]>
        Specifies a path to the item. 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

    -Path <string[]>
        Specifies the path to the selected item.

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

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

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

    -WhatIf [<SwitchParameter>]
        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

    -UseTransaction [<SwitchParameter>]
        Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_transactions.

        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, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe a string that contains a path to Invoke-Item.

OUTPUTS
    None
        The command does not generate any output. However, output might be generated by the item that it invokes.

NOTES

        The Invoke-Item cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type “Get-PsSProvider”. For more information, see about_providers.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Invoke-Item C:\Test\aliasApr04.doc

    Description
    ———–
    This command opens the file AliasApr04.doc in Microsoft Office Word. In this case, opening in Word is the default action for .doc files.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Invoke-Item “C:\Documents and Settings\Lister\My Documents\*.xls”

    Description
    ———–
    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.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113345
    about_providers
    Clear-Item
    Get-Item
    Move-Item
    Set-Item
    New-Item
    Remove-Item
    Rename-Item
    Copy-Item