All posts by Adam

Get-ItemProperty

NAME
    Get-ItemProperty

SYNOPSIS
    Gets the properties of a specified item.

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

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

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

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

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

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

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

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

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

    -Filter <string>
        Specifies a filter in the provider’s format or language. The value of this parameter qualifies the Path parameter. The syntax of the filter, including the use of wildcards, depends on the provider. Filters are more efficient than other parameters, because the provider applies them when retrieving the objects rather than having Windows PowerShell filter the objects after they are retrieved.

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

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

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

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

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

    -Name <string[]>
        Specifies the name of the property or properties to retrieve.

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

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

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

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

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

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

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

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

NOTES

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Get-Item

NAME
    Get-Item

SYNOPSIS
    Gets the item at the specified location.

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

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

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

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

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

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

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

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

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

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

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

    -Filter <string>
        Specifies a filter in the provider’s format or language. The value of this parameter qualifies the Path parameter. The syntax of the filter, including the use of wildcards, depends on the provider. Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having Windows PowerShell filter the objects after they are retrieved.

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

    -Force [<SwitchParameter>]
        Allows the cmdlet to get items that cannot otherwise be accessed, such as hidden items. Implementation varies from provider to provider. For more information, see about_providers. Even using the Force parameter, the cmdlet cannot override security restrictions.

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

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

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

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

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

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

    -Path <string[]>
        Specifies the path to an item. Get-Item gets the item at the specified location. Wildcards are permitted. This parameter is required, but the parameter name (“Path”) is optional.

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

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

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

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

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

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

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

NOTES

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

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

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

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

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

    C:\PS>Get-Item .

    Directory: C:\

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

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

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

    C:\PS>Get-Item *

    Directory: C:\ps-test

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

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

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

    C:\PS>Get-Item C:\

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Get-HotFix

NAME
    Get-HotFix

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

INPUTS
    None
        You cannot pipe input to Get-HotFix.

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

NOTES

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

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

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

    C:\PS>Get-HotFix

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Get-Host

NAME
    Get-Host

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

SYNTAX
    Get-Host [<CommonParameters>]

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

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

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

INPUTS
    None
        You cannot pipe input to this cmdlet.

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

NOTES

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

        For more information, see about_Automatic_Variables.

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

    C:\PS>Get-Host

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

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

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

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

    C:\PS>$h = Get-Host

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

    C:\PS> $win.height = 10

    C:\PS> $win.width = 10

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    C:\PS> cls

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

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

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

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

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

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

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

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

Get-History

NAME
    Get-History

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

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

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

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

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

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

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

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

INPUTS
    Int64
        You can pipe a history ID to Get-History.

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

NOTES

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

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

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

    C:\PS>Get-History

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

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

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

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

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

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

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

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

    C:\PS>Get-History -Count 1

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

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

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

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

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

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

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

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

Get-Help

NAME
    Get-Help

SYNOPSIS
    Displays information about Windows PowerShell commands and concepts.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

INPUTS
    None
        You cannot pipe objects to this cmdlet.

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

NOTES

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

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

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

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

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

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

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

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

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

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

    C:\PS>Get-Help

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

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

    C:\PS>Get-Help *

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

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

    C:\PS>Get-Help Get-Alias

    C:\PS>help Get-Alias

    C:\PS>Get-Alias -?

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

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

    C:\PS>Get-Help about_*

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

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

    C:\PS>Get-Help ls -detailed

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    C:\PS>Get-Help remoting

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

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

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

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

    NAME
        Get-Item

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

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

    NAME
        Get-Item

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

    C:\PS> Get-Item

    NAME
        Get-Item

    SYNOPSIS
        Gets the item at the specified location.

    …

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

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

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

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

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

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

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

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

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

    about_Comment_Based_Help
    Get-Command
    Get-PSDrive
    Get-Member

Get-FormatData

NAME
    Get-FormatData

SYNOPSIS
    Gets the formatting data in the current session.

SYNTAX
    Get-FormatData [[-TypeName] <string[]>] [<CommonParameters>]

DESCRIPTION
    The Get-FormatData cmdlet gets the formatting data in the current session.

    The formatting data in the session includes formatting data from Format.ps1xml formatting files (such as those in the $pshome directory), formatting data for modules that you import into the session, and formatting data for commands that you import into your session by using the Import-PSSession cmdlet.

    You can use this cmdlet to examine the formatting data. Then, you can use the Export-FormatData cmdlet to serialize the objects (convert them to XML) and save them in Format.ps1xml files.

    For more information about formatting files in Windows PowerShell, see about_Format.ps1xml.

PARAMETERS
    -TypeName <string[]>
        Gets only the formatting data with the specified type names. Enter the type names. Wildcards are permitted.

        Required?                    false
        Position?                    1
        Default value
        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
    System.Management.Automation.ExtendedTypeDefinition

NOTES

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

    C:\PS>Get-FormatData

    Description
    ———–
    This command gets all the formatting data in the session.

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

    C:\PS>Get-FormatData -TypeName Microsoft.Wsman*

    Description
    ———–
    This command gets the formatting data items whose names begin with “Microsoft.Wsman”.

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

    C:\PS>$f = Get-FormatData -TypeName helpinfoshort

    C:\PS> $f

    TypeName        FormatViewDefinition
    ——–        ——————–
    HelpInfoShort {help , TableControl}

    C:\PS> $f.FormatViewDefinition[0].control

    Headers                                                                    Rows
    ——-                                                                    —-
    {System.Management.Automation.TableControlColumnHeader, System.Manageme… {System.Management.Automation.TableControlRow}

    C:\PS> $f.FormatViewDefinition[0].control.headers

    Label         Alignment     Width
    —–         ———     —–
    Name         Left         33
    Category     Left         9
                 Undefined     0

    Description
    ———–
    This example shows how to get a formatting data object and examine its properties.

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

    C:\PS>$a = Get-FormatData

    C:\PS> Import-Module bitstransfer
    C:\PS> $b = Get-FormatData
    C:\PS> Compare-Object $a $b

    InputObject                                                SideIndicator
    ———–                                                ————-
    Microsoft.BackgroundIntelligentTransfer.Management.BitsJob =>

    C:\PS> Get-FormatData *bits* | Export-FormatData -filepath c:\test\bits.format.ps1xml

    C:\PS> Get-Content c:\test\bits.format.ps1xml

    <?xml version=”1.0″ encoding=”utf-8″?><Configuration><ViewDefinitions>
    <View><Name>Microsoft.BackgroundIntelligentTransfer.Management.BitsJob</Name>
    …

    Description
    ———–
    This example shows how to use Get-FormatData and Export-FormatData to export the formatting data that is added by a module.

    The first four commands use the Get-FormatData, Import-Module, and Compare-Object cmdlets to identify the format type that the BitsTransfer module adds to the session.

    The fifth command uses the Get-FormatData cmdlet to get the format type that the BitsTransfer module adds. It uses a pipeline operator (|) to send the format type object to the Export-FormatData cmdlet, which converts it back to XML and saves it in the specified format.ps1xml file.

    The final command shows an excerpt of the format.ps1xml file content.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=144303
    Export-FormatData
    Update-FormatData

Get-ExecutionPolicy

NAME
    Get-ExecutionPolicy

SYNOPSIS
    Gets the execution policies for the current session.

SYNTAX
    Get-ExecutionPolicy [[-Scope] {Process | CurrentUser | LocalMachine | UserPolicy | MachinePolicy}] [-List] [<CommonParameters>]

DESCRIPTION
    The Get-ExecutionPolicy cmdlet gets the execution policies for the current session.

    The execution policy is determined by execution policies that you set by using Set-ExecutionPolicy and the Group Policy settings for the Windows PowerShell execution policy. The default value is “Restricted.”

    Without parameters, Get-ExecutionPolicy gets the execution policy that is effective in the session. You can use the List parameter to get all execution policies that affect the session or the Scope parameter to get the execution policy for a particular scope.

    For more information, see about_execution_policies.

PARAMETERS
    -List [<SwitchParameter>]
        Gets all execution policy values for the session listed in precedence order. By default, Get-ExecutionPolicy gets only the effective execution policy.

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

    -Scope <ExecutionPolicyScope>
        Gets the execution policy in the specified scope. By default, Get-ExecutionPolicy gets the effective execution policy for the current session.

        Valid values are:

        — MachinePolicy: The execution policy set by a Group Policy for all users of the computer.
        — UserPolicy: The execution policy set by a Group Policy for the current user of the computer.
        — Process: The execution policy that is set for the current Windows PowerShell process.
        — CurrentUser: The execution policy that is set for the current user.
        — LocalMachine: The execution policy that is set for all users of the computer.

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

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

INPUTS
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    Microsoft.PowerShell.ExecutionPolicy
        Get-ExecutionPolicy returns an object for each execution policy that it gets.

NOTES

        You cannot use Get-ExecutionPolicy to get particular execution policies set for a particular scope or to get the execution policy set by a Group Policy. Get-ExecutionPolicy only gets the effective execution policy that results from applying all precedence rules.

        The execution policy is part of the security strategy of Windows PowerShell. It determines whether you can load configuration files (including your Windows PowerShell profile) and run scripts, and it determines which scripts, if any, must be digitally signed before they will run.

        The effective execution policy is determined by the policies that you set by using Set-ExecutionPolicy and the “Turn on Script Execution” group policies for computers and users. The precedence order is Computer Group Policy > User Group Policy > Process (session) execution policy > User execution policy > Computer execution policy.

        For more information about Windows PowerShell execution policy, including definitions of the Windows PowerShell policies, see about_execution_policies.

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

    C:\PS>Get-ExecutionPolicy

    Restricted

    Description
    ———–
    This command gets the current execution policy for the shell.

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

    C:\PS>Set-ExecutionPolicy RemoteSigned; Get-ExecutionPolicy

    RemoteSigned

    Description
    ———–
    These commands set a new user preference for the shell execution policy and then display the effective execution policy. The commands are separated by a semicolon (;). In this example, because there is no Group Policy setting, the user preference is the effective policy for the shell.

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

    C:\PS>Get-ExecutionPolicy -List

            Scope ExecutionPolicy
            —– —————
    MachinePolicy Undefined
     UserPolicy Undefined
         Process Undefined
     CurrentUser AllSigned
     LocalMachine RemoteSigned

    C:\PS> Get-ExecutionPolicy
    AllSigned

    Description
    ———–
    These commands get all execution policies in the current session and the effective execution policy.

    The first command gets all execution policies that affect the current session. The policies are listed in precedence order.

    The second command gets only the effective execution policy, which is the one set in the CurrentUser scope.

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

Get-EventSubscriber

NAME
    Get-EventSubscriber

SYNOPSIS
    Gets the event subscribers in the current session.

SYNTAX
    Get-EventSubscriber [-SubscriptionId] <int> [[-Force]] [<CommonParameters>]

    Get-EventSubscriber [[-SourceIdentifier] <string>] [[-Force]] [<CommonParameters>]

DESCRIPTION
    The Get-EventSubscriber cmdlet gets the event subscribers in the current session.

    When you subscribe to an event by using a Register event cmdlet, an event subscriber is added to your Windows PowerShell session, and the events to which you subscribed are added to your event queue whenever they are raised. To cancel an event subscription, delete the event subscriber by using the Unregister-Event cmdlet.

PARAMETERS
    -Force [<SwitchParameter>]
        Gets all event subscribers, including subscribers for events that are hidden by using the SupportEvent parameter of Register-ObjectEvent, Register-WmiEvent, and Register-EngineEvent.

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

    -SourceIdentifier <string>
        Gets only the event subscribers with the specified SourceIdentifier property value. By default, Get-EventSubscriber gets all event subscribers in the session. Wildcards are not permitted. This parameter is case-sensitive.

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

    -SubscriptionId <int>
        Gets only the specified subscription identifier. By default, Get-EventSubscriber gets all event subscribers in the session.

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

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

INPUTS
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    System.Management.Automation.PSEventSubscriber
        Get-EventSubscriber returns an object that represents each event subscriber.

NOTES

        The New-Event cmdlet, which creates a custom event, does not generate a subscriber. Therefore, the Get-EventSubscriber cmdlet will not find a subscriber object for these events. However, if you use the Register-EngineEvent cmdlet to subscribe to a custom event (in order to forward the event or to specify an action), Get-EventSubscriber will find the subscriber that Register-EngineEvent generates.

        Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.

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

    C:\PS>$timer = New-Object Timers.Timer

    C:\PS> $timer | Get-Member -Type Event

    C:\PS> Register-ObjectEvent -inputObject $timer -EventName Elapsed -SourceIdentifier Timer.Elapsed

    C:\PS> Get-EventSubscriber

    C:\PS> $timer = New-Object Timers.Timer

    C:\PS> $timer | Get-Member -Type Event

     TypeName: System.Timers.Timer

    Name     MemberType Definition
    —-     ———- ———-
    Disposed Event     System.EventHandler Disposed(System.Object, System.EventArgs)
    Elapsed Event     System.Timers.ElapsedEventHandler Elapsed(System.Object, System.Timers.ElapsedEventArgs)

    C:\PS> Register-ObjectEvent -InputObject $timer -EventName Elapsed -SourceIdentifier Timer.Elapsed

    C:\PS> Get-EventSubscriber

    SubscriptionId : 4
    SourceObject     : System.Timers.Timer
    EventName        : Elapsed
    SourceIdentifier : Timer.Elapsed
    Action         :
    HandlerDelegate :
    SupportEvent     : False
    ForwardEvent     : False

    Description
    ———–
    This example uses a Get-EventSubscriber command to get the event subscriber for a timer event.

    The first command uses the New-Object cmdlet to create an instance of a timer object. It saves the new timer object in the $timer Variable.

    The second command uses the Get-Member cmdlet to display the events that are available for timer objects. The command uses the Type parameter of the Get-Member cmdlet with a value of Event.

    The third command uses the Register-ObjectEvent cmdlet to register for the Elapsed event on the timer object.

    The fourth command uses the Get-EventSubscriber cmdlet to get the event subscriber for the Elapsed event.

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

    C:\PS>$timer = New-Object Timers.Timer

    C:\PS> $timer.Interval = 500

    C:\PS> Register-ObjectEvent -inputObject $timer -eventName Elapsed -SourceIdentifier Timer.Random -Action { $random = Get-Random -Min 0 -Max 100 }

    Id Name         State     HasMoreData Location Command
    — —-         —–     ———– ——– ——-
    3 Timer.Random NotStarted False                 $random = Get-Random

    C:\PS> $timer.Enabled = $true

    C:\PS> $subscriber = Get-EventSubcriber -sourceIdentifer Timer.Random

    C:\PS> ($subscriber.action).gettype().fullname
    PSEventJob

    C:\PS> $subscriber.action | Format-List -property *

    State         : Running
    Module        : __DynamicModule_6b5cbe82-d634-41d1-ae5e-ad7fe8d57fe0
    StatusMessage :
    HasMoreData : True
    Location     :
    Command     : $random = Get-Random -Min 0 -Max 100
    JobStateInfo : Running
    Finished     : System.Threading.ManualResetEvent
    InstanceId    : 88944290-133d-4b44-8752-f901bd8012e2
    Id            : 1
    Name         : Timer.Random
    ChildJobs     : {}
    …

    C:\PS> & $subscriber.action.module {$random}
    96

    C:\PS> & $subscriber.action.module {$random}
    23

    Description
    ———–
    This example shows how to use the dynamic module in the PSEventJob object in the Action property of the event subscriber.

    The first command uses the New-Object cmdlet to create a timer object. The second command sets the interval of the timer to 500 (milliseconds).

    The third command uses the Register-ObjectEvent cmdlet to register the Elapsed event of the timer object. The command includes an action that handles the event. Whenever the timer interval elapses, an event is raised and the commands in the action run. In this case, the Get-Random cmdlet generates a random number between 0 and 100 and saves it in the $random Variable. The source identifier of the event is Timer.Random.

    When you use an Action parameter in a Register-ObjectEvent command, the command returns a PSEventJob object that represents the action.

    The fourth command enables the timer.

    The fifth command uses the Get-EventSubscriber cmdlet to get the event subscriber of the Timer.Random event. It saves the event subscriber object in the $subscriber Variable.

    The sixth command shows that the Action property of the event subscriber object contains a PSEventJob object. In fact, it contains the same PSEventJob object that the Register-ObjectEvent command returned.

    The seventh command uses the Format-List cmdlet to display all of the properties of the PSEventJob object in the Action property in a list. The result reveal that the PSEventJob object has a Module property that contains a dynamic script module that implements the action.

    The remaining commands use the call operator (&) to invoke the command in the module and display the value of the $random Variable. You can use the call operator to invoke any command in a module, including commands that are not exported. In this case, the commands show the random number that is being generated when the Elapsed event occurs.

    For more information about modules, see about_modules.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=135155
    Register-ObjectEvent
    Register-EngineEvent
    Register-WmiEvent
    Unregister-Event
    Get-Event
    New-Event
    Remove-Event
    Wait-Event

Get-EventLog

NAME
    Get-EventLog

SYNOPSIS
    Gets the events in an event log, or a list of the event logs, on the local or remote computers.

SYNTAX
    Get-EventLog [-AsString] [-ComputerName <string[]>] [-List] [<CommonParameters>]

    Get-EventLog [-LogName] <string> [[-InstanceId] <Int64[]>] [-After <DateTime>] [-AsBaseObject] [-Before <DateTime>] [-ComputerName <string[]>] [-EntryType <string[]>] [-Index <Int32[]>] [-Message <string>] [-Newest <int>] [-Source <string[]>] [-UserName <string[]>] [<CommonParameters>]

DESCRIPTION
    The Get-EventLog cmdlet gets events and event logs on the local and remote computers.

    Use the parameters of Get-EventLog to search for events by using their property values. Get-EventLog gets only the events that match all of the specified property values.

    The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later versions of Windows, use Get-WinEvent.

PARAMETERS
    -After <DateTime>
        Gets only the events that occur after the specified date and time. Enter a DateTime object, such as the one returned by the Get-Date cmdlet.

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

    -AsBaseObject [<SwitchParameter>]
        Returns a standard System.Diagnostics.EventLogEntry object for each event. Without this parameter, Get-EventLog returns an extended PSObject object with additional EventLogName, Source, and InstanceId properties.

        To see the effect of this parameter, pipe the events to the Get-Member cmdlet and examine the TypeName value in the result.

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

    -AsString [<SwitchParameter>]
        Returns the output as strings, instead of objects.

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

    -Before <DateTime>
        Gets only the events that occur before the specified date and time. Enter a DateTime object, such as the one returned by the Get-Date cmdlet.

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

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

        Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qualified domain name of a remote computer. 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-EventLog even if your computer is not configured to run remote commands.

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

    -EntryType <string[]>
        Gets only events with the specified entry type. Valid values are Error, Information, FailureAudit, SuccessAudit, and Warning. The default is all events.

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

    -Index <Int32[]>
        Gets only events with the specified index values.

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

    -InstanceId <Int64[]>
        Gets only events with the specified instance IDs.

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

    -List [<SwitchParameter>]
        Gets a list of event logs on the computer.

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

    -LogName <string>
        Specifies the event log. Enter the log name (the value of the Log property; not the LogDisplayName) of one event log. Wildcard characters are not permitted. This parameter is required.

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

    -Message <string>
        Gets events that have the specified string in their messages. You can use this property to search for messages that contain certain words or phrases. Wildcards are permitted.

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

    -Newest <int>
        Specifies the maximum number of events retrieved. Get-EventLog gets the specified number of events, beginning with the newest event in the log.

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

    -Source <string[]>
        Gets events that were written to the log by the specified sources. Wildcards are permitted.

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

    -UserName <string[]>
        Gets only the events that are associated with the specified user names. Enter names or name patterns, such as User01, User*, or Domain01\User*. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        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
    System.Diagnostics.EventLogEntry. System.Diagnostics.EventLog. System.String
        If the LogName parameter is specified, the output is a collection of EventLogEntry objects (System.Diagnostics.EventLogEntry).

        If only the List parameter is specified, the output is a collection of EventLog objects (System.Diagnostics.EventLog).

        If both the List and AsString parameters are specified, the output is a collection of Strings (System.String).

NOTES

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

    C:\PS>Get-Eventlog -list

    Description
    ———–
    This command displays information about the event logs on the computer.

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

    C:\PS>Get-Eventlog -Newest 5 -LogName application

    Description
    ———–
    This command displays the five most recent entries in the Application event log.

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

    C:\PS>$events = Get-Eventlog -LogName system -Newest 1000

    C:\PS> $events | Group-Object -property source -noelement | Sort-Object -property count -descending

    Count Name
    —– —-
     75 Service Control Manager
     12 Print
        6 UmrdpService
        2 DnsApi
        2 DCOM
        1 Dhcp
        1 TermDD
        1 volsnap

    Description
    ———–
    This example shows how to find all of the sources that are represented in the 1000 most recent entries in the System event log.

    The first command gets the 1,000 most recent entries from the System event log and stores them in the $events Variable.

    The second command uses a pipeline operator (|) to send the events in $events to the Group-Object cmdlet, which groups the entries by the value of the Source property. The command uses a second pipeline operator to send the grouped events to the Sort-Object cmdlet, which sorts them in descending order, so the most frequently appearing source is listed first.

    Source is just property of event log entries. To see all of the properties of an event log entry, pipe the events to the Get-Member cmdlet.

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

    C:\PS>Get-Eventlog -LogName System -EntryType Error

    Description
    ———–
    This command gets only error events from the System event log.

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

    C:\PS>Get-Eventlog -LogName System -InstanceId 3221235481 -Source “DCOM”

    Description
    ———–
    This command gets events from the System log that have an InstanceID of 3221235481 and a Source value of “DCOM.”

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

    C:\PS>Get-Eventlog -LogName “Windows PowerShell” -ComputerName localhost, Server01, Server02

    Description
    ———–
    This command gets the events from the “Windows PowerShell” event log on three computers, Server01, Server02, and the local computer, known as “localhost”.

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

    C:\PS>Get-Eventlog -LogName “Windows PowerShell” -Message “*failed*”

    Description
    ———–
    This command gets all the events in the Windows PowerShell event log that have a message value that includes the word “failed”.

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

    C:\PS>$a = Get-Eventlog -log System -Newest 1

    C:\PS> $a | Format-List -property *

    EventID            : 7036
    MachineName        : Server01
    Data             : {}
    Index             : 10238
    Category         : (0)
    CategoryNumber     : 0
    EntryType         : Information
    Message            : The description for Event ID
    Source             : Service Control Manager
    ReplacementStrings : {WinHTTP Web Proxy Auto-Disco
    InstanceId         : 1073748860
    TimeGenerated     : 4/11/2008 9:56:05 PM
    TimeWritten        : 4/11/2008 9:56:05 PM
    UserName         :
    Site             :
    Container         :

    Description
    ———–
    This example shows how to display all of the property values of an event.

    The first command gets the newest event from the System event log and saves it in the $a Variable.

    The second command uses a pipeline operator (|) to send the event in $a to the Format-List command, which displays all (*) of the event properties.

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

    C:\PS>Get-Eventlog -log application -Source outlook | where {$_.eventID -eq 34}

    Description
    ———–
    This command gets events in the Application event log where the source is Outlook and the event ID is 34. Even though Get-EventLog does not have an EventID parameter, you can use the Where-Object cmdlet to select events based on the value of any event property.

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

    C:\PS>Get-Eventlog -log system -UserName NT* | Group-Object -property username -noelement | Format-Table Count, Name -auto

    Count Name
    —– —-
     6031 NT AUTHORITY\SYSTEM
     42 NT AUTHORITY\LOCAL SERVICE
        4 NT AUTHORITY\NETWORK SERVICE

    Description
    ———–
    This command returns the events in the system log grouped by the value of their UserName property. The Get-EventLog command uses the UserName parameter to get only events in which the user name begins with “NT*”.

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

    C:\PS>$May31 = Get-Date 5/31/08

    C:\PS> $July1 = Get-Date 7/01/08

    C:\PS> Get-Eventlog -log “Windows PowerShell” -EntryType Error -After $may31 -Before $july1

    Description
    ———–
    This command gets all of the errors in the Windows PowerShell event log that occurred in June 2008.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113314
    Get-WinEvent
    Clear-EventLog
    Limit-EventLog
    New-EventLog
    Remove-EventLog
    Show-EventLog
    Write-EventLog
    Get-WinEvent