Tag Archives: OutBuffer

Get-PSSnapin

NAME
    Get-PSSnapin

SYNOPSIS
    Gets the Windows PowerShell snap-ins on the computer.

SYNTAX
    Get-PSSnapin [[-Name] <string[]>] [-Registered] [<CommonParameters>]

DESCRIPTION
    The Get-PSSnapin cmdlet gets the Windows PowerShell snap-ins that have been added to the current session or that have been registered on the system. The snap-ins are listed in the order in which they are detected.

    Get-PSSnapin gets only registered snap-ins. To register a Windows PowerShell snap-in, use the InstallUtil tool included with the Microsoft .NET Framework 2.0. For more information, see “How to Register Cmdlets, Providers, and Host Applications” in the MSDN (Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?LinkId=143619.

PARAMETERS
    -Name <string[]>
        Gets only the specified Windows PowerShell snap-ins. Enter the names of one or more Windows PowerShell snap-ins. Wildcards are permitted.

        The parameter name (“Name”) is optional.

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

    -Registered [<SwitchParameter>]
        Gets the Windows PowerShell snap-ins that have been registered on the system (even if they have not yet been added to the session).

        The snap-ins that are installed with Windows PowerShell do not appear in this list.

        Without this parameter, Get-PSSnapin gets the Windows PowerShell snap-ins that have been added to the session.

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

OUTPUTS
    System.Management.Automation.PSSnapInInfo
        Get-PSSnapin returns an object for each snap-in that it gets.

NOTES

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

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

    C:\PS>Get-PSSnapin

    Description
    ———–
    This command gets the Windows PowerShell snap-ins that are currently loaded in the session. This includes the snap-ins that are installed with Windows PowerShell and those that have been added to the session.

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

    C:\PS>Get-PSSnapin -Registered

    Description
    ———–
    This command gets the Windows PowerShell snap-ins that have been registered on the computer, including those that have already been added to the session. The output does not include snap-ins that are installed with Windows PowerShell or Windows PowerShell snap-in dynamic-link libraries (DLLs) that have not yet been registered on the system.

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

    C:\PS>Get-PSSnapin smp*

    Description
    ———–
    This command gets the Windows PowerShell snap-ins in the current session that have names that begin with “smp”.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113330
    Add-PSSnapin
    Remove-PSSnapin

Get-PSProvider

NAME
    Get-PSProvider

SYNOPSIS
    Gets information about the specified Windows PowerShell provider.

SYNTAX
    Get-PSProvider [[-PSProvider] <string[]>] [<CommonParameters>]

DESCRIPTION
    The Get-PSProvider cmdlet gets the Windows PowerShell providers in the current session. You can get a particular drive or all drives in the session.

    Windows PowerShell providers let you access a variety of data stores as though they were file system drives. For information about Windows PowerShell providers, see about_providers.

PARAMETERS
    -PSProvider <string[]>
        Specifies the name or names of the Windows PowerShell providers about which to retrieve information.

        Required?                    false
        Position?                    1
        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 objects to this cmdlet.

OUTPUTS
    System.Management.Automation.ProviderInfo
        Get-PSProvider returns objects that represent the Windows PowerShell providers in the session.

NOTES

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

    C:\PS>Get-PSProvider

    Description
    ———–
    This command displays a list of all available Windows PowerShell providers.

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

    C:\PS>Get-PSProvider f*, r* | Format-List

    Description
    ———–
    This command displays a list of all Windows PowerShell providers with names that begin with the letter “f” or “r”.

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

    C:\PS>Get-PSProvider | Format-Table name, module, pssnapin -auto

    Name        Module     PSSnapIn
    —-        ——     ——–
    Test        TestModule
    WSMan                    Microsoft.WSMan.Management
    Alias                    Microsoft.PowerShell.Core
    Environment             Microsoft.PowerShell.Core
    FileSystem             Microsoft.PowerShell.Core
    Function                 Microsoft.PowerShell.Core
    Registry                 Microsoft.PowerShell.Core
    Variable                 Microsoft.PowerShell.Core
    Certificate             Microsoft.PowerShell.Security

    C:\PS> Get-PSProvider | where {$_.pssnapin -eq “Microsoft.PowerShell.Security”}

    Name            Capabilities     Drives
    —-            ————     ——
    Certificate     ShouldProcess     {cert}

    Description
    ———–
    These commands find the Windows PowerShell snap-ins or modules that added providers to your session. All Windows PowerShell elements, including providers, originate in a snap-in or in a module.

    These commands use the PSSnapin and Module properties of the ProviderInfo object that Get-PSProvider returns. The values of these properties contain the name of the snap-in or module that adds the provider.

    The first command gets all of the providers in the session and formats them in a table with the values of their Name, Module, and PSSnapin properties.

    The second command uses the Where-Object cmdlet to get the providers that come from the Microsoft.PowerShell.Security snap-in.

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

Get-PSSession

NAME
    Get-PSSession

SYNOPSIS
    Gets the Windows PowerShell sessions (PSSessions) in the current session.

SYNTAX
    Get-PSSession [[-ComputerName] <string[]>] [<CommonParameters>]

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

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

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

DESCRIPTION
    The Get-PSSession cmdlet gets the Windows PowerShell sessions (PSSessions) that were created in the current session.

    Without parameters, Get-PSSession gets all of the PSSessions created in the current session. You can use the parameters of Get-PSSession to get the sessions that are connected to particular computers, or you can identify sessions by their names, IDs, or instance IDs.

    For more information about Windows PowerShell sessions, see about_pssessions.

PARAMETERS
    -ComputerName <string[]>
        Gets only the PSSessions that are connected to the specified computers. Wildcards are permitted.

        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, “localhost”, or a dot (.).

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

    -Id <Int32[]>
        Gets only the PSSessions with the specified IDs. Type one or more IDs (separated by commas), or use the range operator (..) to specify a range of IDs.

        An ID is an integer that uniquely identifies the PSSession in the current session. It is easier to remember and type than the InstanceId, but it is unique only within the current session. To find the ID of a PSSession, use Get-PSSession without parameters.

        Required?                    true
        Position?                    1
        Default value                All sessions in the shell
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -InstanceId <Guid[]>
        Gets only the PSSessions with the specified instance IDs.

        The instance ID is a GUID that uniquely identifies a PSSession on a local or remote computer. The InstanceID is unique, even when you have multiple sessions running in Windows PowerShell.

        The InstanceID is stored in the InstanceID property of the object that represents a PSSession. To find the InstanceID of the PSSessions in the current session, type “Get-PSSession | Format-Table Name, ComputerName, InstanceId”.

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

    -Name <string[]>
        Gets only the PSSessions with the specified friendly names. Wildcards are permitted.

        To find the names of the PSSessions in the current session, type “Get-PSSession” without parameters.

        Required?                    false
        Position?                    named
        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
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    System.Management.Automation.Runspaces.PSSession
        Get-PSSession returns a PSSession object for each PSSession that it gets.

NOTES

        Get-PSSession gets the PSSessions that were created in the current session. It does not get the session that is created when you open Windows PowerShell, and it does not get PSSessions that were created in other sessions or on other computers, even if they connect to the local computer.

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

    C:\PS>Get-PSSession

    Description
    ———–
    This command gets all of the PSSessions that were created in the current session.

    It does not get PSSessions that were created in other sessions or on other computers, even if they connect to this computer.

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

    C:\PS>$s = Get-PSSession -ComputerName Server02

    Description
    ———–
    This command gets the PSSessions that are connected to the Server02 computer and saves them in the $p Variable.

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

    C:\PS>New-PSSession -ComputerName Server01, Server02, Server03

    C:\PS> $s1, $s2, $s3 = Get-PSSession

    Description
    ———–
    This example shows how to save the results of a Get-PSSession command in multiple Variables.

    The first command uses the New-PSSession cmdlet to create PSSessions on three remote computers.

    The second command uses a Get-PSSession cmdlet to get the three PSSessions. It then saves each of the PSSessions in a separate Variable.

    When Windows PowerShell assigns an array of objects to an array of Variables, it assigns the first object to the first Variable, the second object to the second Variable, and so on. If there are more objects than Variables, it assigns all remaining objects to the last Variable in the array. If there are more Variables than objects, the extra Variables are not used.

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

    C:\PS>Get-PSSession | Format-Table -property computername, InstanceID

    C:\PS> $s = Get-PSSession -InstanceID a786be29-a6bb-40da-80fb-782c67f7db0f

    C:\PS> Remove-PSSession -session $s

    Description
    ———–
    This example shows how to get a PSSession by using its instance ID, and then to delete the PSSession.

    The first command gets all of the PSSessions on the local computer. It sends the PSSessions to the Format-Table cmdlet, which displays the ComputerName and InstanceID properties of each PSSession.

    The second command uses the Get-PSSession cmdlet to get a particular PSSession and to save it in the $s Variable. The command uses the InstanceID parameter to identify the PSSession.

    The third command uses the Remove-PSSession cmdlet to delete the PSSession in the $s Variable.

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

    C:\PS>Get-PSSession -ComputerName Serv*

    Description
    ———–
    This command gets all the PSSessions that connect to computers that have computer names that begin with “Serv”.

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

    C:\PS>Get-PSSession -name Test*, Ux*

    Description
    ———–
    This command gets PSSessions that have names that begin with “Test” or “Ux”.

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

    C:\PS>Get-PSSession 2

    Description
    ———–
    This command gets the PSSession with ID 2.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=135219
    about_pssessions
    about_remote
    New-PSSession
    Remove-PSSession
    Enter-PSSession
    Exit-PSSession
    Invoke-Command

Get-PSBreakpoint

NAME
    Get-PSBreakpoint

SYNOPSIS
    Gets the breakpoints that are set in the current session.

SYNTAX
    Get-PSBreakpoint [[-Script] <string[]>] [<CommonParameters>]

    Get-PSBreakpoint -Command <string[]> [-Script <string[]>] [<CommonParameters>]

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

    Get-PSBreakpoint [-Type] <BreakpointType[]> [-Script <string[]>] [<CommonParameters>]

    Get-PSBreakpoint -Variable <string[]> [-Script <string[]>] [<CommonParameters>]

DESCRIPTION
    The Get-PSBreakpoint cmdlet gets the breakpoints that are set in the current session. You can use the cmdlet parameters to get particular breakpoints.

    A breakpoint is a point in a command or script where execution stops temporarily so that you can examine the instructions. Get-PSBreakpoint is one of several cmdlets designed for debugging Windows PowerShell scripts and commands. For more information about the Windows PowerShell debugger, see about_debuggers.

PARAMETERS
    -Command <string[]>
        Gets command breakpoints that are set on the specified command names. Enter the command names, such as the name of a cmdlet or Function.

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

    -Id <Int32[]>
        Gets the breakpoints with the specified breakpoint IDs. Enter the IDs in a comma-separated list. You can also pipe breakpoint IDs to Get-PSBreakpoint.

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

    -Script <string[]>
        Gets only the breakpoints in the specified scripts. Enter the path (optional) and names of one or more script files. The default location is the current directory.

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

    -Type <BreakpointType[]>
        Gets only breakpoints of the specified types. Enter one or more types. Valid values are Line, Command, and Variable. You can also pipe breakpoint types to Get-PSBreakpoint.

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

    -Variable <string[]>
        Gets Variable breakpoints that are set on the specified Variable names. Enter the Variable names without dollar signs.

        Required?                    true
        Position?                    named
        Default value                All breakpoints
        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.Int32, Microsoft.PowerShell.Commands.BreakpointType
        You can pipe breakpoint IDs and breakpoint types to Get-PSBreakpoint.

OUTPUTS
    Breakpoint object (System.Management.Automation.LineBreakpoint, System.Management.Automation.VariableBreakpoint, System.Management.Automation.CommandBreakpoint)
        Get-PSBreakpoint returns objects that represent the breakpoints in the session.

NOTES

        You can use Get-PSBreakpoint or its Alias, “gbp”.

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

    C:\PS>Get-PSBreakpoint

    Description
    ———–
    This command gets all breakpoints set on all scripts and Functions in the current session.

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

    C:\PS>Get-PSBreakpoint -Id 2

    Function : Increment
    Action     :
    Enabled    : True
    HitCount : 0
    Id         : 2
    Script     : C:\ps-test\sample.ps1
    ScriptName : C:\ps-test\sample.ps1

    Description
    ———–
    This command gets the breakpoint with breakpoint ID 2.

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

    C:\PS>$b = Set-PSBreakpoint -Script sample.ps1 -function increment

    C:\PS> $b.Id | Get-PSBreakpoint

    Description
    ———–
    These commands show how to get a breakpoint by piping a breakpoint ID to Get-PSBreakpoint.

    The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint on the Increment Function in the Sample.ps1 script. It saves the breakpoint object in the $b Variable.

    The second command uses the dot operator (.) to get the Id property of the breakpoint object in the $b Variable. It uses a pipeline operator (|) to send the ID to the Get-PSBreakpoint cmdlet.

    As a result, Get-PSBreakpoint gets the breakpoint with the specified ID.

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

    C:\PS>Get-PSBreakpoint -Script Sample.ps1, SupportScript.ps1

    Description
    ———–
    This command gets all of the breakpoints in the Sample.ps1 and SupportScript.ps1 files.

    This command does not get other breakpointS that might be set in other scripts or on Functions in the session.

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

    C:\PS>Get-PSBreakpoint -command Read-Host, Write-Host -Script Sample.ps1

    Description
    ———–
    This command gets all Command breakpoints that are set on Read-Host or Write-Host commands in the Sample.ps1 file.

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

    C:\PS>Get-PSBreakpoint -type Command -Script Sample.ps1

    Description
    ———–
    This command gets all Command breakpoints in the Sample.ps1 file.

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

    C:\PS>Get-PSBreakpoint -variable Index, Swap

    Description
    ———–
    This command gets breakpoints that are set on the $index and $swap Variables in the current session.

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

    C:\PS>Get-PSBreakpoint -type line, Variable -Script Sample.ps1

    Description
    ———–
    This command gets all line and Variable breakpoints in the Sample.ps1 script.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113325
    about_debuggers
    Set-PSBreakpoint
    Disable-PSBreakpoint
    Enable-PSBreakpoint
    Remove-PSBreakpoint
    Get-PSCallStack

Get-PSCallStack

NAME
    Get-PSCallStack

SYNOPSIS
    Displays the current call stack.

SYNTAX
    Get-PSCallStack [<CommonParameters>]

DESCRIPTION
    The Get-PSCallStack cmdlet displays the current call stack.

    Although it is designed to be used with the Windows PowerShell debugger, you can use this cmdlet to display the call stack in a script or Function outside of the debugger.

    To run a Get-PSCallStack command while in the debugger, type “k” or “Get-PSCallStack“.

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

OUTPUTS
    System.Management.Automation.CallStackFrame
        Get-PSCallStack returns an object that represents the items in the call stack.

NOTES

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

    C:\PS>function my-alias {
     $p = $args[0]
     Get-Alias | where {$_.definition -like “*$p”} | ft definition, name -auto
    }

    PS C:\ps-test> Set-PSBreakpoint -command my-alias

    Command    : my-alias
    Action     :
    Enabled    : True
    HitCount : 0
    Id         : 0
    Script     : prompt

    PS C:\ps-test> my-alias Get-Content
    Entering debug mode. Use h or ? for help.

    Hit Command breakpoint on ‘prompt:my-alias’

    my-alias Get-Content

    [DBG]: PS C:\ps-test> s
    $p = $args[0]

    DEBUG: Stepped to ‘:    $p = $args[0]    ‘

    [DBG]: PS C:\ps-test> s
    Get-Alias | Where {$_.Definition -like “*$p*”} | ft Definition,

    [DBG]: PS C:\ps-test>Get-PSCallStack

    Name        CommandLineParameters         UnboundArguments             Location
    —-        ———————         —————-             ——–
    prompt     {}                            {}                            prompt
    my-alias    {}                            {Get-Content}                 prompt
    prompt     {}                            {}                            prompt

    [DBG]: PS C:\ps-test> o

    Definition Name
    ———- —-
    Get-Content gc
    Get-Content cat
    Get-Content type

    Description
    ———–
    This command uses the Get-PSCallStack cmdlet to display the call stack for My-Alias, a simple Function that gets the Aliases for a cmdlet name.

    The first command enters the Function at the Windows PowerShell prompt. The second command uses the Set-PSBreakpoint cmdlet to set a breakpoint on the My-Alias Function. The third command uses the My-Alias Function to get all of the Aliases in the current session for the Get-Content cmdlet.

    The debugger breaks in at the Function call. Two consecutive step-into (s) commands begin executing the Function line by line. Then, a Get-PSCallStack command is used to retrieve the call stack.

    The final command is a Step-Out command (o) that exits the debugger and continues executing the script to completion.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113326
    about_debuggers
    Set-PSBreakpoint
    Get-PSBreakpoint
    Enable-PSBreakpoint
    Disable-PSBreakpoint
    Remove-PSBreakpoint

Get-PSDrive

NAME
    Get-PSDrive

SYNOPSIS
    Gets the Windows PowerShell drives in the current session.

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

    Get-PSDrive [[-Name] <string[]>] [-PSProvider <string[]>] [-Scope <string>] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Get-PSDrive cmdlet gets the Windows PowerShell drives in the current session. You can get a particular drive or all drives in the console.

    Get-PSDrive gets the following drives:

    — Windows logical drives on the computer, including drives mapped to network shares.

    — Drives exposed by Windows PowerShell providers (such as the Certificate:, Function:, and Alias: drives) and the HKLM: and HKCU: drives that are exposed by the Windows PowerShell Registry provider.

    — Drives that you create by using New-PSDrive.

    Get-PSDrive does not get Windows mapped drives that are added or created after the Windows PowerShell console is opened.

PARAMETERS
    -LiteralName <string[]>
        Specifies the name of the Windows PowerShell drive.

        The value of LiteralName is used exactly as it is typed. No characters are interpreted as wildcards. If the name 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[]>
        Gets only the specified drives. Type the drive name or letter without a colon (:).

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

    -PSProvider <string[]>
        Gets only the drives supported by the specified Windows PowerShell provider. Type the name of a provider, such as FileSystem, Registry, or Certificate.

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

    -Scope <string>
        Gets only the Windows PowerShell drives in the specified scope. Valid values are “Global”, “Local”, or “Script”, or a number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent). “Local” is the default. For more information, see about_scopes.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     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 objects to Get-PSDrive.

OUTPUTS
    System.Management.Automation.PSDriveInfo
        Get-PSDrive returns objects that represent the Windows PowerShell drives in the session.

NOTES

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

    Name     Provider     Root
    —-     ——–     —-
    Alias     Alias
    C         FileSystem    C:\
    cert     Certificate \
    D         FileSystem    D:\
    Env        Environment
    Function Function
    HKCU     Registry     HKEY_CURRENT_USER
    HKLM     Registry     HKEY_LOCAL_MACHINE
    Variable Variable
    X         FileSystem    X:\

    Description
    ———–
    This command gets the Windows PowerShell drives in the current session.

    The output shows the hard drive (C:) and CD-ROM drive (D:) on the computer, the drives exposed by the Windows PowerShell providers (Alias:, Cert:, Env:, Function:, HKCU:, HKLM:, and Variable:), and a drive mapped to a network share (X:).

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

    C:\PS>Get-PSDrive d

    Name     Provider     Root
    —-     ——–     —-
    D         FileSystem    D:\

    Description
    ———–
    This command displays the D: drive on the computer. Note that the drive letter is not followed by a colon.

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

    C:\PS>Get-PSDrive -PSProvider FileSystem

    Name     Provider     Root
    —-     ——–     —-
    C         FileSystem    C:\
    D         FileSystem    D:\
    X         FileSystem    X:\
    Y         FileSystem    \\Server01\Public
    Z         FileSystem    C:\Windows\System32

    Description
    ———–
    This command displays all of the drives that are supported by the Windows PowerShell FileSystem provider. This includes fixed drives, logical partitions, mapped network drives, and drives that you create by using New-PSDrive that are mapped to the file system drives.

    This example shows that drives created by New-PSDrive have the name of the mapped location in the value of the Root property. Windows drives just have the root of the drive letter.

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

    C:\PS>if (!(Get-PSDrive X)) {
        New-PSDrive -Name X -PSProvider Registry -root HKLM:\Network
    }
    else { Write-Host “The X: drive is already in use.” }

    Description
    ———–
    This command checks to see whether the X drive is already in use as the Windows PowerShell drive name. If it is not, the command uses the New-PSDrive cmdlet to create a Windows PowerShell drive that is mapped to the HKLM:\Network Registry key.

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

    C:\PS>Get-PSDrive -provider FileSystem

    C:\PS> Get-PSDrive -provider FileSystem

    Name     Provider     Root
    —-     ——–     —-
    C         FileSystem    C:\
    D         FileSystem    D:\
    X         FileSystem    X:\
    Y         FileSystem    \\Server01\Public
    Z         FileSystem    C:\Windows\System32

    C:\PS> net use
    New connections will be remembered.

    Status     Local     Remote                    Network
    ——————————————————————————-
                 X:        \\Server01\Public         Microsoft Windows Network

    C:\PS> [System.IO.DriveInfo]::getdrives()

    Name             : C:\
    DriveType         : Fixed
    DriveFormat        : NTFS
    IsReady            : True
    AvailableFreeSpace : 39831498752
    TotalFreeSpace     : 39831498752
    TotalSize         : 79900368896
    RootDirectory     : C:\
    VolumeLabel        :
    Name             : D:\
    DriveType         : CDRom
    DriveFormat        :
    IsReady            : False
    AvailableFreeSpace :
    TotalFreeSpace     :
    TotalSize         :
    RootDirectory     : D:\
    VolumeLabel        :
    Name             : X:\
    DriveType         : Network
    DriveFormat        : NTFS
    IsReady            : True
    AvailableFreeSpace : 36340559872
    TotalFreeSpace     : 36340559872
    TotalSize         : 36413280256
    RootDirectory     : X:\
    VolumeLabel        : D_Drive

    C:\PS> Get-WmiObject win32_logicaldisk

    DeviceID     : C:
    DriveType    : 3
    ProviderName :
    FreeSpace    : 39831252992
    Size         : 79900368896
    VolumeName :
    DeviceID     : D:
    DriveType    : 5
    ProviderName :
    FreeSpace    :
    Size         :
    VolumeName :
    DeviceID     : X:
    DriveType    : 4
    ProviderName : \\server01\public
    FreeSpace    : 36340559872
    Size         : 36413280256
    VolumeName : D_Drive

    C:\PS> Get-WmiObject win32_networkconnection
    LocalName                     RemoteName
    ————–             ————
    x:                            \\server01\public

    Description
    ———–
    This example compares the types of file system drives that are displayed by Get-PSDrive to those displayed by using other methods. This example demonstrates different ways to display drives in Windows PowerShell, and it shows that the drives created by using New-PSDrive are accessible only in Windows PowerShell.

    The first command uses Get-PSDrive to get all of the file system drives in the Windows PowerShell console. This includes the fixed drives (C: and D:), the mapped network drive (X:), and two Windows PowerShell drives (Y: and Z:) that were created by using New-PSDrive.

    A “net use” command, which displays Windows mapped network drives, displays only the X drive. It does not display drives that are created by New-PSDrive. It shows that the X: drive is also mapped to \\Server01\Public.

    The third command uses the GetDrives method of the Microsoft .NET Framework System.IO.DriveInfo class. This command gets the Windows file system drives, including drive X:, but it does not get the drives created by New-PSDrive.

    The fourth command uses the Get-WmiObject cmdlet to display the instances of the Win32_LogicalDisk class. It returns the C:, D:, and X: drives, but not the drives created by New-PSDrive.

    The last command uses the Get-WmiObject cmdlet to display the instances of the Win32_NetworkConnection class. Like “net use”, it returns only the X: drive.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113327
    about_providers
    New-PSDrive
    Remove-PSDrive
    Get-Help
    Get-Command
    Get-Member

Get-PfxCertificate

NAME
    Get-PfxCertificate

SYNOPSIS
    Gets information about .pfx Certificate files on the computer.

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

DESCRIPTION
    The Get-PfxCertificate cmdlet gets an object representing each specified .pfx Certificate file. A .pfx file includes both the Certificate and a private key.

PARAMETERS
    -FilePath <string[]>
        The full path to the .pfx file of the secured file. The parameter name (“FilePath”) is optional.

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

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

INPUTS
    System.String
        You can pipe a string that contains a file path to Get-PfxCertificate.

OUTPUTS
    System.Security.Cryptography.X509Certificates
        Get-PfxCertificate returns an object for each Certificate that it gets.

NOTES

        When using the Invoke-Command cmdlet to run a Get-PfxCertificate command remotely, and the .pfx Certificate file is not password protected, the value of the Authentication parameter of Invoke-Command must be “CredSSP”.

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

    C:\PS>Get-PfxCertificate -FilePath C:\windows\system32\Test.pfx

    Password: ******
    Signer Certificate:     Matt Berg (Self Certificate)
    Time Certificate:
    Time Stamp:
    Path:                    C:\windows\system32\zap.pfx

    Description
    ———–
    This command gets information about the Test.pfx Certificate on the system.

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

    C:\PS>Invoke-Command -computername Server01 -scriptblock {Get-PfxCertificate -FilePath C:\Text\TestNoPassword.pfx} -authentication CredSSP

    Description
    ———–
    This command gets a .pfx Certificate file from the Server01 remote computer. It uses the Invoke-Command to run a Get-PfxCertificate command remotely.

    When the .pfx Certificate file is not password-protected, the value of the Authentication parameter of Invoke-Command must be “CredSSP”.

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

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

NAME
    Get-Module

SYNOPSIS
    Gets the modules that have been imported or that can be imported into the current session.

SYNTAX
    Get-Module [-All] [-ListAvailable] [-Name <string[]>] [<CommonParameters>]

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

DESCRIPTION
    The Get-Module cmdlet gets the modules that have been imported, or that can be imported, into the session.

    Get-Module only gets modules; it does not import them. To import the modules into your session, use Import-Module.

PARAMETERS
    -All [<SwitchParameter>]
        Gets module objects for all module files.

        Without the All parameter, Get-Module gets only the module object for the default module file. The cmdlet selects file types in the following order: manifest (.psd1) files, script module (.psm1) files, and binary module (.dll) files.

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

    -ListAvailable [<SwitchParameter>]
        Gets all of the modules that can be imported into the session. Get-Module gets the modules in the paths specified by the $env:PSModulePath Environment Variable.

        Without this parameter, Get-Module gets only the modules that have been imported into the session.

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

    -Name <string[]>
        Gets only modules with the specified names or name patterns. Wildcards are permitted. You can also pipe the names to Get-Module.

        Required?                    false
        Position?                    1
        Default value                All imported or available modules.
        Accept pipeline input?     true (ByValue)
        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.String
        You can pipe module names to Get-Module.

OUTPUTS
    System.Management.Automation.PSModuleInfo
        Get-Module returns objects that represent the modules.

NOTES

        You can also refer to Get-Module by its Alias, “gmo”. For more information, see about_aliases.

        The All parameter returns module objects for all files with a .dll file name extension, even if they do not implement cmdlets or providers.

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

    C:\PS>Get-Module

    Description
    ———–
    This command gets the modules that have been imported into the current session.

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

    C:\PS>Get-Module -listAvailable

    Description
    ———–
    This command gets the modules that can be imported into the current session.

    Get-Module looks for available modules in the path specified by the $env:PSModulePath Environment Variable. For more information about PSModulePath, see about_modules and about_environment_variables.

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

    C:\PS>Get-Module -listAvailable -All

    Description
    ———–
    This command gets all of the exported files for all available modules.

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

    C:\PS>Get-Module | Get-Member -type property

     TypeName: System.Management.Automation.PSModuleInfo

    Name             MemberType Definition
    —-             ———- ———-
    AccessMode        Property System.Management.Automation.ModuleAcc
    Description     Property System.String Description {get;set;}
    ExportedAliases Property System.Collections.Generic.Dictionary`
    ExportedCmdlets Property System.Collections.Generic.Dictionary`
    ExportedFunctions Property System.Collections.Generic.Dictionary`
    ExportedVariables Property System.Collections.Generic.Dictionary`
    Guid             Property System.Guid Guid {get;}
    ModuleBase        Property System.String ModuleBase {get;}
    ModuleType        Property System.Management.Automation.ModuleTyp
    Name             Property System.String Name {get;}
    NestedModules     Property System.Collections.ObjectModel.ReadOnl
    OnRemove         Property System.Management.Automation.ScriptBlo
    Path             Property System.String Path {get;}
    PrivateData     Property System.Object PrivateData {get;set;}
    SessionState     Property System.Management.Automation.SessionSt
    Version         Property System.Version Version {get;}

    Description
    ———–
    This command get the properties of the PSModuleInfo object that Get-Module returns. There is one object for each module file.

    You can use the properties to format and filter the module objects. For more information about the properties, see “PSModule Properties” in the MSDN (Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?LinkId=143624.

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

    C:\PS>Get-Module -listAvailable -All | Format-Table -property name, moduletype, path -groupby name -auto

     Name: MyTestCmdlets

    Name         ModuleType Path
    —-         ———- —-
    MyTestCmdlets     Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules\TestCmdlets\TestCmdlets.dll

     Name: PSDiagnostics

    Name         ModuleType Path
    —-         ———- —-
    PSDiagnostics Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDiagnostics\PSDiagnostics.psd1
    PSDiagnostics     Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDiagnostics\PSDiagnostics.psm1

     Name: FileTransfer

    Name         ModuleType Path
    —-         ———- —-
    FileTransfer Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer\FileTransfer.psd1

    Description
    ———–
    This command gets all module files (imported and available) and groups them by module name. This lets you see the module files that each script is exporting.

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

    C:\PS>$m = Get-Module -list -Name FileTransfer | where {$_.moduletype -eq “Manifest”}

    C:\PS> Get-Content $m.path

    @{
    GUID=”{8FA5064B-8479-4c5c-86EA-0D311FE48875}”
    Author=”Microsoft Corporation”
    CompanyName=”Microsoft Corporation”
    Copyright=”© Microsoft Corporation. All rights reserved.”
    ModuleVersion=”1.0.0.0″
    Description=”Windows Powershell File Transfer Module”
    PowerShellVersion=”2.0″
    CLRVersion=”2.0″
    NestedModules=”Microsoft.BackgroundIntelligentTransfer.Management”
    FormatsToProcess=”FileTransfer.Format.ps1xml”
    RequiredAssemblies=Join-Path $psScriptRoot “Microsoft.BackgroundIntelligentTransfer.Management.Interop.dll”
    }

    Description
    ———–
    These commands display the contents of the module manifest for the Windows PowerShell File Transfer module.

    The first command gets the PSModuleInfo object that represent the module manifest for the File Transfer module. It saves the object in the $m Variable.

    The second command uses dot notation to get the path to the manifest file, which is stored in the Path property of the object. Then, it uses the Get-Content cmdlet to get the content of the manifest file in the specified path.

    Modules are not required to have manifest files. When they do have a manifest file, a manifest is required only to include a version number. However, manifest files often provide useful information about a module, its requirements, and its contents.

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

    C:\PS>Get-Module -listAvailable -Name FileTransfer | Format-List -property *

    Name             : FileTransfer
    Path             : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer\FileTransfer.psd1
    Description     : Powershell File Transfer Module
    Guid             : 8fa5064b-8479-4c5c-86ea-0d311fe48875
    ModuleBase        : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer
    PrivateData     :
    Version         : 1.0.0.0
    ModuleType        : Manifest
    AccessMode        : ReadWrite
    ExportedFunctions : {}
    ExportedCmdlets : {}
    NestedModules     : {}
    ExportedVariables : {}
    ExportedAliases : {}
    SessionState     : System.Management.Automation.SessionState
    OnRemove         :

    Description
    ———–
    This command displays all of the properties of the FileTransfer module in a list.

    Because the module has not yet been imported into the session, the Exported* properties and the NestedModules property are not yet populated. These properties are populated only after the elements have been exported and the nested modules have been instantiated.

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

    C:\PS>dir (Get-Module -listavailable FileTransfer).modulebase

        Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer

    Mode                LastWriteTime     Length Name
    —-                ————-     —— —-
    d—-        12/16/2008 12:36 PM            en-US
    -a—        11/19/2008 11:30 PM     16184 FileTransfer.Format.ps1xml
    -a—        11/20/2008 11:30 PM     1044 FileTransfer.psd1
    -a—        12/16/2008 12:20 AM     108544 Microsoft.BackgroundIntelligentTransfer.Management.Interop.dll

    Description
    ———–
    This command lists the files in the module’s directory. This is another way to determine what is in a module before you import it. Some modules might have help files or ReadMe files that describe the module.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=141552
    Import-Module
    New-Module
    Remove-Module
    about_modules

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