Category Archives: Get

Get-Process

NAME
    Get-Process

SYNOPSIS
    Gets the processes that are running on the local computer or a remote computer.

SYNTAX
    Get-Process [[-Name] <string[]>] [-ComputerName <string[]>] [-FileVersionInfo] [-Module] [<CommonParameters>]

    Get-Process -Id <Int32[]> [-ComputerName <string[]>] [-FileVersionInfo] [-Module] [<CommonParameters>]

    Get-Process -InputObject <Process[]> [-ComputerName <string[]>] [-FileVersionInfo] [-Module] [<CommonParameters>]

DESCRIPTION
    The Get-Process cmdlet gets the processes on a local or remote computer.

    Without parameters, Get-Process gets all of the processes on the local computer. You can also specify a particular process by process name or process ID (PID) or pass a process object through the pipeline to Get-Process.

    By default, Get-Process returns a process object that has detailed information about the process and supports methods that let you start and stop the process. You can also use the parameters of Get-Process to get file version information for the program that runs in the process and to get the modules that the process loaded.

PARAMETERS
    -ComputerName <string[]>
        Gets the processes running on the specified computers. The default is the local computer.

        Type the NetBIOS name, an IP address, or a fully qualified domain name of one or more computers. To specify the local computer, type the computer name, a dot (.), or “localhost”.

        This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of Get-Process even if your computer is not configured to run remote commands.

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

    -FileVersionInfo [<SwitchParameter>]
        Gets the file version information for the program that runs in the process.

        On Windows Vista and later versions of Windows, you must open Windows PowerShell with the “Run as administrator” option to use this parameter on processes that you do not own.

        Using this parameter is equivalent to getting the MainModule.FileVersionInfo property of each process object. When you use this parameter, Get-Process returns a FileVersionInfo object (System.Diagnostics.FileVersionInfo), not a process object. So, you cannot pipe the output of the command to a cmdlet that expects a process object, such as Stop-Process.

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

    -Id <Int32[]>
        Specifies one or more processes by process ID (PID). To specify multiple IDs, use commas to separate the IDs. To find the PID of a process, type “Get-Process“.

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

    -InputObject <Process[]>
        Specifies one or more process objects. Enter a Variable that contains the objects, or type a command or expression that gets the objects.

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

    -Module [<SwitchParameter>]
        Gets the modules that have been loaded by the processes.

        On Windows Vista and later versions of Windows, you must open Windows PowerShell with the “Run as administrator” option to use this parameter on processes that you do not own.

        This parameter is equivalent to getting the Modules property of each process object. When you use this parameter, Get-Process returns a ProcessModule object (System.Diagnostics.ProcessModule), not a process object. So, you cannot pipe the output of the command to a cmdlet that expects a process object, such as Stop-Process.

        When you use both the Module and FileVersionInfo parameters in the same command, Get-Process returns a FileVersionInfo object with information about the file version of all modules.

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

    -Name <string[]>
        Specifies one or more processes by process name. You can type multiple process names (separated by commas) or use wildcard characters. The parameter name (“Name”) is optional.

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

    <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.Diagnostics.Process
        You can pipe a process object to Get-Process.

OUTPUTS
    System.Diagnostics.Process, System.Diagnotics.FileVersionInfo, System.Diagnostics.ProcessModule
        By default, Get-Process returns a System.Diagnostics.Process object. If you use the FileVersionInfo parameter, it returns a System.Diagnotics.FileVersionInfo object. If you use the Module parameter (without the FileVersionInfo parameter), it returns a System.Diagnostics.ProcessModule object.

NOTES

        You cannot use the Name, ID, and InputObject parameters in the same command.

        You can also refer to Get-Process by its built-in Aliases, “ps” and “gps”. For more information, see about_aliases.

        You can also use the properties and methods of the WMI Win32_Process object in Windows PowerShell. For information, see Get-WmiObject and the Windows Management Instrumentation (WMI) SDK.

        The default display of a process is a table that includes the following columns:

        — Handles: The number of handles that the process has opened.

        — NPM(K): The amount of non-paged memory that the process is using, in kilobytes.

        — PM(K): The amount of pageable memory that the process is using, in kilobytes.

        — WS(K): The size of the working set of the process, in kilobytes. The working set consists of the pages of memory that were recently referenced by the process.

        — VM(M): The amount of virtual memory that the process is using, in megabytes. Virtual memory includes storage in the paging files on disk.

        — CPU(s): The amount of processor time that the process has used on all processors, in seconds.

        — ID: The process ID (PID) of the process.

        — ProcessName: The name of the process.

        For explanations of the concepts related to processes, see the Glossary in Help and Support Center and the Help for Task Manager.

        You can also use the built-in alternate views of the processes available with Format-Table, such as “StartTime” and “Priority”, and you can design your own views. For more information, see Format-Table.

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

    C:\PS>Get-Process

    Description
    ———–
    This command gets a list of all of the running processes running on the local computer. For a definition of each column, see the “Additional Notes” section of the Help topic for Get-Help.

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

    C:\PS>Get-Process winword, explorer | Format-List *

    Description
    ———–
    This command gets all available data about the Winword and Explorer processes on the computer. It uses the Name parameter to specify the processes, but it omits the optional parameter name. The pipeline operator (|) passes the data to the Format-List cmdlet, which displays all available properties (*) of the Winword and Explorer process objects.

    You can also identify the processes by their process IDs. For example, “Get-Process -id 664, 2060″.

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

    C:\PS>Get-Process | Where-Object {$_.WorkingSet -gt 20000000}

    Description
    ———–
    This command gets all processes that have a working set greater than 20 MB. It uses the Get-Process cmdlet to get all running processes. The pipeline operator (|) passes the process objects to the Where-Object cmdlet, which selects only the object with a value greater than 20,000,000 bytes for the WorkingSet property.

    WorkingSet is one of many properties of process objects. To see all of the properties, type “Get-Process | Get-Member“. By default, the values of all amount properties are in bytes, even though the default display lists them in kilobytes and megabytes.

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

    C:\PS>$a = Get-Process

    C:\PS> Get-Process -inputobject $a | Format-Table -view priority

    Description
    ———–
    These commands list the processes on the computer in groups based on their priority class.

    The first command gets all the processes on the computer and then stores them in the $a Variable.

    The second command uses the InputObject parameter to pass the process objects that are stored in the $a Variable to the Get-Process cmdlet. The pipeline operator passes the objects to the Format-Table cmdlet, which formats the processes by using the Priority view.

    The priority view, and other views, are defined in the PS1XML format files in the Windows PowerShell home directory ($pshome).

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

    C:\PS>Get-Process powershell -ComputerName S1, localhost | ft @{Label=”NPM(K)”;Expression={[int]($_.NPM/1024)}}, @{Label=”PM(K)”;Expression={[int]($_.PM/1024)}},@{Label=”WS(K)”;Expression={[int]($_.WS/1024)}},@{Label=”VM(M)”;Expression={[int]($_.VM/1MB)}}, @{Label=”CPU(s)”;Expression={if ($_.CPU -ne $()) { $_.CPU.ToString(“N”)}}}, Id, MachineName, ProcessName -auto

    NPM(K) PM(K) WS(K) VM(M) CPU(s) Id MachineName ProcessName
    —— —– —– —– —— — ———– ———–
         6 23500 31340 142        1980 S1         powershell
         6 23500 31348 142        4016 S1         powershell
        27 54572 54520 576        4428 localhost powershell

    Description
    ———–
    This example provides a Format-Table (alias = ft) command that adds the MachineName property to the standard Get-Process output display.

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

    C:\PS>Get-Process powershell -FileVersionInfo

    ProductVersion FileVersion     FileName
    ————– ———–     ——–
    6.1.6713.1     6.1.6713.1 (f… C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe

    Description
    ———–
    This command uses the FileVersionInfo parameter to get the version information for the PowerShell.exe file that is the main module for the PowerShell process.

    To run this command with processes that you do not own on Windows Vista and later versions of Windows, you must open Windows PowerShell with the “Run as administrator” option.

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

    C:\PS>Get-Process sql* -Module

    Description
    ———–
    This command uses the Module parameter to get the modules that have been loaded by the process. This command gets the modules for the processes that have names that begin with “sql”.

    To run this command on Windows Vista (and later versions of Windows) with processes that you do not own, you must start Windows PowerShell with the “Run as administrator” option.

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

    C:\PS>$p = Get-WmiObject win32_process -filter “name=’powershell.exe'”

    C:\PS> $p.getowner()

    __GENUS         : 2
    __CLASS         : __PARAMETERS
    __SUPERCLASS     :
    __DYNASTY        : __PARAMETERS
    __RELPATH        :
    __PROPERTY_COUNT : 3
    __DERIVATION     : {}
    __SERVER         :
    __NAMESPACE     :
    __PATH         :
    Domain         : DOMAIN01
    ReturnValue     : 0
    User             : user01

    Description
    ———–
    This command shows how to find the owner of a process. Because the System.Diagnostics.Process object that Get-Process returns does not have a property or method that returns the process owner, the command uses
    the Get-WmiObject cmdlet to get a Win32_Process object that represents the same process.

    The first command uses Get-WmiObject to get the PowerShell process. It saves it in the $p Variable.

    The second command uses the GetOwner method to get the owner of the process in $p. The command reveals that the owner is Domain01\user01.

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

    C:\PS>Get-Process powershell

    C:\PS> Get-Process -id $pid

    C:\PS> Get-Process powershell

    Handles NPM(K)    PM(K)     WS(K) VM(M) CPU(s)     Id ProcessName
    ——- ——    —–     —– —– ——     — ———–
        308     26    52308     61780 567     3.18 5632 powershell
        377     26    62676     63384 575     3.88 5888 powershell

    C:\PS> Get-Process -id $pid

    Handles NPM(K)    PM(K)     WS(K) VM(M) CPU(s)     Id ProcessName
    ——- ——    —–     —– —– ——     — ———–
        396     26    56488     57236 575     3.90 5888 powershell

    Description
    ———–
    These commands show how to use the $pid automatic Variable to identify the process that is hosting the current Windows PowerShell session. You can use this method to distinguish the host process from other PowerShell processes that you might want to stop or close.

    The first command gets all of the PowerShell processes in the current session.

    The second command gets the PowerShell process that is hosting the current session.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113324
    Get-Process
    Start-Process
    Stop-Process
    Wait-Process
    Debug-Process

Get-Job

NAME
    Get-Job

SYNOPSIS
    Gets Windows PowerShell background jobs that are running in the current session.

SYNTAX
    Get-Job [-Command <string[]>] [<CommonParameters>]

    Get-Job [[-InstanceId] <Guid[]>] [<CommonParameters>]

    Get-Job [[-Name] <string[]>] [<CommonParameters>]

    Get-Job [[-Id] <Int32[]>] [<CommonParameters>]

    Get-Job [-State {NotStarted | Running | Completed | Failed | Stopped | Blocked}] [<CommonParameters>]

DESCRIPTION
    The Get-Job cmdlet gets objects that represent the background jobs that were started in the current session. You can use Get-Job to get jobs that were started by using Start-Job, or by using the AsJob parameter of any cmdlet.

    Without parameters, a “Get-Job” command gets all jobs in the current session. You can use the parameters of Get-Job to get particular jobs.

    The job object that Get-Job returns contains useful information about the job, but it does not contain the job results. To get the results, use the Receive-Job cmdlet.

    A Windows PowerShell background job is a command that runs “in the background” without interacting with the current session. Typically, you use a background job to run a complex command that takes a long time to complete. For more information about background jobs in Windows PowerShell, see about_jobs.

PARAMETERS
    -Command <string[]>
        Gets the jobs that include the specified command. The default is all jobs. Enter a command (as a string). You can use wildcards to specify a command pattern.

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

    -Id <Int32[]>
        Gets only jobs with the specified IDs.

        The ID is an integer that uniquely identifies the job within the current session. It is easier to remember and to type than the instance ID, but it is unique only within the current session. You can type one or more IDs (separated by commas). To find the ID of a job, type “Get-Job” without parameters.

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

    -InstanceId <Guid[]>
        Gets jobs with the specified instance IDs. The default is all jobs.

        An instance ID is a GUID that uniquely identifies the job on the computer. To find the instance ID of a job, use Get-Job.

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

    -Name <string[]>
        Gets the job with the specified friendly names. Enter a job name, or use wildcard characters to enter a job name pattern. By default, Get-Job gets all jobs in the current session.

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

    -State <JobState>
        Gets only jobs in the specified state. Valid values are NotStarted, Running, Completed, Stopped, Failed, and Blocked. By default, Get-Job gets all the jobs in the current session.

        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
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    System.Management.Automation.RemotingJob
        Get-Job returns objects that represent the jobs in the session.

NOTES

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

    C:\PS>Get-Job

    Description
    ———–
    This command gets all background jobs started in the current session. It does not include jobs created in other sessions, even if the jobs run on the local computer.

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

    C:\PS>$j = Get-Job -name Job1

    C:\PS> $ID = $j.InstanceID

    C:\PS> $ID

    Guid
    —-
    03c3232e-1d23-453b-a6f4-ed73c9e29d55

    C:\PS> Stop-Job -instanceid $ID

    Description
    ———–
    These commands show how to get the instance ID of a job and then use it to stop a job. Unlike the name of a job, which is not unique, the instance ID is unique.

    The first command uses the Get-Job cmdlet to get a job. It uses the Name parameter to identify the job. The command stores the job object that Get-Job returns in the $j Variable. In this example, there is only one job with the specified name.

    The second command gets the InstanceId property of the object in the $j Variable and stores it in the $ID Variable.

    The third command displays the value of the $ID Variable.

    The fourth command uses Stop-Job cmdlet to stop the job. It uses the InstanceId parameter to identify the job and $ID Variable to represent the instance ID of the job.

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

    C:\PS>Get-Job -command “*Get-Process*”

    Description
    ———–
    This command gets the jobs on the system that include a Get-Process command. The command uses the Command parameter of Get-Job to limit the jobs retrieved. The command uses wildcard characters (*) to get jobs that include a Get-Process command anywhere within the command string.

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

    C:\PS>”*Get-Process*” | Get-Job

    Description
    ———–
    Like the command in the previous example, this command gets the jobs on the system that include a Get-Process command. The command uses a pipeline operator (|) to send a string (in double quotation marks) to the Get-Job cmdlet. It is the equivalent of the previous command.

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

    C:\PS>Get-Job -state NotStarted

    Description
    ———–
    This command gets only those jobs that have been created but have not yet been started. This includes jobs that are scheduled to run in the future and those not yet scheduled.

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

    C:\PS>Get-Job -name job*

    Description
    ———–
    This command gets all jobs that have job names beginning with “job”. Because “job<number>” is the default name for a job, this command gets all jobs that do not have an explicitly assigned name.

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

    C:\PS>Start-Job -scriptblock {Get-Process} -name MyJob

    C:\PS> $j = Get-Job -name MyJob

    C:\PS> $j

    Id     Name     State     HasMoreData     Location    Command
    —     —-     —–     ———–     ——–    ——-
    1        myjob     Completed True            localhost Get-Process

    C:\PS> Receive-Job -job $j

    Handles NPM(K)    PM(K)     WS(K) VM(M) CPU(s)     Id ProcessName
    ——- ——    —–     —– —– ——     — ———–
        124     4    13572     12080    59            1140 audiodg
        783     16    11428     13636 100             548 CcmExec
         96     4     4252     3764    59            3856 ccmsetup
    …

    Description
    ———–
    This example shows how to use Get-Job to get a job object, and then it shows how to use the job object to represent the job in a command.

    The first command uses the Start-Job cmdlet to start a background job that runs a Get-Process command on the local computer. The command uses the Name parameter of Start-Job to assign a friendly name to the job.

    The second command uses Get-Job to get the job. It uses the Name parameter of Get-Job to identify the job. The command saves the resulting job object in the $j Variable.

    The third command displays the value of the job object in the $j Variable. The value of the State property shows that the job is complete. The value of the HasMoreData property shows that there are results available from the job that have not yet been retrieved.

    The fourth command uses the Receive-Job cmdlet to get the results of the job. It uses the job object in the $j Variable to represent the job. You can also use a pipeline operator to send a job object to Receive-Job.

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

    C:\PS>Start-Job -scriptblock {Get-Eventlog system}

    C:\PS> Invoke-Command -computername S1 -scriptblock {Get-Eventlog system} -AsJob

    C:\PS> Invoke-Command -computername S2 -scriptblock {Start-Job -scriptblock {Get-Eventlog system}}

    C:\PS> Get-Job

    Id    Name     State     HasMoreData Location Command
    —    —-     —–     ———– ——– ——-
    1     Job1     Running    True         localhost Get-Eventlog system
    2     Job2     Running    True         S1         Get-Eventlog system

    C:\PS> Invoke-Command -computername S2 -scriptblock {Get-Job}

    Id    Name     State     HasMoreData Location Command
    —    —-     —–     ———– ——– ——-
    4     Job4     Running    True         localhost Get-Eventlog system

    Description
    ———–
    This example demonstrates that the Get-Job cmdlet can get all of the jobs that were started in the current session, even if they were started by using different methods.

    The first command uses the Start-Job cmdlet to start a job on the local computer.

    The second command uses the AsJob parameter of Invoke-Command to start a job on the S1 computer. Even though the commands in the job run on the remote computer, the job object is created on the local computer, so you use local commands to manage the job.

    The third command uses the Invoke-Command cmdlet to run a Start-Job command on the S2 computer. With this method, the job object is created on the remote computer, so you use remote commands to manage the job.

    The fourth command uses Get-Job to get the jobs stored on the local computer.

    The fifth command uses Invoke-Command to run a Get-Job command on the S2 computer.

    The sample output shows the results of the Get-Job commands.

    For more information about running background jobs on remote computers, see about_remote_Jobs.

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

    C:\PS>Start-Job -scriptblock {Get-Process}

    Id     Name            State     HasMoreData     Location             Command
    —     —-            —–     ———–     ——–             ——-
    1        Job1            Failed     False         localhost            Get-Process

    C:\PS> (Get-Job).jobstateinfo | Format-List -property *

    State : Failed
    Reason :

    C:\PS> Get-Job | Format-List *

    HasMoreData : False
    StatusMessage :
    Location     : localhost
    Command     : Get-Process
    JobStateInfo : Failed
    Finished     : System.Threading.ManualResetEvent
    InstanceId    : fb792295-1318-4f5d-8ac8-8a89c5261507
    Id            : 1
    Name         : Job1
    ChildJobs     : {Job2}
    Output        : {}
    Error         : {}
    Progress     : {}
    Verbose     : {}
    Debug         : {}
    Warning     : {}
    StateChanged :

    C:\PS> (Get-Job -name job2).jobstateinfo.reason
    Connecting to remote server using WSManCreateShellEx api failed. The async callback gave the following error message :
    Access is denied.

    Description
    ———–
    This command shows how to use the job object that Get-Job returns to investigate why a job failed. It also shows how to get the child jobs of each job.

    The first command uses the Start-Job cmdlet to start a job on the local computer. The job object that Start-Job returns shows that the job failed. The value of the State property is “Failed”.

    The second command uses Get-Job to get the job object. The command uses the dot method to get the value of the JobStateInfo property of the object. It uses a pipeline operator to send the object in the JobStateInfo property to the Format-List cmdlet, which formats all of the properties of the object (*) in a list.

    The result of the Format-List command shows that the value of the Reason property of the job is blank.

    The third command investigates further. It uses a Get-Job command to get the job and then uses a pipeline operator to send the entire job object to the Format-List cmdlet, which displays all of the properties of the job in a list.

    The display of all properties in the job object shows that the job contains a child job named “Job2”.

    The fourth command uses Get-Job to get the job object that represents the Job2 child job. This is the job in which the command actually ran. It uses the dot method to get the Reason property of the JobStateInfo property.

    The result shows that the job failed because of an “access denied” error. In this case, the user forgot to use the “Run as administrator” option when opening Windows PowerShell.

    Because background jobs use the remoting features of Windows PowerShell, the computer must be configured for remoting to run a job, even when the job runs on the local computer.

    For information about requirements for remoting in Windows PowerShell, see about_remote_requirements. For troubleshooting tips, see about_remote_TroubleShooting.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113328
    about_jobs
    about_job_details
    about_remote_Jobs
    Start-Job
    Receive-Job
    Wait-Job
    Stop-Job
    Remove-Job
    Invoke-Command

Get-Location

NAME
    Get-Location

SYNOPSIS
    Gets information about the current working location.

SYNTAX
    Get-Location [-PSDrive <string[]>] [-PSProvider <string[]>] [-UseTransaction] [<CommonParameters>]

    Get-Location [-Stack] [-StackName <string[]>] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Get-Location cmdlet gets an object that represents the current directory, much like the pwd (print working directory) command.

    When you move between Windows PowerShell drives, Windows PowerShell retains your location in each drive. You can use Get-Location to find your location in each drive.

    You can also use Get-Location to get the current directory at run time and use it in Functions and scripts, such as in a Function that displays the current directory in the Windows PowerShell prompt.

    If you use the Push-Location cmdlet to add locations to a path stack, you can use the Stack parameter of Get-Location to display the current stack.

PARAMETERS
    -PSDrive <string[]>
        Gets the current location in the specified Windows PowerShell drive.

        For example, if you are in the Certificate: drive, you can use this parameter to find your current location in the C: drive.

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

    -PSProvider <string[]>
        Gets the current location in the drive supported by the specified Windows PowerShell provider.

        If the specified provider supports more than one drive, Get-Location returns the location on the most recently accessed drive.

        For example, if you are in the C: drive, you can use this parameter to find your current location in the drives of the Windows PowerShell Registry provider.

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

    -Stack [<SwitchParameter>]
        Displays the locations in the default path stack.

        To add paths to the default stack, use the Push-Location cmdlet.

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

    -StackName <string[]>
        Displays the locations in the specified path stacks.

        To create path stacks, use the Push-Location cmdlet.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     true (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
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    PathInfo objects or StackInfo objects
        If you use the Stack or StackName parameters, Get-Location returns a StackInfo object. Otherwise, it returns a PathInfo object.

NOTES

        Locations can be stored on a stack. The Push-Location cmdlet adds a location to the top of the stack. The Pop-Location cmdlet gets the location at the top of the stack.

        The ways that the PSProvider, PSDrive, Stack, and StackName parameters interact depends on the provider. Some combinations will result in errors, such as specifying both a drive and a provider that does not expose that drive. If no parameters are specified, Get-Location returns the PathInfo object for the provider that contains the current working location.

        The Get-Location 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-Location

    Path
    —-
    C:\WINDOWS

    Description
    ———–
    This command displays your location in the current Windows PowerShell drive.

    For example, if you are in the Windows directory of the C: drive, it displays the path to that directory.

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

    C:\PS>Set-Location

    Description
    ———–
    These commands demonstrate the use of Get-Location to display your current location in different Windows PowerShell drives.

    The first command uses the Set-Location cmdlet to set the current location to the Windows subdirectory of the C: drive.

        C:\PS> Set-Location C:\Windows

    The second command uses the Set-Location cmdlet to change the location to the HKLM:\Software\Microsoft Registry key. When you change to a location in the HKLM: drive, Windows PowerShell retains your location in the C: drive.

        PS C:\WINDOWS> Set-Location HKLM:\Software\Microsoft
        PS HKLM:\Software\Microsoft>

    The third command uses the Set-Location cmdlet to change the location to the “HKCU:\Control Panel\Input Method” Registry key.

        PS HKLM:\Software\Microsoft> Set-Location ‘HKCU:\Control Panel\Input Method’
        PS HKCU:\Control Panel\Input Method>

    The fourth command uses the Get-Location cmdlet to find the current location on the C: drive. It uses the PSDrive parameter to specify the drive.

        PS HKCU:\Control Panel\Input Method> Get-Location -PSDrive c
        Path
        —-
        C:\WINDOWS

    The fifth command uses the Set-Location cmdlet to return to the C: drive. Even though the command does not specify a subdirectory, Windows PowerShell returns you to the saved location.

        PS HKCU:\Control Panel\Input Method> Set-Location C:
        PS C:\WINDOWS>

    The sixth command uses the Get-Location cmdlet to find the current location in the drives supported by the Windows PowerShell Registry provider. Get-Location returns the location of the most recently accessed Registry drive, HKCU:.

        PS C:\WINDOWS> Get-Location -PSProvider Registry
        Path
        —-
        HKCU:\Control Panel\Input Method

    To see the current location in the HKLM: drive, you need to use the PSDrive parameter to specify the drive. The seventh command does just this:

        PS C:\WINDOWS> Get-Location -PSDrive HKLM
        Path
        —-
        HKLM:\Software\Microsoft

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

    C:\PS>Set-Location

    Description
    ———–
    These commands show how to use the Stack and StackName parameters of Get-Location to list the paths in the default and alternate path stacks.

    The first command sets the current location to the Windows directory on the C: drive.

        C:\PS> Set-Location C:\Windows

    The second command uses the Push-Location cmdlet to push the current location (C:\Windows) onto the path stack and change to the System32 subdirectory. Because no stack is specified, the current location is pushed onto the default stack.
        C:\WINDOWS>Push-Location System32

    The third command pushes the current location (C:\Windows\System32) onto the Stack2 stack and changes the location to the WindowsPowerShell subirectory.

        C:\Windows\System32>Push-Location WindowsPowerShell -stack Stack2

    The fourth command uses the Get-Location cmdlet to get the paths on the default path stack.

        C:\WINDOWS\system32\WindowsPowerShell>Get-Location -stack

        Path
        —-
        C:\WINDOWS

    The last command uses the StackName parameter of Get-Location to get the paths on the Stack2 stack.

        C:\WINDOWS\system32\WindowsPowerShell>Get-Location -stackname Stack2

        Path
        —-
        C:\WINDOWS\system32

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

    C:\PS>function prompt { ‘PowerShell: ‘ + (Get-Location) + ‘> ‘}

    PowerShell: C:\WINDOWS>

    Description
    ———–
    This example shows how to customize the Windows PowerShell prompt. The Function that defines the prompt includes a Get-Location command, which is run whenever the prompt appears in the console.

    The format of the default Windows PowerShell prompt is defined by a special Function called “prompt”. You can change the prompt in your console by creating a new Function called “prompt”.

    To see the current prompt Function, type the following command:

        Get-Content Function:prompt

    The command begins with the “function” keyword followed by the Function name, “prompt”. The Function body appears within braces ( {} ).

    This command defines a new prompt that begins with the string “PowerShell: “. To append the current location, it uses a Get-Location command, which runs when the prompt Function is called. The prompt ends with the string “> “.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113321
    about_providers
    Pop-Location
    Push-Location
    Set-Location

Get-Member

NAME
    Get-Member

SYNOPSIS
    Gets the properties and methods of objects.

SYNTAX
    Get-Member [[-Name] <string[]>] [-Force] [-InputObject <psobject>] [-MemberType {AliasProperty | CodeProperty | Property | NoteProperty | ScriptProperty | Properties | PropertySet | Method | CodeMethod | ScriptMethod | Methods | ParameterizedProperty | MemberSet | Event | All}] [-Static] [-View {Extended | Adapted | Base | All}] [<CommonParameters>]

DESCRIPTION
    The Get-Member cmdlet gets the “members” (properties and methods) of objects.

    To specify the object, use the InputObject parameter or pipe an object to Get-Member. To retrieve information about static members (members of the class, not of the instance), use the Static parameter. To get only certain types of members, such as NoteProperties, use the MemberType parameter.

PARAMETERS
    -Force [<SwitchParameter>]
        Adds the intrinsic members (PSBase, PSAdapted, PSObject, PSTypeNames) and the compiler-generated get_ and set_ methods to the display. By default, Get-Member gets these properties in all views other than “Base” and “Adapted,” but it does not display them.

        The following list describes the properties that are added when you use the Force parameter:

        — PSBase: The original properties of the .NET Framework object without extension or adaptation. These are the properties defined for the object class and listed in MSDN.
        — PSAdapted: The properties and methods defined in the Windows PowerShell extended type system.
        — PSExtended: The properties and methods that were added in the Types.ps1xml files or by using the Add-Member cmdlet.
        — PSObject: The adapter that converts the base object to a Windows PowerShell PSObject object.
        — PSTypeNames: A list of object types that describe the object, in order of specificity. When formatting the object, Windows PowerShell searches for the types in the Format.ps1xml files in the Windows PowerShell installation directory ($pshome). It uses the formatting definition for the first type that it finds.

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

    -InputObject <psobject>
        Specifies the object whose members are retrieved.

        Using the InputObject parameter is not the same as piping an object to Get-Member. The differences are as follows:

        — When you pipe a collection of objects to Get-Member, Get-Member gets the members of the individual objects in the collection, such as the properties of the integers in an array of integers.

        — When you use InputObject to submit a collection of objects, Get-Member gets the members of the collection, such as the properties of the array in an array of integers.

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

    -MemberType <PSMemberTypes>
        Gets only members with the specified member type. The default is All.

        The valid values for this parameter are:

        — AliasProperty: A property that defines a new name for an existing property.
        — CodeMethod: A method that references a static method of a .NET Framework class.
        — CodeProperty: A property that references a static property of a .NET Framework class.
        — Event: Indicates that the object sends a message to indicate an action or a change in state.
        — MemberSet: A predefined collection of properties and methods, such as PSBase, PSObject, and PSTypeNames.
        — Method: A method of the underlying .NET Framework object.
        — NoteProperty: A property with a static value.
        — ParameterizedProperty: A property that takes parameters and parameter values.
        — Property: A property of the underlying .NET Framework object.
        — PropertySet: A predefined collection of object properties.
        — ScriptMethod: A method whose value is the output of a script.
        — ScriptProperty: A property whose value is the output of a script.

        — All: Gets all member types.
        — Methods: Gets all types of methods of the object (for example, Method, CodeMethod, ScriptMethod).
        — Properties: Gets all types of properties of the object (for example, Property, CodeProperty, AliasProperty, ScriptProperty).

        Not all objects have every type of member. If you specify a member type that the object does not have, Windows PowerShell returns a null value.

        To get related types of members, such as all extended members, use the View parameter. If you use the MemberType parameter with the Static or View parameters, Get-Member gets the members that belong to both sets.

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

    -Name <string[]>
        Specifies the names of one or more properties or methods of the object. Get-Member gets only the specified properties and methods.

        If you use the Name parameter with the MemberType, View, or Static parameters, Get-Member gets only the members that satisfy the criteria of all parameters.

        To get a static member by name, use the Static parameter with the Name parameter.

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

    -Static [<SwitchParameter>]
        Gets only the static properties and methods of the object.

        Static properties and methods are defined on the class of objects, not on any particular instance of the class.

        If you use the Static parameter with the View parameter, the View parameter is ignored. If you use the Static parameter with the MemberType parameter, Get-Member gets only the members that belong to both sets.

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

    -View <PSMemberViewTypes>
        Gets only particular types of members (properties and methods). Specify one or more of the values. The default is “Adapted, Extended”.

        Valid values are:
        — Base: Gets only the original properties and methods of the .NET Framework object (without extension or adaptation).
        — Adapted: Gets only the properties and methods defined in the Windows PowerShell extended type system.
        — Extended: Gets only the properties and methods that were added in the Types.ps1xml files or by using the Add-Member cmdlet.
        — All: Gets the members in the Base, Adapted, and Extended views.

        The View parameter determines the members retrieved, not just the display of those members.

        To get particular member types, such as script properties, use the MemberType parameter. If you use the MemberType and View parameters in the same command, Get-Member gets the members that belong to both sets. If you use the Static and View parameters in the same command, the View parameter is ignored.

        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 to Get-Member

OUTPUTS
    Microsoft.PowerShell.Commands.MemberDefinition
        Get-Member returns an object for each property or method that its gets.

NOTES

        You can retrieve information about a collection object either by using the InputObject parameter or by piping the object, preceded by a comma, to Get-Member.

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

    C:\PS>Get-Service | Get-Member

     TypeName: System.ServiceProcess.ServiceController

    Name                     MemberType    Definition
    —-                     ———-    ———-
    Name                     AliasProperty Name = ServiceName
    Close                     Method        System.Void Close()
    Continue                 Method        System.Void Continue()
    CreateObjRef             Method        System.Runtime.Remoting.ObjRef CreateObjRef(Type requestedType)
    Dispose                 Method        System.Void Dispose()
    Equals                    Method        System.Boolean Equals(Object obj)
    ExecuteCommand            Method        System.Void ExecuteCommand(Int32 command)
    GetHashCode             Method        System.Int32 GetHashCode()
    GetLifetimeService        Method        System.Object GetLifetimeService()
    GetType                 Method        System.Type GetType()
    InitializeLifetimeService Method        System.Object InitializeLifetimeService()
    Pause                     Method        System.Void Pause()
    Refresh                 Method        System.Void Refresh()
    Start                     Method        System.Void Start(), System.Void Start(String[] args)
    Stop                     Method        System.Void Stop()
    ToString                 Method        System.String ToString()
    WaitForStatus             Method        System.Void WaitForStatus(ServiceControllerStatus desiredStatus), System.Voi…
    CanPauseAndContinue     Property     System.Boolean CanPauseAndContinue {get;}
    CanShutdown             Property     System.Boolean CanShutdown {get;}
    CanStop                 Property     System.Boolean CanStop {get;}
    Container                 Property     System.ComponentModel.IContainer Container {get;}
    DependentServices         Property     System.ServiceProcess.ServiceController[] DependentServices {get;}
    DisplayName             Property     System.String DisplayName {get;set;}
    MachineName             Property     System.String MachineName {get;set;}
    ServiceHandle             Property     System.Runtime.InteropServices.SafeHandle ServiceHandle {get;}
    ServiceName             Property     System.String ServiceName {get;set;}
    ServicesDependedOn        Property     System.ServiceProcess.ServiceController[] ServicesDependedOn {get;}
    ServiceType             Property     System.ServiceProcess.ServiceType ServiceType {get;}
    Site                     Property     System.ComponentModel.ISite Site {get;set;}
    Status                    Property     System.ServiceProcess.ServiceControllerStatus Status {get;}

    Description
    ———–
    This command displays the properties and methods of the process objects (System.ServiceProcess.ServiceController) that are generated by the Get-Service cmdlet.

    The command uses the pipeline operator (|) to send the output of a Get-Service command to Get-Member.

    Because the Get-Member part of the command does not have any parameters, it uses all of the default values. As such, it gets all member types, but it does not get static members and does not display intrinsic members.

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

    C:\PS>Get-Service | Get-Member -Force

    C:\PS> (Get-Service -schedule).psbase

    Description
    ———–
    This example gets all of the members (properties and methods) of the service objects (System.ServiceProcess.ServiceController) retrieved by the Get-Service cmdlet, including the intrinsic members, such as PSBase and PSObject, and the get_ and set_ methods.

    The first command uses the Get-Service cmdlet to get objects that represent the services on the system. It uses a pipeline operator (|) to pass the service objects to the Get-Member cmdlet.

    The Get-Member command uses the Force parameter to add the intrinsic members and compiler-generated members of the objects to the display. Get-Member gets these members, but it hides them by default.

    You can use these properties and methods in the same way that you would use an adapted method of the object. The second command shows how to display the value of the PSBase property of the Schedule service.

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

    C:\PS>Get-Service    | Get-Member -View extended

     TypeName: System.ServiceProcess.ServiceController

    Name MemberType    Definition
    —- ———-    ———-
    Name AliasProperty Name = ServiceName

    Description
    ———–
    This command gets the methods and properties of service objects that were extended by using the Types.ps1xml file or the Add-Member cmdlet.

    The Get-Member command uses the View parameter to get only the extended members of the service objects. In this case, the extended member is the Name property, which is an Alias property of the ServiceName property.

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

    C:\PS>Get-Eventlog -log system | gm -MemberType scriptproperty

     TypeName: System.Diagnostics.EventLogEntry

    Name    MemberType     Definition
    —-    ———-     ———-
    EventID ScriptProperty System.Object EventID {get=$this.get_EventID() -band 0xFFFF;}

    Description
    ———–
    This command gets the script properties of event log objects in the System log in Event Viewer. In this case, the only script property is the EventID.

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

    C:\PS>Get-Eventlog -log system | Get-Member -MemberType scriptproperty

     TypeName: System.Diagnostics.EventLogEntry

    Name    MemberType     Definition
    —-    ———-     ———-
    EventID ScriptProperty System.Object EventID {get=$this.get_EventID() -band 0xFFFF;}

    Description
    ———–
    This command gets the script properties of event log objects in the System log in Event Viewer.

    The command uses the MemberType parameter to get only objects with a value of AliasProperty for their MemberType property.

    The command returns the EventID property of the EventLog object.

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

    C:\PS>$a = “Get-Process“, “Get-Service“, “Get-Culture“, “Get-PSDrive“, “Get-ExecutionPolicy

    C:\PS> foreach ($cmdlet in $a) {Invoke-Expression $cmdlet | Get-Member -Name machinename}

    TypeName: System.Diagnostics.Process

    Name        MemberType Definition
    —-        ———- ———-
    MachineName Property System.String MachineName {get;}

     TypeName: System.ServiceProcess.ServiceController

    Name        MemberType Definition
    —-        ———- ———-
    MachineName Property System.String MachineName {get;set;}

    Description
    ———–
    This command gets objects that have a MachineName property from a list of cmdlets.

    The first command stores the names of several cmdlets in the $a Variable.

    The second command uses a ForEach statement to invoke each command, send the results to Get-Member, and limit the results from Get-Member to members that have the name “MachineName.”

    The results show that only process objects (System.Diagnostics.Process) and service objects (System.ServiceProcess.ServiceController) have a MachineName property.

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

    C:\PS>$a = Get-Member -InputObject @(1)

    C:\PS>$a.count

    1

    C:\PS> $a = Get-Member -InputObject 1,2,3

     TypeName: System.Object[]
    Name             MemberType    Definition
    —-             ———-    ———-
    Count             AliasProperty Count = Length
    Address            Method        System.Object& Address(Int32 )
    Clone             Method        System.Object Clone()
    …

    C:\PS>$a.count
    1

    Description
    ———–
    This example demonstrates how to find the properties and methods of an array of objects when you have only one object of the given type.

    Because the goal of the command is to find the properties of an array, the first command uses the InputObject parameter. It uses the “at” symbol (@) to indicate an array. In this case, the array contains only one object, the integer 1.

    The third command uses the Get-Member cmdlet to get the properties and methods of an array of integers, and the command saves them in the $a Variable.

    The fourth command uses the Count property of the array to find the number of objects in the $a Variable.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113322
    Add-Member
    Get-Help
    Get-Command
    Get-PSDrive

Get-Item

NAME
    Get-Item

SYNOPSIS
    Gets the item at the specified location.

SYNTAX
    Get-Item [-LiteralPath] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-UseTransaction] [<CommonParameters>]

    Get-Item [-Path] <string[]> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Get-Item cmdlet gets the item at the specified location. It does not get the contents of the item at the location unless you use a wildcard character (*) to request all the contents of the item.

    The Get-Item cmdlet is used by Windows PowerShell providers to enable you to navigate through different types of data stores.

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.

        The Exclude parameter is effective only when the command includes the contents of an item, such as C:\Windows\*, where the wildcard character specifies the contents of the C:\Windows directory.

        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 get items that cannot otherwise be accessed, such as hidden items. 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 contents of an item, 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 the item. 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 the path to an item. Get-Item gets the item at the specified location. Wildcards are permitted. This parameter is required, but the parameter name (“Path”) is optional.

        Use a dot (.) to specify the current location. Use the wildcard character (*) to specify all the items in the current location.

        Required?                    true
        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-Item.

OUTPUTS
    Object
        Get-Item returns the objects that it gets. The type is determined by the type of objects in the path.

NOTES

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

        Get-Item does not have a Recurse parameter, because it gets only an item, not its contents. To get the contents of an item recursively, use Get-ChildItem.

        To navigate through the Registry, use Get-Item to get Registry keys and Get-ItemProperty to get Registry values and data. The Registry values are considered to be properties of the Registry key.

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

    Directory: C:\

    Mode                LastWriteTime     Length Name
    —-                ————-     —— —-
    d—-         7/26/2006 10:01 AM            ps-test

    Description
    ———–
    This command gets the current directory. The dot (.) represents the item at the current location (not its contents).

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

    C:\PS>Get-Item *

    Directory: C:\ps-test

    Mode                LastWriteTime     Length Name
    —-                ————-     —— —-
    d—-         7/26/2006 9:29 AM            Logs
    d—-         7/26/2006 9:26 AM            Recs
    -a—         7/26/2006 9:28 AM         80 date.csv
    -a—         7/26/2006 10:01 AM         30 filenoext
    -a—         7/26/2006 9:30 AM     11472 process.doc
    -a—         7/14/2006 10:47 AM         30 test.txt

    Description
    ———–
    This command gets all the items in the current directory. The wildcard character (*) represents all the contents of the current item.

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

    C:\PS>Get-Item C:\

    Description
    ———–
    This command gets the current directory of the C: drive. The object that is retrieved represents only the directory, not its contents.

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

    C:\PS>Get-Item C:\*

    Description
    ———–
    This command gets the items in the C: drive. The wildcard character (*) represents all the items in the container, not just the container.

    In Windows PowerShell, use a single asterisk (*) to get contents, instead of the traditional “*.*”. The format is interpreted literally, so “*.*” would not retrieve directories or file names without a dot.

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

    C:\PS>(Get-Item C:\Windows).LastAccessTime

    Description
    ———–
    This command gets the LastAccessTime property of the C:\Windows directory. LastAccessTime is just one property of file system directories. To see all of the properties of a directory, type “(Get-Item <directory-name>) | Get-Member“.

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

    C:\PS>Get-Item hklm:\software\microsoft\powershell\1\shellids\microsoft.powershell\*

    Description
    ———–
    This command shows the contents of the Microsoft.PowerShell Registry key. You can use Get-Item with the Windows PowerShell Registry provider to get Registry keys and subkeys, but you must use Get-ItemProperty to get the Registry values and data.

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

    C:\PS>Get-Item c:\Windows\* -Include *.* -Exclude w*

    Description
    ———–
    This command gets items in the Windows directory with names that include a dot (.), but do not begin with w*. This command works only when the path includes a wildcard character (*) to specify the contents of the item.

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

Get-ItemProperty

NAME
    Get-ItemProperty

SYNOPSIS
    Gets the properties of a specified item.

SYNTAX
    Get-ItemProperty [-LiteralPath] <string[]> [[-Name] <string[]>] [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Include <string[]>] [-UseTransaction] [<CommonParameters>]

    Get-ItemProperty [-Path] <string[]> [[-Name] <string[]>] [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Include <string[]>] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Get-ItemProperty cmdlet gets the properties of the specified items. For example, you can use Get-ItemProperty to get the value of the LastAccessTime property of a file object. You can also use Get-ItemProperty to view Registry entries and their values.

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

    -Include <string[]>
        Includes the specified items.

        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 name of the property or properties to retrieve.

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

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

        Required?                    true
        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-ItemProperty.

OUTPUTS
    Object
        Get-ItemProperty returns an object for each item property that it gets. The object type depends on the object that is retrieved.

NOTES

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

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

    C:\PS>Get-Itemproperty C:\Windows

    Description
    ———–
    This command gets information about the C:\Windows directory.

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

    C:\PS>Get-Itemproperty C:\Test\Weather.xls | Format-List

    Description
    ———–
    This command gets the properties of the C:\Test\Weather.xls file. The result is piped to the Format-List cmdlet to display the output as a list.

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

    C:\PS>Get-Itemproperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion

    Description
    ———–
    This command displays the value name and data of each of the Registry entries contained in the CurrentVersion Registry subkey. Note that the command requires that there is a Windows PowerShell drive named HKLM: that is mapped to the HKEY_LOCAL_MACHINE hive of the Registry. A drive with that name and mapping is available in Windows PowerShell by default. Alternatively, the path to this Registry subkey can be specified by using the following alternative path that begins with the provider name followed by two colons:
    Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion.

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

    C:\PS>Get-Itemproperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion `
    -Name “ProgramFilesDir”

    Description
    ———–
    This command gets the value name and data of the ProgramFilesDir Registry entry in the CurrentVersion Registry subkey. The command uses the Path parameter to specify the subkey and the Name parameter to specify the value name of the entry.

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

    C:\PS>Get-Itemproperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine

    ApplicationBase         : C:\Windows\system32\WindowsPowerShell\v1.0\
    ConsoleHostAssemblyName : Microsoft.PowerShell.ConsoleHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad
                             364e35, ProcessorArchitecture=msil
    PowerShellVersion     : 2.0
    RuntimeVersion         : v2.0.50727
    CTPVersion             : 5
    PSCompatibleVersion     : 1.0,2.0

    Description
    ———–
    This command gets the value names and data of the Registry entries in the PowerShellEngine Registry key. The results are shown in the following sample output.

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

    C:\PS>Get-Itemproperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell

    Path                                                        ExecutionPolicy
    —-                                                        —————
    C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe RemoteSigned

    C:\PS>Get-Itemproperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell | Format-List -property *

    PSPath         : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\PowerShell\1\ShellIds\Micro
                     soft.PowerShell
    PSParentPath    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\PowerShell\1\ShellIds
    PSChildName     : Microsoft.PowerShell
    PSDrive         : HKLM
    PSProvider     : Microsoft.PowerShell.Core\Registry
    Path            : C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
    ExecutionPolicy : RemoteSigned

    Description
    ———–
    This example shows how to format the output of a Get-ItemProperty command in a list to make it easy to see the Registry values and data and to make it easy to interpret the results.

    The first command uses the Get-ItemProperty cmdlet to get the Registry entries in the Microsoft.PowerShell subkey. This subkey stores options for the default shell for Windows PowerShell. The results are shown in the following sample output.

    The output shows that there are two Registry entries, Path and ExecutionPolicy. When a Registry key contains fewer than five entries, by default it is displayed in a table, but it is often easier to view in a list.

    The second command uses the same Get-ItemProperty command. However, this time, the command uses a pipeline operator (|) to send the results of the command to the Format-List cmdlet. The Format-List command uses the Property parameter with a value of * (all) to display all of the properties of the objects in a list. The results are shown in the following sample output.

    The resulting display shows the Path and ExecutionPolicy Registry entries, along with several less familiar properties of the Registry key object. The other properties, prefixed with “PS”, are properties of Windows PowerShell custom objects, such as the objects that represent the Registry keys.

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

Get-History

NAME
    Get-History

SYNOPSIS
    Gets a list of the commands entered during the current session.

SYNTAX
    Get-History [[-Id] <Int64[]>] [[-Count] <int>] [<CommonParameters>]

DESCRIPTION
    The Get-History cmdlet gets the session history, that is, the list of commands entered during the current session. Windows PowerShell automatically maintains a history of each session. You can save the session history in XML or CSV format. By default, history files are saved in the home directory, but you can save the file in any location.

PARAMETERS
    -Count <int>
        Displays the specified number of the most recent history entries. The default is 32. If you use both the Count and Id parameters in a command, the display ends with the command specified by the Id parameter.

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

    -Id <Int64[]>
        Specifies the ID number of a command in the session history. Get-History gets only the specified command. If you use Id and Count, Get-History gets the most recent commands ending with the command specified by the Id parameter.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue)
        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
    Int64
        You can pipe a history ID to Get-History.

OUTPUTS
    Microsoft.PowerShell.Commands.HistoryInfo
        Get-History returns a history object for each history item that it gets.

NOTES

        The session history is a list of the commands entered during the session along with the ID. The session history represents the order of execution, the status, and the start and end times of the command. As you enter each command, Windows PowerShell adds it to the history so that you can reuse it. For more information about the command history, see about_History.

        You can also refer to Get-History by its built-in Aliases, “h”, “history”, and “ghy”. For more information, see about_aliases.

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

    C:\PS>Get-History

    Description
    ———–
    This command gets the 32 most recently submitted commands. The default display shows each command and its ID, which indicates the order of execution.

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

    C:\PS>Get-History | Where-Object {$_.commandLine -like “*service*”}

    Description
    ———–
    This command gets entries from the command history that include the word, “service”. The first command gets the 32 most recent entries in the session history. The pipeline operator (|) passes the results to the Where-Object cmdlet, which selects only the commands that include “service”.

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

    C:\PS>Get-History -Id 7 -Count 5 | Export-Csv history.csv

    Description
    ———–
    This command gets the five most recent history entries ending with entry 7. The pipeline operator (|) passes the result to the Export-Csv cmdlet, which formats the history as comma-separated text and saves it in the History.csv file. The file includes the data that is displayed when you format the history as a list, including the status and start and end times of the command.

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

    C:\PS>Get-History -Count 1

    Description
    ———–
    This command gets the last (most recently entered) command in the command history. It uses the Count parameter to display just one command. By default, Get-History displays the most recent commands. This command can be abbreviated to “h -c 1” and is equivalent to pressing the up-arrow key.

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

    C:\PS>Get-History -Count $MaximumHistoryCount

    Description
    ———–
    This command displays all of the commands saved in the session history. By default, $MaximumHistoryCount is 64, so this command can be abbreviated as “h -c 64”.

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

    C:\PS>Get-History | Format-List

    Description
    ———–
    This command displays all of the properties of entries in the session history. The pipeline operator (|) passes the result to the Format-List cmdlet, which displays all of the properties of each history entry, including the ID, status, and start and end times of the command.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113317
    about_History
    Invoke-History
    Add-History
    Clear-History

Get-Host

NAME
    Get-Host

SYNOPSIS
    Gets an object that represents the current host program. And, displays Windows PowerShell version and regional information by default.

SYNTAX
    Get-Host [<CommonParameters>]

DESCRIPTION
    The Get-Host cmdlet gets an object that represents the program that is hosting Windows PowerShell.

    The default display includes the Windows PowerShell version number and the current region and language settings that the host is using, but the host object contains a wealth of information, including detailed information about the version of Windows PowerShell that is currently running and the current culture and UI culture of Windows PowerShell. You can also use this cmdlet to customize features of the host program user interface, such as the text and background colors.

PARAMETERS
    <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 this cmdlet.

OUTPUTS
    System.Management.Automation.Internal.Host.InternalHost
        Get-Host returns a System.Management.Automation.Internal.Host.InternalHost object.

NOTES

        The $host automatic Variable contains the same object that Get-Host returns, and you can use it in the same way. Similarly, the $PSCulture and $PSUICulture automatic Variables contain the same objects that the CurrentCulture and CurrentUICulture properties of the host object contain. You can use these features interchangeably.

        For more information, see about_Automatic_Variables.

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

    C:\PS>Get-Host

    Name             : ConsoleHost
    Version         : 2.0
    InstanceId     : e4e0ab54-cc5e-4261-9117-4081f20ce7a2
    UI             : System.Management.Automation.Internal.Host.InternalHostUserInterface
    CurrentCulture : en-US
    CurrentUICulture : en-US
    PrivateData     : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
    IsRunspacePushed : False
    Runspace         : System.Management.Automation.Runspaces.LocalRunspace

    Description
    ———–
    This command displays information about the Windows PowerShell console, which is the current host program for Windows PowerShell in this example. It includes the name of the host, the version of Windows PowerShell that is running in the host, and current culture and UI culture.

    The Version, UI, CurrentCulture, CurrentUICulture, PrivateData, and Runspace properties each contain an object with very useful properties. Later examples examine these properties.

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

    C:\PS>$h = Get-Host

    C:\PS> $win = $h.ui.rawui.windowsize

    C:\PS> $win.height = 10

    C:\PS> $win.width = 10

    C:\PS> $h.ui.rawui.set_windowsize($win)

    Description
    ———–
    This command resizes the Windows PowerShell window to 10 pixels by 10 pixels.

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

    C:\PS>(Get-Host).version | Format-List -property *

    Major         : 2
    Minor         : 0
    Build         : -1
    Revision     : -1
    MajorRevision : -1
    MinorRevision : -1

    Description
    ———–
    This command gets detailed information about the version of Windows PowerShell running in the host. You can view, but not change, these values.

    The Version property of Get-Host contains a System.Version object. This command uses a pipeline operator (|) to send the version object to the Format-List cmdlet. The Format-List command uses the Property parameter with a value of all (*) to display all of the properties and property values of the version object.

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

    C:\PS>(Get-Host).currentculture | Format-List -property *

    Parent                         : en
    LCID                         : 1033
    KeyboardLayoutId             : 1033
    Name                         : en-US
    IetfLanguageTag                : en-US
    DisplayName                    : English (United States)
    NativeName                     : English (United States)
    EnglishName                    : English (United States)
    TwoLetterISOLanguageName     : en
    ThreeLetterISOLanguageName     : eng
    ThreeLetterWindowsLanguageName : ENU
    CompareInfo                    : CompareInfo – 1033
    TextInfo                     : TextInfo – 1033
    IsNeutralCulture             : False
    CultureTypes                 : SpecificCultures, InstalledWin32Cultures, FrameworkCultures
    NumberFormat                 : System.Globalization.NumberFormatInfo
    DateTimeFormat                 : System.Globalization.DateTimeFormatInfo
    Calendar                     : System.Globalization.GregorianCalendar
    OptionalCalendars             : {System.Globalization.GregorianCalendar, System.Globalization.GregorianCalendar}
    UseUserOverride                : True
    IsReadOnly                     : False

    Description
    ———–
    This command gets detailed information about the current culture set for Windows PowerShell running in the host. This is the same information that is returned by the Get-Culture cmdlet.

    (Similarly, the CurrentUICulture property returns the same object that Get-UICulture returns.)

    The CurrentCulture property of the host object contains a System.Globalization.CultureInfo object. This command uses a pipeline operator (|) to send the CultureInfo object to the Format-List cmdlet. The Format-List command uses the Property parameter with a value of all (*) to display all of the properties and property values of the CultureInfo object.

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

    C:\PS>(Get-Host).currentculture.DateTimeFormat | Format-List -property *

    AMDesignator                     : AM
    Calendar                         : System.Globalization.GregorianCalendar
    DateSeparator                    : /
    FirstDayOfWeek                 : Sunday
    CalendarWeekRule                 : FirstDay
    FullDateTimePattern             : dddd, MMMM dd, yyyy h:mm:ss tt
    LongDatePattern                 : dddd, MMMM dd, yyyy
    LongTimePattern                 : h:mm:ss tt
    MonthDayPattern                 : MMMM dd
    PMDesignator                     : PM
    RFC1123Pattern                 : ddd, dd MMM yyyy HH’:’mm’:’ss ‘GMT’
    ShortDatePattern                 : M/d/yyyy
    ShortTimePattern                 : h:mm tt
    SortableDateTimePattern         : yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss
    TimeSeparator                    : :
    UniversalSortableDateTimePattern : yyyy’-‘MM’-‘dd HH’:’mm’:’ss’Z’
    YearMonthPattern                 : MMMM, yyyy
    AbbreviatedDayNames             : {Sun, Mon, Tue, Wed…}
    ShortestDayNames                 : {Su, Mo, Tu, We…}
    DayNames                         : {Sunday, Monday, Tuesday, Wednesday…}
    AbbreviatedMonthNames            : {Jan, Feb, Mar, Apr…}
    MonthNames                     : {January, February, March, April…}
    IsReadOnly                     : False
    NativeCalendarName             : Gregorian Calendar
    AbbreviatedMonthGenitiveNames    : {Jan, Feb, Mar, Apr…}
    MonthGenitiveNames             : {January, February, March, April…}

    Description
    ———–
    This command returns detailed information about the DateTimeFormat of the current culture that is being used for Windows PowerShell.

    The CurrentCulture property of the host object contains a CultureInfo object that, in turn, has many useful properties. Among them, the DateTimeFormat property contains a DateTimeFormatInfo object with many useful properties.

    To find the type of an object that is stored in an object property, use the Get-Member cmdlet. To display the property values of the object, use the Format-List cmdlet.

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

    C:\PS>(Get-Host).ui.rawui | Format-List -property *

    ForegroundColor     : DarkYellow
    BackgroundColor     : DarkBlue
    CursorPosition        : 0,390
    WindowPosition        : 0,341
    CursorSize            : 25
    BufferSize            : 120,3000
    WindowSize            : 120,50
    MaxWindowSize         : 120,81
    MaxPhysicalWindowSize : 182,81
    KeyAvailable         : False
    WindowTitle         : Windows PowerShell 2.0 (04/11/2008 00:08:14)

    Description
    ———–
    This command displays the properties of the RawUI property of the host object. By changing these values, you can change the appearance of the host program.

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

    C:\PS>(Get-Host).ui.rawui.backgroundcolor = “Black”

    C:\PS> cls

    Description
    ———–
    These commands change the background color of the Windows PowerShell console to black. The “cls” command is an Alias for the Clear-Host Function, which clears the screen and changes the whole screen to the new color.

    This change is effective only in the current session. To change the background color of the console for all sessions, add the command to your Windows PowerShell profile.

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

    C:\PS>$host.privatedata.errorbackgroundcolor = “white”

    Description
    ———–
    This command changes the background color of error messages to white.

    This command uses the $host automatic Variable, which contains the host object for the current host program. Get-Host returns the same object that $host contains, so you can use them interchangeably.

    This command uses the PrivateData property of $host as its ErrorBackgroundColor property. To see all of the properties of the object in the $host.privatedata property, type “$host.privatedata | Format-List * “.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113318
    Read-Host
    Out-Host
    Write-Host

Get-HotFix

NAME
    Get-HotFix

SYNOPSIS
    Gets the hotfixes that have been applied to the local and remote computers.

SYNTAX
    Get-HotFix [[-Id] <string[]>] [-ComputerName <string[]>] [-Credential <PSCredential>] [<CommonParameters>]

    Get-HotFix [-Description <string[]>] [-ComputerName <string[]>] [-Credential <PSCredential>] [<CommonParameters>]

DESCRIPTION
    The Get-HotFix cmdlet gets the hotfixes that have been applied to the local computer or to remote computers by Component-Based Servicing.

PARAMETERS
    -ComputerName <string[]>
        Specifies a remote computer. The default is the local computer.

        Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qualified domain name of a remote computer.

        This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of Get-HotFix even if your computer is not configured to run remote commands.

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

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

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

    -Description <string[]>
        Gets only hotfixes with the specified descriptions. Wildcards are permitted. The default is all hotfixes on the computer.

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

    -Id <string[]>
        Gets only hotfixes with the specified hotfix IDs. The default is all hotfixes on the computer.

        Required?                    false
        Position?                    1
        Default value                All hotfixes
        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 Get-HotFix.

OUTPUTS
    System.Management.ManagementObject#root\CIMV2\Win32_QuickFixEngineering
        Get-HotFix returns objects that represent the hotfixes on the computer.

NOTES

        This cmdlet uses the Win32_QuickFixEngineering WMI class, which represents small system-wide updates of the operating system. Starting with Windows Vista, this class returns only the updates supplied by Component Based Servicing (CBS). It does not include updates that are supplied by Microsoft Windows Installer (MSI) or the Windows update site. For more information, see the Win32_QuickFixEngineering class topic in the Microsoft .NET Framework SDK at http://go.microsoft.com/fwlink/?LinkID=145071.

        The output of this cmdlet might be different on different operating systems.

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

    C:\PS>Get-HotFix

    Description
    ———–
    This command gets all hotfixes on the local computer.

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

    C:\PS>Get-HotFix -description Security* -ComputerName Server01, Server02 -cred Server01\admin01

    Description
    ———–
    This command gets all hotfixes on the Server01 and Server02 computers that have a description that begins with “Security”.

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

    C:\PS>$a = Get-Content servers.txt

    C:\PS> $a | foreach { if (!(Get-HotFix -Id KB957095 -ComputerName $_)) { Add-Content $_ -path Missing-kb953631.txt }}

    Description
    ———–
    The commands in this example create a text file listing the names of computers that are missing a security update.

    The commands use the Get-HotFix cmdlet to get the KB957095 security update on all of the computers whose names are listed in the Servers.txt file.

    If a computer does not have the update, the Add-Content cmdlet writes the computer name in the Missing-KB953631.txt file.

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

    C:\PS>(Get-HotFix | sort installedon)[-1]

    Description
    ———–
    This command gets the most recent hotfix on the computer.

    It gets the hotfixes, sorts them by the value of the InstalledOn property, and then it uses array notation to select the last item in the array.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=135217
    Get-ComputerRestorePoint

Get-Help

NAME
    Get-Help

SYNOPSIS
    Displays information about Windows PowerShell commands and concepts.

SYNTAX
    Get-Help [-Full] [[-Name] <string>] [-Category <string[]>] [-Component <string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <string[]>] [<CommonParameters>]

    Get-Help [-Detailed] [[-Name] <string>] [-Category <string[]>] [-Component <string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <string[]>] [<CommonParameters>]

    Get-Help [-Examples] [[-Name] <string>] [-Category <string[]>] [-Component <string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <string[]>] [<CommonParameters>]

    Get-Help [-Parameter <string>] [[-Name] <string>] [-Category <string[]>] [-Component <string[]>] [-Functionality <string[]>] [-Online] [-Path <string>] [-Role <string[]>] [<CommonParameters>]

DESCRIPTION
    The Get-Help cmdlet displays information about Windows PowerShell concepts and commands, including cmdlets, providers, Functions and scripts. To get a list of all cmdlet help topic titles, type “Get-Help *”.

    If you type “Get-Help” followed by the exact name of a help topic, or by a word unique to a help topic, Get-Help displays the topic contents. If you enter a word or word pattern that appears in several help topic titles, Get-Help displays a list of the matching titles. If you enter a word that does not appear in any help topic titles, Get-Help displays a list of topics that include that word in their contents.

    In addition to “Get-Help“, you can also type “help” or “man”, which displays one screen of text at a time, or “<cmdlet-Name> -?”, which is identical to Get-Help but works only for cmdlets.

    You can display the entire help file or selected parts of the file, such as the syntax, parameters, or examples. You can also use the Online parameter to display an online version of a help file in your Internet browser. These parameters have no effect on conceptual help topics.

    Conceptual help topics in Windows PowerShell begin with “about_”, such as “about_Comparison_Operators”. To see all “about_” topics, type “Get-Help about_*”. To see a particular topic, type “Get-Help about_<topic-Name>”, such as “Get-Help about_Comparison_Operators“.

PARAMETERS
    -Category <string[]>
        Displays help for items in the specified category. Valid values are Alias, Cmdlet, Provider, and HelpFile. Conceptual topics are in the HelpFile category.

        Category is a property of the MamlCommandHelpInfo object that Get-Help returns. This parameter has no effect on displays of conceptual (“about_”) help.

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

    -Component <string[]>
        Displays a list of tools with the specified component value, such as “Exchange.” Enter a component name. Wildcards are permitted.

        Component is a property of the MamlCommandHelpInfo object that Get-Help returns. This parameter has no effect on displays of conceptual (“About_”) help.

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

    -Detailed [<SwitchParameter>]
        Adds parameter descriptions and examples to the basic help display.

        This parameter has no effect on displays of conceptual (“About_”) help.

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

    -Examples [<SwitchParameter>]
        Displays only the name, synopsis, and examples. To display only the examples, type “(Get-Help <cmdlet-Name>).examples”.

        This parameter has no effect on displays of conceptual (“About_”) help.

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

    -Full [<SwitchParameter>]
        Displays the entire help file for a cmdlet, including parameter descriptions and attributes, examples, input and output object types, and additional notes.

        This parameter has no effect on displays of conceptual (“About_”) help.

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

    -Functionality <string[]>
        Displays help for items with the specified Functionality. Enter the Functionality. Wildcards are permitted.

        Functionality is a property of the MamlCommandHelpInfo object that Get-Help returns. This parameter has no effect on displays of conceptual (“About_”) help.

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

    -Name <string>
        Requests help about the specified tool or conceptual topic. Enter a cmdlet, provider, script, or Function name, such as Get-Member, a conceptual topic name, such as “about_Objects”, or an Alias, such as “ls”. Wildcards are permitted in cmdlet and provider names, but you cannot use wildcards to find the names of Function help and script help topics.

        To get help for a script that is not located in a path that is listed in the Path Environment Variable, type the path and file name of the script .

        If you enter the exact name of a help topic, Get-Help displays the topic contents. If you enter a word or word pattern that appears in several help topic titles, Get-Help displays a list of the matching titles. If you enter a word that does not match any help topic titles, Get-Help displays a list of topics that include that word in their contents.

        The names of conceptual topics, such as about_objects, must be entered in English, even in non-English versions of Windows PowerShell.

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

    -Online [<SwitchParameter>]
        Displays the online version of a help topic in the default Internet browser. This parameter is valid only for cmdlet, Function, and script help topics.

        Get-Help uses the Internet address (Uniform Resource Identifier [URI]) that appears in the first item of the Related Links section of a cmdlet, Function, or script help topic. This parameter works only when the help topic includes a URI that begins with “Http” or “Https” and an Internet browser is installed on the system.

        For information about supporting this feature in help topics that you write, see about_Comment_Based_Help, and see “How to Write Cmdlet Help” in the MSDN (Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?LinkID=123415.

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

    -Parameter <string>
        Displays only the detailed descriptions of the specified parameters. Wildcards are permitted.

        This parameter has no effect on displays of conceptual (“About_”) help.

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

    -Path <string>
        Gets help that explains how the cmdlet works in the specified provider path. Enter a Windows PowerShell provider path.

        This parameter gets a customized version of a cmdlet help topic that explains how the cmdlet works in the specified Windows PowerShell provider path. This parameter is effective only for help about a provider cmdlet and only when the provider includes a custom version of the provider cmdlet help topic.

        To see the custom cmdlet help for a provider path, go to the provider path location and enter a Get-Help command or, from any path location, use the Path parameter of Get-Help to specify the provider path. For more information, see about_providers.

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

    -Role <string[]>
        Displays help customized for the specified user role. Enter a role. Wildcards are permitted.

        Enter the role that the user plays in an organization. Some cmdlets display different text in their help files based on the value of this parameter. This parameter has no effect on help for the core cmdlets.

        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 objects to this cmdlet.

OUTPUTS
    System.String or MamlCommandHelpInfo
        If you request a conceptual topic, Get-Help returns it as a string. If you specify the name of a cmdlet,, Function, or script, it returns a MamlCommandHelpInfo object. Otherwise, Get-Help returns one of the formatted views that are specified in the Help.Format.ps1xml file in the $pshome directory.

NOTES

        Without parameters, “Get-Help” displays information about the Windows PowerShell help system.

        The full view of help (-Full) includes a table of information about the parameters. The table includes the following fields:

        — Required: Indicates whether the parameter is required (true) or optional (false).

        — Position: Indicates whether the parameter is named or positional (numbered). Positional parameters must appear in a specified place in the command.

        — “Named” indicates that the parameter name is required, but that the parameter can appear anywhere in the command.

        — <Number> indicates that the parameter name is optional, but when the name is omitted, the parameter must be in the place specified by the number. For example, “2” indicates that when the parameter name is omitted, the parameter must be the second (2) or only unnamed parameter in the command. When the parameter name is used, the parameter can appear anywhere in the command.

        — Default value: The parameter value that Windows PowerShell uses if you do not include the parameter in the command.

        — Accepts pipeline input: Indicates whether you can (true) or cannot (false) send objects to the parameter through a pipeline. “By Property Name” means that the pipelined object must have a property with the same name as the parameter name.

        — Accepts wildcard characters: Indicates whether the value of a parameter can include wildcard characters, such as * and ?.

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

    C:\PS>Get-Help

    Description
    ———–
    This command displays help about the Windows PowerShell help system.

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

    C:\PS>Get-Help *

    Description
    ———–
    This command displays a list of all help files in the Windows PowerShell help system.

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

    C:\PS>Get-Help Get-Alias

    C:\PS>help Get-Alias

    C:\PS>Get-Alias -?

    Description
    ———–
    These commands display basic information about the Get-Alias cmdlet. The “Get-Help” and “-?” commands display the information on a single page. The “Help” command displays the information one page at a time.

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

    C:\PS>Get-Help about_*

    Description
    ———–
    This command displays a list of the conceptual topics included in Windows PowerShell help. All of these topics begin with the characters “about_”. To display a particular help file, type “Get-Help <topic-Name>, for example, “Get-Help about_Signing“.

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

    C:\PS>Get-Help ls -detailed

    Description
    ———–
    This command displays detailed help for the Get-ChildItem cmdlet by specifying one of its Aliases, “ls.” The Detailed parameter requests the detailed view of the help file, which includes parameter descriptions and examples. To see the complete help file for a cmdlet, use the Full parameter.

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

    C:\PS>Get-Help format-string -Full

    Description
    ———–
    This command displays the full view help for the Format-String cmdlet. The full view of help includes parameter descriptions, examples, and a table of technical details about the parameters.

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

    C:\PS>Get-Help Start-Service -examples

    Description
    ———–
    This command displays examples of using Start-Service in Windows PowerShell commands.

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

    C:\PS>Get-Help Get-ChildItem -parameter f*

    Description
    ———–
    This command displays descriptions of the parameters of the Get-ChildItem cmdlet that begin with “f” (filter and force). For descriptions of all parameters, type “Get-Help Get-ChildItem parameter*”.

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

    C:\PS>(Get-Help Write-Output).syntax

    Description
    ———–
    This command displays only the syntax of the Write-Output cmdlet.

    Syntax is one of many properties of help objects; others are description, details, examples, and parameters. To find all properties and methods of help objects, type “Get-Help <cmdlet-Name> | Get-Member“; for example, “Get-Help Start-Service | get member”.

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

    C:\PS>(Get-Help Trace-Command).alertset

    Description
    ———–
    This command displays the notes about the cmdlet. The notes are stored in the alertSet property of the help object.

    The notes include conceptual information and tips for using the cmdlet. By default, the notes are displayed only when you use the Full parameter of Get-Help, but you can also display them by using the alertSet property.

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

    C:\PS>Get-Help Add-Member -Full | Out-String -stream | Select-String -pattern clixml

    Description
    ———–
    This example shows how to search for a word in particular cmdlet help topic. This command searches for the word “clixml” in the full version of the help topic for the Add-Member cmdlet.

    Because the Get-Help cmdlet generates a MamlCommandHelpInfo object, not a string, you need to use a command that transforms the help topic content into a string, such as Out-String or Out-File.

    ————————– EXAMPLE 12 ————————–

    C:\PS>Get-Help Get-Member -Online

    Description
    ———–
    This command displays the online version of the help topic for the Get-Member cmdlet.

    ————————– EXAMPLE 13 ————————–

    C:\PS>Get-Help remoting

    Description
    ———–
    This command displays a list of topics that include the word “remoting” in their contents.

    When you enter a word that does not appear in any topic title, Get-Help displays a list of topics that include that word.

    ————————– EXAMPLE 14 ————————–

    C:\PS>Get-Help Get-Item -Path SQLSERVER:\DataCollection

    NAME
        Get-Item

    SYNOPSIS
        Gets a collection of Server objects for the local computer and any computers to which you have made a SQL Server PowerShell connection.
    …

    C:\PS> cd SQLSERVER:\DataCollection
    C:\PS> SQLSERVER:\DataCollection> Get-Help Get-Item

    NAME
        Get-Item

    SYNOPSIS
        Gets a collection of Server objects for the local computer and any computers to which you have made a SQL Server PowerShell connection.
    …

    C:\PS> Get-Item

    NAME
        Get-Item

    SYNOPSIS
        Gets the item at the specified location.

    …

    Description
    ———–
    This example shows how to get help for the Get-Item cmdlet that explains how to use the cmdlet in the DataCollection node of the Windows PowerShell SQL Server provider.

    The example shows two ways of getting the custom help for Get-Item.

    The first command uses the Path parameter of Get-Help to specify the provider path. This command can be entered at any path location.

    The second command uses the Set-Location cmdlet (alias = “cd”) to go to the provider path. From that location, even without the Path parameter, the Get-Help command gets the custom help for the provider path.

    The third command shows that a Get-Help command in a file system path, and without the Path parameter, gets the standard help for the Get-Item cmdlet.

    ————————– EXAMPLE 15 ————————–

    C:\PS>Get-Help c:\ps-test\MyScript.ps1

    Description
    ———–
    This command gets help for the MyScript.ps1 script. For information about writing help for your Functions and scripts, see about_Comment_Based_Help.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113316

    about_Comment_Based_Help
    Get-Command
    Get-PSDrive
    Get-Member