Category Archives: Get

Get-ComputerRestorePoint

NAME
    Get-ComputerRestorePoint

SYNOPSIS
    Gets the restore points on the local computer.

SYNTAX
    Get-ComputerRestorePoint [[-RestorePoint] <Int32[]>] [<CommonParameters>]

    Get-ComputerRestorePoint -LastStatus [<CommonParameters>]

DESCRIPTION
    The Get-ComputerRestorePoint cmdlet gets the restore points on the local computer. This cmdlet can also display the status of the most recent attempt to restore the computer.

    You can use the information returned by Get-ComputerRestorePoint to select a restore point, and you can use the sequence number to identify a restore point for the Restore-Computer cmdlet.

PARAMETERS
    -LastStatus [<SwitchParameter>]
        Gets the status of the most recent system restore operation.

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

    -RestorePoint <Int32[]>
        Gets the restore points with the specified sequence numbers. Enter the sequence numbers of one or more restore points. By default, Get-ComputerRestorePoint gets all restore points on the local computer.

        Required?                    false
        Position?                    1
        Default value                All restore points
        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 objects to this cmdlet.

OUTPUTS
    System.Management.ManagementObject#root\default\SystemRestore or String.
        Get-ComputerRestore returns a SystemRestore object, which is an instance of the WMI SystemRestore class. When you use the LastStatus parameter, this cmdlet returns a string.

NOTES

        To run a Get-ComputerRestorePoint command on Windows Vista and later versions of Windows, open Windows PowerShell with the “Run as administrator” option.

        This cmdlet uses the Windows Management Instrumentation (WMI) SystemRestore class.

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

    C:\PS>Get-ComputerRestorePoint

    Description
    ———–
    This command gets all of the restore points on the local computer.

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

    C:\PS>Get-ComputerRestorePoint -RestorePoint 232, 240, 245

    Description
    ———–
    This command gets the restore points with sequence numbers 232, 240, and 245.

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

    C:\PS>Get-ComputerRestorePoint -laststatus

    The last restore failed.

    Description
    ———–
    This command displays the status of the most recent system restore operation on the local computer.

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

    C:\PS>Get-ComputerRestorePoint | Format-Table SequenceNumber, @{Label=”Date”; Expression={$_.ConvertToDateTime($_.CreationTime)}}, Description -auto

    SequenceNumber Date                 Description
    ————– —-                 ———–
             253 8/5/2008 3:19:20 PM Windows Update
             254 8/6/2008 1:53:24 AM Windows Update
             255 8/7/2008 12:00:04 AM Scheduled Checkpoint
    …

    Description
    ———–
    This command displays the restore points in a table for easy reading.

    The Format-Table command includes a calculated property that uses the ConvertToDateTime method to convert the value of the CreationTime property from WMI format to a DateTime object.

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

    C:\PS>((Get-ComputerRestorePoint)[-1]).sequencenumber

    Description
    ———–
    This command gets the sequence number of the most recently created restore point on the computer.

    The command uses the -1 index to get the last item in the array that Get-ComputerRestorePoint returns.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=135215
    Enable-ComputerRestore
    Disable-ComputerRestore
    Restore-Computer
    Restart-Computer

Get-Command

NAME
    Get-Command

SYNOPSIS
    Gets basic information about cmdlets and other elements of Windows PowerShell commands.

SYNTAX
    Get-Command [[-Name] <string[]>] [-CommandType {Alias | Function | Filter | Cmdlet | ExternalScript | Application | Script | All}] [[-ArgumentList] <Object[]>] [-Module <string[]>] [-Syntax] [-TotalCount <int>] [<CommonParameters>]

    Get-Command [-Noun <string[]>] [-Verb <string[]>] [[-ArgumentList] <Object[]>] [-Module <string[]>] [-Syntax] [-TotalCount <int>] [<CommonParameters>]

DESCRIPTION
    The Get-Command cmdlet gets basic information about cmdlets and other elements of Windows PowerShell commands in the session, such as Aliases, Functions, filters, scripts, and applications.

    Get-Command gets its data directly from the code of a cmdlet, Function, script, or Alias, unlike Get-Help, which gets its information from help topic files.

    Without parameters, “Get-Command” gets all of the cmdlets and Functions in the current session. “Get-Command *” gets all Windows PowerShell elements and all of the non-Windows-PowerShell files in the Path Environment Variable ($env:path). It groups the files in the “Application” command type.

    You can use the Module parameter of Get-Command to find the commands that were added to the session by adding a Windows PowerShell snap-in or importing a module.

PARAMETERS
    -ArgumentList <Object[]>
        Gets information about a cmdlet or Function when it is used with the specified parameters (“arguments”), such as a path. The Alias for ArgumentList is Args.

        To detect parameters that are added to a cmdlet when it is used with a particular provider, set the value of ArgumentList to a path in the provider drive, such as “HKML\Software” or “cert:\my”.

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

    -CommandType <CommandTypes>
        Gets only the specified types of commands. Use “CommandType” or its Alias, “Type”. By default, Get-Command gets cmdlets and Functions.

        Valid values are:
        — Alias: All Windows PowerShell Aliases in the current session.

        — All: All command types. It is the equivalent of “Get-Command *”.

        — Application: All non-Windows-PowerShell files in paths listed in the Path Environment Variable ($env:path), including .txt, .exe, and .dll files.

        — Cmdlet: The cmdlets in the current session. “Cmdlet” is the default.

        — ExternalScript: All .ps1 files in the paths listed in the Path Environment Variable ($env:path).

        — Filter and Function: All Windows PowerShell Functions.

        — Script: Script blocks in the current session.

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

    -Module <string[]>
        Gets the commands that came from the specified modules or snap-ins. Enter the names of modules or snap-ins, or enter snap-in or module objects.

        You can refer to this parameter by its name, Module, or by its Alias, PSSnapin. The parameter name that you choose has no effect on the command or its output.

        This parameter takes string values, but you can also supply a PSModuleInfo or PSSnapinInfo object, such as the objects that Get-Module, Get-PSSnapin, and Import-PSSession return.

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

    -Name <string[]>
        Gets information only about the cmdlets or command elements with the specified name. <String> represents all or part of the name of the cmdlet or command element. Wildcards are permitted.

        To list commands with the same name in execution order, type the command name without wildcard characters. For more information, see the Notes section.

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

    -Noun <string[]>
        Gets cmdlets and Functions with names that include the specified noun. <String> represents one or more nouns or noun patterns, such as “process” or “*item*”. Wildcards are permitted.

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

    -Syntax [<SwitchParameter>]
        Gets only specified data about the command element.
                 * For Aliases, retrieves the standard name.
                 * For cmdlets, retrieves the syntax.
                 * For Functions and filters, retrieves the Function definition.
                 * For scripts and applications (files), retrieves the path and filename.

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

    -TotalCount <int>
        Gets only the specified number of command elements. You can use this parameter to limit the output of a command.

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

    -Verb <string[]>
        Gets information about cmdlets and Functions with names that include the specified verb. <String> represents one or more verbs or verb patterns, such as “remove” or *et”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     true (ByPropertyName)
        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 “Name”, “Command”, and “Verb” noun-property specified, or a string object to Get-Command.

OUTPUTS
    Object
        The type of object returned depends on the type of command element retrieved. For example, Get-Command on a cmdlet retrieves a CmdletInfo object, while Get-Command on a DLL retrieves an ApplicationInfo object.

NOTES

        Without parameters, “Get-Command” gets information about the Windows PowerShell cmdlets and Functions. Use the parameters to qualify the elements retrieved.

        Unlike Get-Help, which displays the contents of XML-based help topic files, Get-Command gets its cmdlet information directly from the cmdlet code in the system.

        Get-Command returns the commands in alphabetical order. When the session contains more than one command with the same name, Get-Command returns the commands in execution order. The first command that is listed is the command that runs when you type the command name without qualification. For more information, see about_command_precedence.

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

    C:\PS>Get-Command

    Description
    ———–
    This command gets information about all of the Windows PowerShell cmdlets and Functions.

    The default display lists the command type (“Cmdlet” or “Function” or “Filter”), the name of the cmdlet or Function, and the syntax or Function definition.

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

    C:\PS>Get-Command -Verb set | Format-List

    Description
    ———–
    This command gets information about all of the cmdlets and Functions with the verb “set”, and it displays some of that information in a list.

    The list format includes fields that are omitted from the table display, including the complete syntax. To display all fields (all properties of the object), type “Get-Command -Verb set | Format-List *”.

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

    C:\PS>Get-Command -type cmdlet | Sort-Object noun | Format-Table -group noun

    Description
    ———–
    This command retrieves all of the cmdlets, sorts them alphabetically by the noun in the cmdlet name, and then displays them in noun-based
    groups. This display can help you find the cmdlets for a task.

    By default, Get-Command displays items in the order in which the system discovers them, which is also the order in which they are selected to run when a run command is ambiguous.

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

    C:\PS>Get-Command -Module Microsoft.PowerShell.Security, TestModule

    Description
    ———–
    This command gets the commands in the Microsoft.PowerShell.Security snap-in and the Test-Module module.

    The Module parameter gets commands that were added by importing modules or adding Windows PowerShell snap-ins.

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

    C:\PS>Get-Command Get-ChildItem -args cert: -Syntax

    Description
    ———–
    This command retrieves information about the Get-ChildItem cmdlet when Get-ChildItem is used with the Windows PowerShell Certificate provider.

    When you compare the syntax displayed in the output with the syntax that is displayed when you omit the Args (ArgumentList) parameter, you’ll see that the Certificate provider dynamically adds a parameter, CodeSigningCert, to the Get-ChildItem cmdlet.

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

    C:\PS>(Get-Command Get-ChildItem -ArgumentList cert:).parametersets[0].parameters | Where-Object { $_.IsDynamic }

    Description
    ———–
    This command retrieves only parameters that are added to the Get-ChildItem cmdlet dynamically when it is used with the Windows PowerShell Certificate provider. This is an alternative to the method used in the previous example.

    In this command, the “Get-Command Get-ChildItem -ArgumentList cert:” is processed first. It requests information from Get-Command about the Get-ChildItem cmdlet when it is used with the Certificate provider. The “.parametersets[0]” selects the first parameter set (set 0) of “Get-ChildItem -ArgumentList cert:” and “.parameters” selects the parameters in that parameter set. The resulting parameters are piped to the Where-Object cmdlet to test each parameter (“$_.”) by using the IsDynamic property. To find the properties of the objects in a command, use Get-Member.

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

    C:\PS>Get-Command *

    Description
    ———–
    This command gets information about the Windows PowerShell cmdlets, Functions, filters, scripts, and Aliases in the current console.

    It also gets information about all of the files in the paths of the Path Environment Variable ($env:path). It returns an ApplicationInfo object (System.Management.Automation.ApplicationInfo) for each file, not a FileInfo object (System.IO.FileInfo).

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

    C:\PS>Get-Command | Where-Object {$_.definition -like “*first*”}

    CommandType     Name                        Definition
    ———–     —-                        ———
    Cmdlet         Select-Object             Select-Object [[-Property]

    Description
    ———–
    This command finds a cmdlet or Function based on the name of one of its parameters. You can use this command to identify a cmdlet or Function when all that you can recall is the name of one of its parameters.

    In this case, you recall that one of the cmdlets or Functions has a First parameter that gets the first “n” objects in a list, but you cannot remember which cmdlet it is.

    This command uses the Get-Command cmdlet to get a CmdletInfo object representing each of the cmdlets and Functions in the session. The CmdletInfo object has a Definition property that contains the syntax of the cmdlet or Function, which includes its parameters.

    The command uses a pipeline operator (|) to pass the CmdletInfo object to the Where-Object cmdlet, which examines the definition (syntax) of each object ($_) for a value that includes “first”.

    The result shows that the First parameter belongs to the Select-Object cmdlet.

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

    C:\PS>Get-Command dir | Format-List

    Name             : dir
    CommandType     : Alias
    Definition        : Get-ChildItem
    ReferencedCommand : Get-ChildItem
    ResolvedCommand : Get-ChildItem

    Description
    ———–
    This example shows how to use the Get-Command cmdlet with an Alias. Although it is typically used on cmdlets, Get-Command also displays information about the code in scripts, Functions, Aliases, and executable files.

    This command displays the “dir” Alias in the current console. The command pipes the result to the Format-List cmdlets.

    ————————– EXAMPLE 10 ————————–

    C:\PS>Get-Command notepad

    CommandType     Name         Definition
    ———–     —-         ———-
    Application     notepad.exe    C:\WINDOWS\system32\notepad.exe
    Application     NOTEPAD.EXE    C:\WINDOWS\NOTEPAD.EXE

    Description
    ———–
    This example shows how to use Get-Command to determine which command Windows PowerShell runs when it has access to multiple commands with the same name. When you use the Name parameter without wildcard characters, Get-Command lists the commands with that name in execution precedence order.

    This command shows which Notepad program Windows PowerShell runs when you type “Notepad” without a fully qualified path. The command uses the Name parameter without wildcard characters.

    The sample output shows the Notepad commands in the current console. It indicates that Windows PowerShell will run the instance of Notepad.exe in the C:\Windows\System32 directory.

    ————————– EXAMPLE 11 ————————–

    C:\PS>(Get-Command Get-Date).pssnapin

    C:\PS> (Get-Command remove-gpo).module

    Description
    ———–
    These commands show how to find the snap-in or module from which a particular cmdlet originated.

    The first command uses the PSSnapin property of the CmdletInfo object to find the snap-in that added the Get-Date cmdlet.

    The second command uses the Module property of the CmdletInfo object to find the module that added the Remove-GPO cmdlet.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113309
    about_command_precedence
    Get-Help
    Get-PSDrive
    Get-Member
    Import-PSSession
    Export-PSSession

Get-AuthenticodeSignature

NAME
    Get-AuthenticodeSignature

SYNOPSIS
    Gets information about the Authenticode signature in a file.

SYNTAX
    Get-AuthenticodeSignature [-FilePath] <string[]> [<CommonParameters>]

DESCRIPTION
    The Get-AuthenticodeSignature cmdlet gets information about the Authenticode signature in a file. If the file is not signed, the information is retrieved, but the fields are blank.

PARAMETERS
    -FilePath <string[]>
        Specifies the path to the file being examined. Wildcards are permitted, but they must lead to a single file. The parameter name (“FilePath”) is optional.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue, ByPropertyName)
        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 file path to Get-AuthenticodeSignature.

OUTPUTS
    System.Management.Automation.Signature
        Get-AuthenticodeSignature returns a signature object for each signature that it gets.

NOTES

        For information about Authenticode signatures in Windows PowerShell, see about_Signing.

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

    C:\PS>Get-AuthenticodeSignature -FilePath C:\Test\NewScript.ps1

    Description
    ———–
    This command gets information about the Authenticode signature in the NewScript.ps1 file. It uses the FilePath parameter to specify the file.

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

    C:\PS>Get-AuthenticodeSignature test.ps1, test1.ps1, sign-file.ps1, makexml.ps1

    Description
    ———–
    This command gets information about the Authenticode signature in the four files listed at the command line. In this command, the name of the FilePath parameter, which is optional, is omitted.

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

    C:\PS>Get-ChildItem $pshome\*.* | ForEach-Object {Get-AuthenticodeSignature $_} | where {$_.status -eq “Valid”}

    Description
    ———–
    This command lists all of the files in the $pshome directory that have a valid Authenticode signature. The $pshome automatic Variable contains the path to the Windows PowerShell installation directory.

    The command uses the Get-ChildItem cmdlet to get the files in the $pshome directory. It uses a pattern of *.* to exclude directories (although it also excludes files without a dot in the filename).

    The command uses a pipeline operator (|) to send the files in $pshome to the ForEach-Object cmdlet, where Get-AuthenticodeSignature is called for each file.

    The results of the Get-AuthenticodeSignature command are sent to a Where-Object command that selects only the signature objects with a status of “Valid”.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113307
    about_Signing
    about_execution_policies
    Set-AuthenticodeSignature
    Get-ExecutionPolicy
    Set-ExecutionPolicy

Get-ChildItem

NAME
    Get-ChildItem

SYNOPSIS
    Gets the items and child items in one or more specified locations.

SYNTAX
    Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Exclude <string[]>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction] [<CommonParameters>]

    Get-ChildItem [-LiteralPath] <string[]> [[-Filter] <string>] [-Exclude <string[]>] [-Force] [-Include <string[]>] [-Name] [-Recurse] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Get-ChildItem cmdlet gets the items in one or more specified locations. If the item is a container, it gets the items inside the container, known as child items. You can use the Recurse parameter to get items in all child containers.

    A location can be a file system location, such as a directory, or a location exposed by another provider, such as a Registry hive or a Certificate store.

PARAMETERS
    -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?                    2
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Force [<SwitchParameter>]
        Allows the cmdlet to get items that cannot otherwise not be accessed by the user, such as hidden or system files. 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[]>
        Retrieves 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.

        The Include parameter is effective only when the command includes the Recurse parameter or the path leads to the contents of a directory, such as C:\Windows\*, where the wildcard character specifies the contents of the C:\Windows directory.

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

    -LiteralPath <string[]>
        Specifies a path to one or more locations. 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 [<SwitchParameter>]
        Retrieves only the names of the items in the locations. If you pipe the output of this command to another command, only the item names are sent.

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

    -Path <string[]>
        Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directory (.).

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

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

        Recurse works only when the path points to a container that has child items, such as C:\Windows or C:\Windows\*, and not when it points to items that do not have child items, such as C:\Windows\*.exe.

        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 Get-ChildItem.

OUTPUTS
    Object.
        The type of object that Get-ChildItem returns is determined by the provider with which it is used.

NOTES

        You can also refer to Get-ChildItem by its built-in Aliases, “ls”, “dir”, and “gci”. For more information, see about_aliases.

        Get-ChildItem does not get hidden items by default. To get hidden items, use -Force.

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

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

    C:\PS>Get-ChildItem

    Description
    ———–
    This command gets the child items in the current location. If the location is a file system directory, it gets the files and sub-directories in the current directory. If the item does not have child items, this command returns to the command prompt without displaying anything.

    The default display lists the mode (attributes), last write time, file size (length), and the name of the file. The valid values for mode are d (directory), a (archive), r (read-only), h (hidden), and s (system).

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

    C:\PS>Get-ChildItem . -Include *.txt -Recurse -Force

    Description
    ———–
    This command retrieves all of the .txt files in the current directory and its subdirectories. The dot (.) represents the current directory and the Include parameter specifies the file name extension. The Recurse parameter directs Windows PowerShell to retrieve objects recursively, and it indicates that the subject of the command is the specified directory and its contents. The force parameter adds hidden files to the display.

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

    C:\PS>Get-ChildItem c:\windows\logs\* -Include *.txt -Exclude A*

    Description
    ———–
    This command lists the .txt files in the Logs subdirectory, except for those whose names start with the letter A. It uses the wildcard character (*) to indicate the contents of the Logs subdirectory, not the directory container. Because the command does not include the Recurse parameter, Get-ChildItem does not include the content of directory automatically; you need to specify it.

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

    C:\PS>Get-ChildItem Registry::hklm\software

    Description
    ———–
    This command retrieves all of the Registry keys in the HKEY_LOCAL_MACHINE\SOFTWARE key in the Registry of the local computer.

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

    C:\PS>Get-ChildItem -Name

    Description
    ———–
    This command retrieves only the names of items in the current directory.

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

    C:\PS>Get-ChildItem cert:\. -Recurse -codesigningcert

    Description
    ———–
    This command gets all of the Certificates in the Certificate store that have code-signing authority.

    The command uses the Get-ChildItem cmdlet. The path specifies the Cert: drive exposed by the Windows PowerShell Certificate provider. The backslash (\) symbol specifies a subdirectory of the Certificate store and the dot (.) represents the current directory, which would be the root directory of the Certificate store. The Recurse parameter specifies a recursive search.

    The CodeSigningCertificate parameter is a dynamic parameter that gets only Certificates with code-signing authority. For more information, type “Get-Help Certificate“.

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

    C:\PS>Get-ChildItem * -Include *.exe

    Description
    ———–
    This command retrieves all of the items in the current directory with a “.exe” file name extension. The wildcard character (*) represents the contents of the current directory (not the container). When using the Include parameter without the Recurse parameter, the path must point to contents, not a container.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113308
    about_providers
    Get-Item
    Get-Alias
    Get-Location
    Get-Process

Get-Alias

NAME
    Get-Alias

SYNOPSIS
    Gets the Aliases for the current session.

SYNTAX
    Get-Alias [[-Name] <string[]>] [-Exclude <string[]>] [-Scope <string>] [<CommonParameters>]

    Get-Alias [-Definition <string[]>] [-Exclude <string[]>] [-Scope <string>] [<CommonParameters>]

DESCRIPTION
    The Get-Alias cmdlet gets the Aliases (alternate names for commands and executable files) in the current session. This includes built-in Aliases, Aliases that you have set or imported, and Aliases that you have added to your Windows PowerShell profile.

    By default, Get-Alias takes an Alias and returns the command name. When you use the Definition parameter, Get-Alias takes a command name and returns its Aliases.

PARAMETERS
    -Definition <string[]>
        Gets the Aliases for the specified item. Enter the name of a cmdlet, Function, script, file, or executable file.

        This parameter is called Definition, because it searches for the item name in the Definition property of the Alias object.

        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 Name and Definition parameters. Enter a name, a definition, or a 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 Aliases to retrieve. Wildcards are permitted. By default, Get-Alias retrieves all Aliases defined for the current session. The parameter name (“Name”) is optional. You can also pipe Alias names to Get-Alias.

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

    -Scope <string>
        Gets only the Aliases in the specified scope. 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

    <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 Alias names to Get-Alias.

OUTPUTS
    System.Management.Automation.AliasInfo
        Get-Alias returns an object that represents each Alias.

NOTES

        An Alias is an alternate name or nickname for a cmdlet, Function, or an executable file. To run the cmdlet, Function, or executable, you can use its full name or any Alias. For more information, see about_aliases.

        To create a new Alias, use Set-Alias or New-Alias. To delete an Alias, use Remove-Item.

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

    C:\PS>Get-Alias

    Description
    ———–
    This command gets all Aliases in the current session.

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

    C:\PS>Get-Alias -Name g*, s* -Exclude get-*

    Description
    ———–
    This command gets all Aliases that begin with “g” or “s”, except for Aliases that begin with “get-“.

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

    C:\PS>Get-Alias -definition Get-ChildItem

    Description
    ———–
    This command gets the Aliases for the Get-ChildItem cmdlet.

    By default, the Get-Alias cmdlet gets the item name when you know the Alias. The Definition parameter gets the Alias when you know the item name.

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

    C:\PS>Get-Alias | Where-Object {$_.Options -match “ReadOnly”}

    Description
    ———–
    This command retrieves all Aliases in which the value of the Options property is ReadOnly. This command provides a quick way to find the Aliases that are built into Windows PowerShell, because they have the ReadOnly option.

    Options is just one property of the AliasInfo objects that Get-Alias gets. To find all properties and methods of AliasInfo objects, type “Get-Alias | Get-Member“.

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

    C:\PS>Get-Alias -definition “*-pssession” -Exclude e* -Scope global

    Description
    ———–
    This example gets Aliases for commands that have names that end in “-pssession”, except for those that begin with “e”.

    The command uses the Scope parameter to apply the command in the global scope. This is useful in scripts when you want to get the Aliases in the session.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113306
    about_aliases
    Set-Alias
    New-Alias
    Export-Alias
    Import-Alias
    Alias Provider

Get-Acl

NAME
    Get-Acl

SYNOPSIS
    Gets the security descriptor for a resource, such as a file or Registry key.

SYNTAX
    Get-Acl [[-Path] <string[]>] [-Audit] [-Exclude <string[]>] [-Filter <string>] [-Include <string[]>] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Get-Acl cmdlet gets objects that represent the security descriptor of a file or resource. The security descriptor contains the access control lists (ACLs) of the resource. The ACL specifies the permissions that users and user groups have to access the resource.

PARAMETERS
    -Audit [<SwitchParameter>]
        Gets the audit data for the security descriptor from the system access control list (SACL).

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        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[]>
        Retrieves 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

    -Path <string[]>
        Specifies the path to a resource. Get-Acl gets the security descriptor of the resource indicated by the path. Wildcards are permitted. If you omit the Path parameter, Get-Acl gets the security descriptor of the current directory.

        The parameter name (“Path”) is optional.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue, ByPropertyName)
        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 Get-Acl.

OUTPUTS
    System.Security.AccessControl
        Get-Acl returns an object that represents the ACLs that it gets. The object type depends upon the ACL type.

NOTES

        By default, Get-Acl displays the Windows PowerShell path to the resource (<provider>::<resource-Path>), the owner of the resource, and “Access”, a list (array) of the access control entries in the discretionary access control list (DACL) for the resource. The DACL list is controlled by the resource owner.

        When you format the result as a list, (“Get-Acl | Format-List“), in addition to the path, owner, and access list, Windows PowerShell displays the following fields:

        — Group: The security group of the owner.

        — Audit: A list (array) of entries in the system access control list (SACL). The SACL specifies the types of access attempts for which Windows generates audit records.

        — Sddl: The security descriptor of the resource displayed in a single text string in Security Descriptor Definition Language format. Windows PowerShell uses the GetSddlForm method of security descriptors to retrieve this data.

        Because Get-Acl is supported by the file system and Registry providers, you can use Get-Acl to view the ACL of file system objects, such as files and directories, and Registry objects, such as Registry keys and entries.

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

    C:\PS>Get-Acl C:\windows

    Description
    ———–
    This command gets the security descriptor of the C:Windows directory.

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

    C:\PS>Get-Acl C:\Windows\k*.log | Format-List -property PSPath, Sddl

    Description
    ———–
    This command gets the Windows PowerShell path and SDDL for all of the .log files in the C:\Windows directory whose names begin with “k.”

    The command uses Get-Acl to get objects representing the security descriptors of each log file. It uses a pipeline operator (|) to send the results to the Format-List cmdlet. The command uses the Property parameter of Format-List to display only the PsPath and SDDL properties of each security descriptor object.

    Lists are often used in Windows PowerShell, because long values appear truncated in tables.

    The SDDL values are valuable to system administrators, because they are simple text strings that contain all of the information in the security descriptor. As such, they are easy to pass and store, and they can be parsed when needed.

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

    C:\PS>Get-Acl c:/windows/k*.log -Audit | ForEach-Object { $_.Audit.Count }

    Description
    ———–
    This command gets the security descriptors of the .log files in the C:\Windows directory whose names begin with “k.” It uses the Audit parameter to retrieve the audit records from the SACL in the security descriptor. Then it uses the For-EachObject parameter to count the number of audit records associated with each file. The result is a list of numbers representing the number of audit records for each log file.

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

    C:\PS>Get-Acl -Path hklm:\system\currentcontrolset\control | Format-List

    Description
    ———–
    This command uses Get-Acl to get the security descriptor of the Control subkey (HKLM\SYSTEM\CurrentControlSet\Control) of the Registry.

    The Path parameter specifies the Control subkey. The pipeline operator (|) passes the security descriptor that Get-Acl retrieves to the Format-List command, which formats the properties of the security descriptor as a list so that they are easy to read.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113305
    Set-Acl