Tag Archives: Name

New-ItemProperty

NAME
    New-ItemProperty

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

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

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

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

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

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

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

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

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

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

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

    -Filter <string>
        Specifies a filter in the provider’s format or language. The value of this parameter qualifies the Path parameter.

        The syntax of the filter, including the use of wildcards, depends on the provider. Filters are more efficient than other parameters, because the provider applies them when retrieving the objects rather than having Windows PowerShell filter the objects after they are retrieved.

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

    -Force [<SwitchParameter>]
        Allows the cmdlet to create a property on an object that cannot otherwise be accessed by the user. Implementation varies from provider to provider. For more information, see about_providers.

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

    -Include <string[]>
        The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as “*.txt”. Wildcards are permitted.

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

    -LiteralPath <string[]>
        Specifies a path to the item property. The value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

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

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

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

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

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

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

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

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

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

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

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

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

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

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

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

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

INPUTS
    None
        You cannot pipe input to New-ItemProperty.

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

NOTES

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Import-Module

NAME
    Import-Module

SYNOPSIS
    Adds modules to the current session.

SYNTAX
    Import-Module [-Name] <string[]> [-Alias <string[]>] [-ArgumentList <Object[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Force] [-Function <string[]>] [-Global] [-PassThru] [-Prefix <string>] [-Variable <string[]>] [-Version <Version>] [<CommonParameters>]

    Import-Module [-Assembly] <Assembly[]> [-Alias <string[]>] [-ArgumentList <Object[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Force] [-Function <string[]>] [-Global] [-PassThru] [-Prefix <string>] [-Variable <string[]>] [-Version <Version>] [<CommonParameters>]

    Import-Module [-ModuleInfo] <PSModuleInfo[]> [-Alias <string[]>] [-ArgumentList <Object[]>] [-AsCustomObject] [-Cmdlet <string[]>] [-Force] [-Function <string[]>] [-Global] [-PassThru] [-Prefix <string>] [-Variable <string[]>] [-Version <Version>] [<CommonParameters>]

DESCRIPTION
    The Import-Module cmdlet adds one or more modules to the current session.

    A module is a package that contains members (such as cmdlets, providers, scripts, Functions, Variables, and other tools and files) that can be used in Windows PowerShell. After a module is imported, you can use the module members in your session.

    To import a module, use the Name, Assembly, or ModuleInfo parameter to identify the module to import. By default, Import-Module imports all members that the module exports, but you can use the Alias, Function, Cmdlet, and Variable parameters to restrict the members that are imported.

    Import-Module imports a module only into the current session. To import the module into all sessions, add an Import-Module command to your Windows PowerShell profile. For more information about profiles, see about_profiles.

    For more information about modules, see about_modules.

PARAMETERS
    -Alias <string[]>
        Imports only the specified Aliases from the module into the current session. Enter a comma-separated list of Aliases. Wildcard characters are permitted.

        Some modules automatically export selected Aliases into your session when you import the module. This parameter lets you select from among the exported Aliases.

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

    -ArgumentList <Object[]>
        Specifies arguments (parameter values) that are passed to a script module during the Import-Module command. This parameter is valid only when you are importing a script module.

        You can also refer to ArgumentList by its Alias, “args”. For more information, see about_aliases.

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

    -AsCustomObject [<SwitchParameter>]
        Returns a custom object with members that represent the imported module members. This parameter is valid only for script modules.

        When you use the AsCustomObject parameter, Import-Module imports the module members into the session and then returns a PSCustomObject object instead of a PSModuleInfo object. You can save the custom object in a Variable and use dot notation to invoke the members.

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

    -Assembly <Assembly[]>
        Imports the cmdlets and providers implemented in the specified assembly objects. Enter a Variable that contains assembly objects or a command that creates assembly objects. You can also pipe an assembly object to Import-Module.

        When you use this parameter, only the cmdlets and providers implemented by the specified assemblies are imported. If the module contains other files, they are not imported, and you might be missing important members of the module. Use this parameter for debugging and testing the module, or when you are instructed to use it by the module author.

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

    -Cmdlet <string[]>
        Imports only the specified cmdlets from the module into the current session. Enter a list of cmdlets. Wildcard characters are permitted.

        Some modules automatically export selected cmdlets into your session when you import the module. This parameter lets you select from among the exported cmdlets.

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

    -Force [<SwitchParameter>]
        Re-imports a module and its members, even if the module or its members have an access mode of read-only.

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

    -Function <string[]>
        Imports only the specified Functions from the module into the current session. Enter a list of Functions. Wildcard characters are permitted.

        Some modules automatically export selected Functions into your session when you import the module. This parameter lets you select from among the exported Functions.

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

    -Global [<SwitchParameter>]
        When used in a script module (.psm1), this parameter imports modules into the global session state.

        This parameter is effective only when it appears in a script module. Otherwise, it is ignored.

        By default, the commands in a script module, including commands from nested modules, are imported into the caller’s session state. To restrict the commands that a module exports, use an Export-ModuleMember command in the script module.

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

    -ModuleInfo <PSModuleInfo[]>
        Specifies module objects to import. Enter a Variable that contains the module objects, or a command that gets the module objects, such as a “Get-Module -listavailable” command. You can also pipe module objects to Import-Module.

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

    -Name <string[]>
        Specifies the names of the modules to import. Enter the name of the module or the name of a file in the module, such as a .psd1, .psm1, .dll, or ps1 file. File paths are optional. Wildcards are not permitted. You can also pipe module names and file names to Import-Module.

        If you omit a path, Import-Module looks for the module in the paths saved in the PSModulePath Environment Variable ($env:PSModulePath).

        Specify only the module name whenever possible. When you specify a file name, only the members that are implemented in that file are imported. If the module contains other files, they are not imported, and you might be missing important members of the module.

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

    -PassThru [<SwitchParameter>]
        Returns objects that represent the modules that were imported. By default, this cmdlet does not generate any output.

        Notes
        — When you pipe the output of a “Get-Module -listavailable” command to an Import-Module command with the PassThru parameter, Import-Module returns the object that Get-Module passed to it without updating the object. As a result, the Exported and NestedModules properties are not yet populated.

        — When you use the Prefix parameter to specify a prefix for the member, the prefix does not appear in the member names in the properties of the module object. The object records what was exported before the prefix was applied.

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

    -Prefix <string>
        Adds the specified prefix to the nouns in the names of imported module members.

        Use this parameter to avoid name conflicts that might occur when different members in the session have the same name. This parameter does not change the module, and it does not affect files that the module imports for its own use (known as “nested modules”). It affects only the names of members in the current session.

        For example, if you specify the prefix “UTC” and then import a Get-Date cmdlet, the cmdlet is known in the session as Get-UTCDate, and it is not confused with the original Get-Date cmdlet.

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

    -Variable <string[]>
        Imports only the specified Variables from the module into the current session. Enter a list of Variables. Wildcard characters are permitted.

        Some modules automatically export selected Variables into your session when you import the module. This parameter lets you select from among the exported Variables.

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

    -Version <Version>
        Specifies the version of the module to import. Use this parameter when you have different versions of the same module on your system.

        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, System.Management.Automation.PSModuleInfo, System.Reflection.Assembly
        You can pipe a module name, module object, or assembly object to Import-Module.

OUTPUTS
    None, System.Management.Automation.PSModuleInfo, or System.Management.Automation.PSCustomObject
        By default, Import-Module does not generate any output. If you use the PassThru parameter, it generates a System.Management.Automation.PSModuleInfo object that represents the module. If you use the AsCustomObject parameter, it generates a PSCustomObject object.

NOTES

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

        Before you can import a module, the module directory must be copied to a directory that is accessible to your local computer. For more information, see about_modules.

        Module members run in their own private module session state, so the commands that they use for internal processing do not affect your session state.

        If you import members with the same name and the same type into your session, Windows PowerShell uses the member imported last by default. Variables and Aliases are replaced, and the originals are not accessible. Functions, cmdlets and providers are merely “shadowed” by the new members, and they can be accessed by qualifying the command name with the name of its snap-in, module, or Function path.

        To update the formatting data for commands that have been imported from a module, use the Update-FormatData cmdlet. Update-FormatData also updates the formatting data for commands in the session that were imported from modules. If the formatting file for a module changes, you can run an Update-FormatData command to update the formatting data for imported commands. You do not need to import the module again.

        To import a module that is created by Import-PSSession or Export-PSSession, the execution policy in the current session cannot be Restricted or AllSigned, because the modules that Import-PSSession and Export-PSSession create contains unsigned script files that are prohibited by these policies. To use Import-Module without changing the execution policy for the local computer, use the Scope parameter of Set-ExecutionPolicy to set a less restrictive execution policy for a single process.

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

    C:\PS>Import-Module -Name BitsTransfer

    Description
    ———–
    This command imports the members of the BitsTransfer module into the current session.

    The Name parameter name (-Name) is optional and can be omitted.

    By default, Import-Module does not generate any output when it imports a module. To request output, use the PassThru or AsCustomObject parameter, or the Verbose common parameter.

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

    C:\PS>Get-Module -listAvailable | Import-Module

    Description
    ———–
    This command imports all available modules in the path specified by the PSModulePath Environment Variable ($env:psmodulepath) into the current session.

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

    C:\PS>$m = Get-Module -ListAvailable BitsTransfer, ServerBackup

    C:\PS> Import-Module -moduleInfo $m

    Description
    ———–
    These commands import the members of the BitsTransfer and ServerBackup modules into the current session.

    The first command uses the Get-Module cmdlet to get PSModuleInfo objects that represent the BitsTransfer and ServerBackup modules. It saves the objects in the $m Variable. The ListAvailable parameter is required when you are getting modules that are not yet imported into the session.

    The second command uses the ModuleInfo parameter of Import-Module to import the modules into the current session.

    These commands are equivalent to using a pipeline operator (|) to send the output of a Get-Module command to Import-Module.

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

    C:\PS>Import-Module -Name c:\ps-test\modules\test -Verbose

    VERBOSE: Loading module from path ‘C:\ps-test\modules\Test\Test.psm1’.
    VERBOSE: Exporting Function ‘my-parm’.
    VERBOSE: Exporting Function ‘get-parm’.
    VERBOSE: Exporting Function ‘get-spec’.
    VERBOSE: Exporting Function ‘get-specDetails’.

    Description
    ———–
    This command uses an explicit path to identify the module to import.

    It also uses the Verbose common parameter to get a list of the items imported from the module. Without the Verbose, PassThru, or AsCustomObject parameter, Import-Module does not generate any output when it imports a module.

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

    C:\PS>Import-Module BitsTransfer -Cmdlet Add-BitsTransferFile, Get-BitsTransfer

    C:\PS> Get-Module BitsTransfer

    Name             : BitsTransfer
    Path             : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\BitsTransfer.psd1
    Description     :
    Guid             : 8fa5064b-8479-4c5c-86ea-0d311fe48875
    Version         : 1.0.0.0
    ModuleBase        : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer
    ModuleType        : Manifest
    PrivateData     :
    AccessMode        : ReadWrite
    ExportedAliases : {}
    ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Complete-BitsTransfer, Complete-BitsTransfer], [Get-BitsTransfer, Get-BitsTransfer], [Rem
                        ove-BitsTransfer, Remove-BitsTransfer]…}
    ExportedFunctions : {}
    ExportedVariables : {}
    NestedModules     : {Microsoft.BackgroundIntelligentTransfer.Management}

    C:\PS> Get-Command -module BitsTransfer

    CommandType Name                Definition
    ———– —-                ———-
    Cmdlet     Add-BitsTransfer    Add-BitsTransfer [-BitsJob] <BitsJob[]> [-Source] <String[]> [[-Destination] <String[]>] [-Verbose] [-Debug] [-ErrorA…
    Cmdlet     Get-BitsTransfer    Get-BitsTransfer [[-Name] <String[]>] [-AllUsers] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-WarningActi…

    Description
    ———–
    This example shows how to restrict the module members that are imported into the session and the effect of this command on the session.

    The first command imports only the Add-BitsTransfer and Get-BitsTransfer cmdlets from the BitsTransfer module. The command uses the Cmdlet parameter to restrict the cmdlets that the module imports. You can also use the Alias, Variable, and Function parameters to restrict other members that a module imports.

    The second command uses the Get-Module cmdlet to get the object that represents the BitsTransfer module. The ExportedCmdlets property lists all of the cmdlets that the module exports, even when they were not all imported.

    The third command uses the Module parameter of the Get-Command cmdlet to get the commands that were imported from the BitsTransfer module. The results confirm that only the Add-BitsTransfer and Get-BitsTransfer cmdlets were imported.

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

    C:\PS>Import-Module BitsTransfer -Prefix PS -PassThru

    Name             : bitstransfer
    Path             : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\bitstransfer\bitstransfer.psd1
    Description     :
    Guid             : 8fa5064b-8479-4c5c-86ea-0d311fe48875
    Version         : 1.0.0.0
    ModuleBase        : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\bitstransfer
    ModuleType        : Manifest
    PrivateData     :
    AccessMode        : ReadWrite
    ExportedAliases : {}
    ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Remove-BitsTransfer, Remove-BitsTransfer], [Complete-BitsTransfer, Complete-BitsTransfer]
                        , [Get-BitsTransfer, Get-BitsTransfer]…}
    ExportedFunctions : {}
    ExportedVariables : {}
    NestedModules     : {Microsoft.BackgroundIntelligentTransfer.Management}

    C:\PS> Get-Command -module bitstransfer

    CommandType     Name                        Definition
    ———–     —-                        ———-
    Cmdlet         Add-PSBitsTransfer         Add-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Source] <String[]> …
    Cmdlet         Complete-PSBitsTransfer     Complete-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Verbose] [-Deb…
    Cmdlet         Get-PSBitsTransfer         Get-PSBitsTransfer [[-Name] <String[]>] [-AllUsers] [-Verbose] …
    Cmdlet         Remove-PSBitsTransfer     Remove-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Verbose] [-Debug
    Cmdlet         Resume-PSBitsTransfer     Resume-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Asynchronous] [-…
    Cmdlet         Set-PSBitsTransfer         Set-PSBitsTransfer [-BitsJob] <BitsJob[]> [-DisplayName <String…
    Cmdlet         Start-PSBitsTransfer        Start-PSBitsTransfer [[-Source] <String[]>] [[-Destination] <St…
    Cmdlet         Suspend-PSBitsTransfer     Suspend-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Verbose] [-Debu…

    Description
    ———–
    These commands import the BitsTransfer module into the current session, add a prefix to the member names, and then display the prefixed member names.

    The first command uses the Import-Module cmdlet to import the BitsTransfer module. It uses the Prefix parameter to add the PS prefix to all members that are imported from the module and the PassThru parameter to return a module object that represents the imported module.

    The module object that the command returns has an ExportedCmdlets property that lists the exported members. The prefix does not appear in the cmdlet names, because it is applied after the members are exported (but before they are imported).

    The second command uses the Get-Command cmdlet to get the members that have been imported from the module. It uses the Module parameter to specify the module. The output shows that the module members were correctly prefixed.

    The prefix that you use applies only to the members in the current session. It does not change the module.

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

    C:\PS>Get-Module -list | Format-Table -property name, moduletype -auto

    Name         ModuleType
    —-         ———-
    Show-Calendar     Script
    BitsTransfer    Manifest
    PSDiagnostics Manifest
    TestCmdlets     Script

    C:\PS> $a = Import-Module -Name Show-Calendar -AsCustomObject

    C:\PS> $a | Get-Member

     TypeName: System.Management.Automation.PSCustomObject

    Name         MemberType Definition
    —-         ———- ———-
    Equals        Method     bool Equals(System.Object obj)
    GetHashCode Method     int GetHashCode()
    GetType     Method     type GetType()
    ToString     Method     string ToString()
    Show-Calendar ScriptMethod System.Object Show-Calendar();

    C:\PS> $a.”show-calendar”()

    Description
    ———–
    These commands demonstrate how to get and use the custom object that Import-Module returns.

    Custom objects include synthetic members that represent each of the imported module members. For example, the cmdlets and Functions in a module are converted to script methods of the custom object.

    Custom objects are very useful in scripting. They are also useful when several imported objects have the same names. Using the script method of an object is equivalent to specifying the fully qualified name of an imported member, including its module name.

    The AsCustomObject parameter can be used only with a script module, so the first task is to determine which of the available modules is a script module.

    The first command uses the Get-Module cmdlet to get the available modules. The command uses a pipeline operator (|) to pass the module objects to the Format-Table cmdlet, which lists the Name and ModuleType of each module in a table.

    The second command uses the Import-Module cmdlet to import the Show-Calendar script module. The command uses the AsCustomObject parameter to request a custom object. The command saves the resulting custom object in the $a Variable.

    The third command uses a pipeline operator to send the $a Variable to the Get-Member cmdlet, which gets the properties and methods of the PSCustomObject in $a. The output shows a Show-Calendar script method.

    The last command uses the Show-Calendar script method. The method name must be enclosed in quotation marks, because it includes a hyphen.

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

    C:\PS>Import-Module BitsTransfer

    C:\PS> Import-Module BitsTransfer -Force -Prefix PS

    Description
    ———–
    This example shows how to use the Force parameter of Import-Module when you are re-importing a module into the same session.

    The first command imports the BitsTransfer module. The second command imports the module again, this time using the Prefix parameter.

    The second command also includes the Force parameter, which removes the module and then imports it again. Without this parameter, the session would include two copies of each BitsTransfer cmdlet, one with the standard name and one with the prefixed name.

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

    C:\PS>Get-Date

    Saturday, September 12, 2009 6:47:04 PM

    C:\PS> Import-Module TestModule

    C:\PS> Get-Date
    09255

    C:\PS> Get-Command Get-Date | Format-Table -property commandtype, name, pssnapin, module -auto

    CommandType Name     pssnapin                     Module
    ———– —-     ——–                     ——
     Function Get-Date                                 TestModule
         Cmdlet Get-Date Microsoft.PowerShell.Utility

    C:\PS> Microsoft.PowerShell.Utility\Get-Date

    Saturday, September 12, 2009 6:33:23 PM

    Description
    ———–
    This example shows how to run commands that have been hidden by imported commands.

    The first command run the Get-Date cmdlet that comes with Windows PowerShell. It returns a DateTime object with the current date.

    The second command imports the TestModule module. This module includes a Function named Get-Date that returns the Julian date.

    The third command runs the Get-Date command again. Because Functions take precedence over cmdlets, the Get-Date Function from the TestModule module ran, instead of the Get-Date cmdlet.

    The fourth command shows that there are two Get-Date commands in the session, a Function from the TestModule module and a cmdlet from the Microsoft.PowerShell.Utility snap-in.

    The fifth command runs the hidden cmdlet by qualifying the command name with the snap-in name.

    For more information about command precedence in Windows PowerShell, see about_command_precedence.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=141553
    Get-Module
    New-Module
    Remove-Module
    Export-ModuleMember
    about_modules

Get-Variable

NAME
    Get-Variable

SYNOPSIS
    Gets the Variables in the current console.

SYNTAX
    Get-Variable [[-Name] <string[]>] [-Exclude <string[]>] [-Include <string[]>] [-Scope <string>] [-ValueOnly] [<CommonParameters>]

DESCRIPTION
    The Get-Variable cmdlet gets the Windows PowerShell Variables in the current console. You can retrieve just the values of the Variables by specifying the ValueOnly parameter, and you can filter the Variables returned by name.

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

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

    -Include <string[]>
        Specifies only the items upon which the cmdlet will act, excluding all others. Wildcards are permitted.

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

    -Name <string[]>
        Specifies the name of the Variable.

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

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

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

    -ValueOnly [<SwitchParameter>]
        Gets only the value of the Variable.

        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 the Variable name to Get-Variable.

OUTPUTS
    Variable object
        Get-Variable returns a System.Management.Automation Variable object for each Variable that it gets. The object type depends on the Variable.

NOTES

        This cmdlet does not manage Environment Variables. To manage Environment Variables, you can use the Environment Variable provider.

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

    C:\PS>Get-Variable m*

    Description
    ———–
    This command displays Variables with names that begin with the letter “m”. The value of the Variables is also displayed.

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

    C:\PS>Get-Variable m* -ValueOnly

    Description
    ———–
    This command displays only the values of the Variables with names that begin with the letter “m”.

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

    C:\PS>Get-Variable -Include M*,P* | Sort-Object name

    Description
    ———–
    This command gets information about the Variables that begin with either the letter “M” or the letter “P”. The results are piped to the Sort-Object cmdlet, sorted by name, and displayed.

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

    C:\PS>Get-Variable -Scope 0

    C:\PS> Compare-Object (Get-Variable -Scope 0) (Get-Variable -Scope 1)

    Description
    ———–
    The first command gets only the Variables that are defined in the local scope. It is equivalent to “Get-Variable -Scope local” and can be abbreviated as “gv -s 0”.

    The second command uses the Compare-Object cmdlet to find the Variables that are defined in the parent scope (Scope 1) but are visible only in the local scope (Scope 0).

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

Get-Service

NAME
    Get-Service

SYNOPSIS
    Gets the services on a local or remote computer.

SYNTAX
    Get-Service [[-Name] <string[]>] [-ComputerName <string[]>] [-DependentServices] [-Exclude <string[]>] [-Include <string[]>] [-RequiredServices] [<CommonParameters>]

    Get-Service -DisplayName <string[]> [-ComputerName <string[]>] [-DependentServices] [-Exclude <string[]>] [-Include <string[]>] [-RequiredServices] [<CommonParameters>]

    Get-Service [-InputObject <ServiceController[]>] [-ComputerName <string[]>] [-DependentServices] [-Exclude <string[]>] [-Include <string[]>] [-RequiredServices] [<CommonParameters>]

DESCRIPTION
    The Get-Service cmdlet gets objects that represent the services on a local computer or on a remote computer, including running and stopped services.

    You can direct Get-Service to get only particular services by specifying the service name or display name of the services, or you can pipe service objects to Get-Service.

PARAMETERS
    -ComputerName <string[]>
        Gets the services 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 a remote computer. 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-Service even if your computer is not configured to run remote commands.

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

    -DependentServices [<SwitchParameter>]
        Gets only the services that depend upon the specified service.

        By default, Get-Service gets all services.

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

    -DisplayName <string[]>
        Specifies the display names of services to be retrieved. Wildcards are permitted. By default, Get-Service gets all services on the computer.

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

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

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

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

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

    -InputObject <ServiceController[]>
        Specifies ServiceController objects representing the services to be retrieved. Enter a Variable that contains the objects, or type a command or expression that gets the objects. You can also pipe a service object to Get-Service.

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

    -Name <string[]>
        Specifies the service names of services to be retrieved. Wildcards are permitted. By default, Get-Service gets all of the services on the computer.

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

    -RequiredServices [<SwitchParameter>]
        Gets only the services that this service requires.

        This parameter gets the value of the ServicesDependedOn property of the service. By default, Get-Service gets all services.

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

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

INPUTS
    System.ServiceProcess.ServiceController, System.String
        You can pipe a service object or a service name to Get-Service.

OUTPUTS
    System.ServiceProcess.ServiceController
        Get-Service returns objects that represent the services on the computer.

NOTES

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

        Get-Service can display services only when the current user has permission to see them. If Get-Service does not display services, you might not have permission to see them.

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

        When you sort in ascending order by status value, “Stopped” services appear before “Running” services. The Status property of a service is an enumerated value in which the names of the statuses represent integer values. The sort is based on the integer value, not the name. “Running” appears before “Stopped” because “Stopped” has a value of “1”, and “Running” has a value of “4”.

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

    C:\PS>Get-Service

    Description
    ———–
    This command retrieves all of the services on the system. It behaves as though you typed “Get-Service *”. The default display shows the status, service name, and display name of each service.

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

    C:\PS>Get-Service wmi*

    Description
    ———–
    This command retrieves services with service names that begin with “WMI” (the acronym for Windows Management Instrumentation).

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

    C:\PS>Get-Service -displayname *network*

    Description
    ———–
    This command displays services with a display name that includes the word
    “network”. Searching the display name finds network-related services even when the service name does not include “Net”, such as xmlprov, the Network Provisioning Service.

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

    C:\PS>Get-Service -Name win* -Exclude winrm

    Description
    ———–
    These commands get only the services with service names that begin with “win”, except for the WinRM service.

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

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

    Description
    ———–
    This command displays only the services that are currently running. It uses the Get-Service cmdlet to get all of the services on the computer. The pipeline operator (|) passes the results to the Where-Object cmdlet, which selects only the services with a Status property that equals “Running”.

    Status is only one property of service objects. To see all of the properties, type “Get-Service | Get-Member“.

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

    C:\PS>Get-Service -ComputerName Server02

    Description
    ———–
    This command gets the services on the Server02 remote computer.

    Because the ComputerName parameter of Get-Service does not use Windows PowerShell remoting, you can use this parameter even if the computer is not configured for remoting in Windows PowerShell.

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

    C:\PS>Get-Service | Where-Object {$_.DependentServices} | Format-List -property Name, DependentServices, @{Label=”NoOfDependentS
    ervices”; Expression={$_.dependentservices.count}}

    Name                 : AudioEndpointBuilder
    DependentServices     : {AudioSrv}
    NoOfDependentServices : 1

    Name                 : Dhcp
    DependentServices     : {WinHttpAutoProxySvc}
    NoOfDependentServices : 1
    …

    Description
    ———–
    These commands list the services on the computer that have dependent services.

    The first command uses the Get-Service cmdlet to get the services on the computer. A pipeline operator (|) sends the services to the Where-Object cmdlet, which selects the services whose DependentServices property is not null.

    Another pipeline operator sends the results to the Format-List cmdlet. The command uses its Property parameter to display the name of the service, the name of the dependent services, and a calculated property that displays the number of dependent services that each service has.

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

    C:\PS>C:\PS> Get-Service s* | Sort-Object status

    Status Name             DisplayName
    —— —-             ———–
    Stopped stisvc             Windows Image Acquisition (WIA)
    Stopped SwPrv             MS Software Shadow Copy Provider
    Stopped SysmonLog         Performance Logs and Alerts
    Running Spooler            Print Spooler
    Running srservice         System Restore Service
    Running SSDPSRV            SSDP Discovery Service
    Running ShellHWDetection Shell Hardware Detection
    Running Schedule         Task Scheduler
    Running SCardSvr         Smart Card
    Running SamSs             Security Accounts Manager
    Running SharedAccess     Windows Firewall/Internet Connectio…
    Running SENS             System Event Notification
    Running seclogon         Secondary Logon

    C:\PS> Get-Service s* | Sort-Object status -descending

    Status Name             DisplayName
    —— —-             ———–
    Running ShellHWDetection Shell Hardware Detection
    Running SharedAccess     Windows Firewall/Internet Connectio…
    Running Spooler            Print Spooler
    Running SSDPSRV            SSDP Discovery Service
    Running srservice         System Restore Service
    Running SCardSvr         Smart Card
    Running SamSs             Security Accounts Manager
    Running Schedule         Task Scheduler
    Running SENS             System Event Notification
    Running seclogon         Secondary Logon
    Stopped SysmonLog         Performance Logs and Alerts
    Stopped SwPrv             MS Software Shadow Copy Provider
    Stopped stisvc             Windows Image Acquisition (WIA)

    Description
    ———–
    This command shows that when you sort services in ascending order by the value of their Status property, stopped services appear before running services. This happens because the value of Status is an enumeration, in which “Stopped” has a value of “1”, and “Running” has a value of 4.

    To list running services first, use the Descending parameter of the Sort-Object cmdlet.

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

    C:\PS>Get-Service -Name winrm -ComputerName localhost, Server01, Server02 | Format-Table -property MachineName, Status, Name, DisplayName -auto

    MachineName    Status Name DisplayName
    ———— —— —- ———–
    localhost     Running WinRM Windows Remote Management (WS-Management)
    Server01     Running WinRM Windows Remote Management (WS-Management)
    Server02     Running WinRM Windows Remote Management (WS-Management)

    Description
    ———–
    This command uses the Get-Service cmdlet to run a “Get-Service Winrm” command on two remote computers and the local computer (“localhost”).

    The Get-Service command runs on the remote computers, and the results are returned to the local computer. A pipeline operator (|) sends the results to the Format-Table cmdlet, which formats the services as a table. The Format-Table command uses the Property parameter to specify the properties displayed in the table, including the MachineName property.

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

    C:\PS>Get-Service winrm -RequiredServices

    Description
    ———–
    This command gets the services that the WinRM service requires.

    The command returns the value of the ServicesDependedOn property of the service.

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

    C:\PS>”winrm” | Get-Service

    Description
    ———–
    This command gets the WinRM service on the local computer. This example shows that you can pipe a service name string (enclosed in quotation marks) to Get-Service.

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

Get-TraceSource

NAME
    Get-TraceSource

SYNOPSIS
    Gets the Windows PowerShell components that are instrumented for tracing.

SYNTAX
    Get-TraceSource [[-Name] <string[]>] [<CommonParameters>]

DESCRIPTION
    The Get-TraceSource cmdlet gets the trace sources for Windows PowerShell components that are currently in use. You can use the data to determine which Windows PowerShell components you can trace. When tracing, the component generates detailed messages about each step in its internal processing. Developers use the trace data to monitor data flow, program execution, and errors. The tracing cmdlets were designed for Windows PowerShell developers, but they are available to all users.

PARAMETERS
    -Name <string[]>
        Gets only the specified trace sources. Wildcards are permitted. The parameter name (“Name”) is optional.

        Required?                    false
        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 the name of a trace source to Get-TraceSource.

OUTPUTS
    System.Management.Automation.PSTraceSource
        Get-TraceSource returns objects that represent the trace sources.

NOTES

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

    C:\PS>Get-TraceSource *provider*

    Description
    ———–
    This command gets all of the trace sources that have names that include “provider”.

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

    C:\PS>Get-TraceSource

    Description
    ———–
    This command gets all of the Windows PowerShell components that can be traced.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113333
    Set-TraceSource
    Trace-Command

Get-PSSessionConfiguration

NAME
    Get-PSSessionConfiguration

SYNOPSIS
    Gets the registered session configurations on the computer.

SYNTAX
    Get-PSSessionConfiguration [[-Name] <string[]>] [<CommonParameters>]

DESCRIPTION
    The Get-PSSessionConfiguration cmdlet gets the session configurations that have been registered on the local computer. This is an advanced cmdlet that is designed to be used by system administrators to manage customized session configurations for their users.

    To create and register a session configuration, use the Register-PSSessionConfiguration cmdlet.

PARAMETERS
    -Name <string[]>
        Gets only the session configurations with the specified name or name pattern. Enter one or more session configuration names. Wildcards are permitted.

        Required?                    false
        Position?                    1
        Default value                All session configurations on the local computer
        Accept pipeline input?     false
        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
    Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration

NOTES

        To run this cmdlet on Windows Vista, Windows Server 2008, and later versions of Windows, you must open Windows PowerShell with the “Run as administrator” option.

        To view the session configurations on the computer, you must be a member of the Administrators group on the computer.

        To run a Get-PSSessionConfiguration command on a remote computer, Credential Security Service Provider (CredSSP) authentication must be enabled in the client settings on the local computer (by using the Enable-WSManCredSSP cmdlet) and in the service settings on the remote computer, and you must use the CredSSP value of the Authentication parameter when establishing the remote session. Otherwise, access is denied.

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

    C:\PS>Get-PSSessionConfiguration

    Description
    ———–
    This command gets the session configurations on the computer.

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

    C:\PS>Get-PSSessionConfiguration -Name Microsoft*

    Name                     PSVersion StartupScript        Permission
    —-                     ——— ————-        ———-
    microsoft.powershell     2.0                             BUILTIN\Administrators AccessAll…
    microsoft.powershell32    2.0                             BUILTIN\Administrators AccessAll…

    Description
    ———–
    This command uses the Name parameter of Get-PSSessionConfiguration to get only the session configurations with names that begin with “Microsoft”.

    This command gets the two default session configurations that come with Windows PowerShell.

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

    C:\PS>Get-PSSessionConfiguration -Name microsoft.powershell | Get-Member

     TypeName: Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration

    Name                 MemberType     Definition
    —-                 ———-     ———-
    Equals                 Method         bool Equals(System.Object obj)
    GetHashCode            Method         int GetHashCode()
    GetType                Method         type GetType()
    ToString             Method         string ToString()
    Capability             NoteProperty System.Object[] Capability=System.Object[]
    ExactMatch             NoteProperty System.String ExactMatch=False
    Filename             NoteProperty System.String Filename=%windir%\system32\pwrshplugin.dll
    lang                 NoteProperty System.String lang=en-US
    Name                 NoteProperty System.String Name=microsoft.powershell
    PSVersion             NoteProperty System.String PSVersion=2.0
    ResourceUri            NoteProperty System.String ResourceUri=http://schemas.microsoft.com/powershell/microsoft.powershell
    SDKVersion             NoteProperty System.String SDKVersion=1
    SecurityDescriptorSddl NoteProperty System.String SecurityDescriptorSddl=O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
    SupportsOptions        NoteProperty System.String SupportsOptions=true
    Uri                    NoteProperty System.String Uri=http://schemas.microsoft.com/powershell/microsoft.powershell
    xmlns                 NoteProperty System.String xmlns=http://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
    XmlRenderingType     NoteProperty System.String XmlRenderingType=text
    Permission             ScriptProperty System.Object Permission {get=trap { continue; }…

    C:\PS> Get-PSSessionConfiguration -Name microsoft.powershell | Format-List -property *

    Name                 : microsoft.powershell
    Filename             : %windir%\system32\pwrshplugin.dll
    SDKVersion             : 1
    XmlRenderingType     : text
    lang                 : en-US
    PSVersion             : 2.0
    ResourceUri            : http://schemas.microsoft.com/powershell/microsoft.powershell
    SupportsOptions        : true
    Capability             : {Shell}
    Uri                    : http://schemas.microsoft.com/powershell/microsoft.powershell
    SecurityDescriptorSddl : O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
    ExactMatch             : False
    xmlns                 : http://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
    Permission             : BUILTIN\Administrators AccessAllowed

    Description
    ———–
    These commands examine the PSSessionConfiguration object that Get-PSSessionConfiguration returns.

    The first command uses the Get-PSSessionConfiguration cmdlet to get the Microsoft.PowerShell default configuration.

    The second command uses a pipeline operator (|) to send the object that Get-PSSessionConfiguration returns to the Get-Member cmdlet. The output shows the properties and methods of the object.

    The third command sends the same object to the Format-List cmdlet. The Property parameter with a value of * (all) directs Format-List to display all of the properties and property values of the object in a list.

    The output of this command has very useful information, including the location of the .dll that implements the configuration type, the resource Uniform Resource Identifier (URI) for the endpoint that is created, and the Security Descriptor Definition Language (SDDL) for the configuration.

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

    C:\PS>dir WSMan:\localhost\plugin

     WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin

    Name                     Type                 Keys
    —-                     —-                 —-
    Event Forwarding Plugin Container            {Name=Event Forwarding Plugin}
    MaintenanceShell         Container            {Name=MaintenanceShell}
    microsoft.powershell     Container            {Name=microsoft.powershell}
    microsoft.powershell32    Container            {Name=microsoft.powershell32}
    WMI Provider             Container            {Name=WMI Provider}

    Description
    ———–
    This command uses the Get-ChildItem cmdlet (alias = dir) in the WSMan: provider drive to look at the content of the Plugin node.

    This is another way to look at the session configurations on the computer.

    The PlugIn node contains ContainerElement objects (Microsoft.WSMan.Management.WSManConfigContainerElement) that represent the registered Windows PowerShell session configurations, along with other plug-ins for WS-Management.

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

    C:\PS>Enable-WSManCredSSP -delegate server02

    C:\PS> Connect-WSMan server02

    C:\PS> Set-Item WSMan:\server02*\service\auth\credSSP -value $true

    C:\PS> Invoke-Command -scriptblock {Get-PSSessionConfiguration} -computername Server02 -authentication CredSSP -credential Domain01\Admin01

    Name                     PSVersion StartupScript        Permission                         PSComputerName
    —-                     ——— ————-        ———-                         ————–
    microsoft.powershell     2.0                             BUILTIN\Administrators AccessAll… server02.corp.fabrikam.com
    microsoft.powershell32    2.0                             BUILTIN\Administrators AccessAll… server02.corp.fabrikam.com
    MyX86Shell                2.0        c:\test\x86Shell.ps1 BUILTIN\Administrators AccessAll… server02.corp.fabrikam.com

    Description
    ———–
    This example shows how to run a Get-PSSessionConfiguration command on a remote computer. The command requires that CredSSP delegation be enabled in the client settings on the local computer and in the service settings on the remote computer. To run the commands in this example, you must be a member of the Administrators group on the local computer and the remote computer.

    The first command uses the Enable-WSManCredSSP cmdlet to enable CredSSP delegation from the Server01 local computer to the Server02 remote computer. This configures the CredSSP client setting on the local computer.

    The second command uses the Connect-WSMan cmdlet to connect to the Server02 computer. This action adds a node for the Server02 computer to the WSMan: drive on the local computer, allowing you to view and change the WS-Management settings on the Server02 computer.

    The third command uses the Set-Item cmdlet to change the value of the CredSSP item in the Service node of the Server02 computer to True. This configures the service settings on the remote computer.

    The fourth command uses the Invoke-Command cmdlet to run a Get-PSSessionConfiguration command on the Server02 computer. The command uses the Credential parameter, and it uses the Authentication parameter with a value of CredSSP.

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

    C:\PS>(Get-PSSessionConfiguration -Name CustomShell).resourceURI

    http://schemas.microsoft.com/powershell/microsoft.CustomShell

    Description
    ———–
    This command uses the Get-PSSessionConfiguration cmdlet to get the resource URI of a session configuration.

    This command is useful when setting the value of the $PSSessionConfigurationName preference Variable, which takes a resource URI.

    The $PSSessionConfiguationName Variable specifies the default configuration that is used when you create a session. This Variable is set on the local computer, but it specifies a configuration on the remote computer. For more information about the $PSSessionConfiguration Variable, see about_preference_variables.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=144304
    about_Session_Configurations
    Disable-PSSessionConfiguration
    Enable-PSSessionConfiguration
    Register-PSSessionConfiguration
    Set-PSSessionConfiguration
    Unregister-PSSessionConfiguration
    WS-Management Provider

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