Tag Archives: Path

Get-ChildItem

NAME
    Get-ChildItem

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    -Name [<SwitchParameter>]
        Retrieves only the names of the items in the locations. If you pipe the output of this command to another command, only the item names are sent.

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

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

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

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

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

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

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

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

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

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

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

NOTES

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

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

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

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

    C:\PS>Get-ChildItem

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

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

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

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

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

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

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

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

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

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

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

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

    C:\PS>Get-ChildItem -Name

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

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

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

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

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

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

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

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

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

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

Get-Acl

NAME
    Get-Acl

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

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

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

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

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

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

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

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

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

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

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

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

        The parameter name (“Path”) is optional.

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

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

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

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

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

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

NOTES

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

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

        — Group: The security group of the owner.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Export-FormatData

NAME
    Export-FormatData

SYNOPSIS
    Saves formatting data from the current session in a formatting file.

SYNTAX
    Export-FormatData [-Force] [-IncludeScriptBlock] [-InputObject <ExtendedTypeDefinition[]>] [-NoClobber] [-Path <string>] [<CommonParameters>]

DESCRIPTION
    The Export-FormatData cmdlet creates Windows PowerShell formatting files (format.ps1xml) from the formatting objects in the current session. It takes the ExtendedTypeDefinition objects that Get-FormatData returns and saves them in a file in XML format.

    Windows PowerShell uses the data in formatting files (format.ps1xml) to generate the default display of Microsoft .NET Framework objects in the session. You can view and edit the formatting files and use the Update-FormatData cmdlet to add the formatting data to a session.

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

PARAMETERS
    -Force [<SwitchParameter>]
        Overwrites an existing output file, even if the file has the read-only attribute.

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

    -IncludeScriptBlock [<SwitchParameter>]
        Determines whether script blocks in the format data are exported.

        Because script blocks contain code and can be used maliciously, they are not exported by default.

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

    -InputObject <ExtendedTypeDefinition[]>
        Specifies the format data objects to be exported. Enter a Variable that contains the objects or a command that gets the objects, such as a Get-FormatData command. You can also pipe the objects from Get-FormatData to Export-FormatData.

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

    -NoClobber [<SwitchParameter>]
        Prevents the cmdlet from overwriting existing files. By default, Export-FormatData overwrites files without warning unless the file has the read-only attribute.

        To direct Export-FormatData to overwrite read-only files, use the Force parameter.

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

    -Path <string>
        Specifies a location for the output file. Enter a path (optional) and file name with a format.ps1xml file name extension. If you omit the path, Export-FormatData creates the file in the current directory.

        If you use a file name extension other than .ps1xml, the Update-FormatData cmdlet will not recognize the file.

        If you specify an existing file, Export-FormatData overwrites the file without warning, unless the file has the read-only attribute. To overwrite a read-only file, use the Force parameter. To prevent files from being overwritten, use the NoClobber parameter.

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

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

INPUTS
    System.Management.Automation.ExtendedTypeDefinition
        You can pipe ExtendedTypeDefinition objects from Get-FormatData to Export-FormatData.

OUTPUTS
    None
        Export-FormatData does not return any objects. It generates a file and saves it in the specified path.

NOTES

        To use any formatting file, including an exported formatting file, the execution policy for the session must allow scripts and configuration files to run. For more information, see about_execution_policies.

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

    C:\PS>Get-FormatData -typename * | Export-FormatData -Path allformat.ps1xml -IncludeScriptBlock

    Description
    ———–
    This command exports all of the format data in the session to the AllFormat.ps1xml file.

    The command uses the Get-FormatData cmdlet to get the format data in the session. A value of * (all) for the TypeName parameter directs the cmdlet to get all of the data in the session.

    The command uses a pipeline operator (|) to send the format data from the Get-FormatData command to the Export-FormatData cmdlet, which exports the format data to the AllFormat.ps1 file.

    The Export-FormatData command uses the IncludeScriptBlock parameter to include script blocks in the format data in the file.

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

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

    C:\PS> Export-FormatData -InputObject $f -Path c:\test\help.format.ps1xml -IncludeScriptBlock

    Description
    ———–
    These commands export the format data for the HelpInfoShort type to the Help.format.ps1xml file.

    The first command uses the Get-FormatData cmdlet to get the format data for the HelpInfoShort type, and it saves it in the $f Variable.

    The second command uses the InputObject parameter of the Export-FormatData to enter the format data saved in the $f Variable. It also uses the IncludeScriptBlock parameter to include script blocks in the output.

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

    C:\PS>Get-FormatData -typename System.Diagnostics.Process | Export-FormatData -Path process.format.ps1xml

    C:\PS> Update-FormatData -prependPath .\process.format.ps1xml

    C:\PS> Get-Process p*

    Handles NPM(K) PM(K) WS(K) VM(M) CPU(s)    Id ProcessName
    ——- —— —– —– —– ——    — ———–
        323                                     5600 powershell
        336                                     3900 powershell_ise
        138                                     4076 PresentationFontCache

    Description
    ———–
    This example shows the effect of omitting the IncludeScriptBlock parameter from an Export-FormatData command.

    The first command uses the Get-FormatData cmdlet to get the format data for the System.Diagnostics.Process object that the Get-Process cmdlet returns. The command uses a pipeline operator (|) to send the formatting data to the Export-FormatData cmdlet, which exports it to the Process.format.ps1xml file in the current directory.

    In this case, the Export-FormatData command does not use the IncludeScriptBlock parameter.

    The second command uses the Update-FormatData cmdlet to add the Process.format.ps1xml file to the current session. The command uses the PrependPath parameter to ensure that the formatting data for process objects in the Process.format.ps1xml file is found before the standard formatting data for process objects.

    The third command shows the effects of this change. The command uses the Get-Process cmdlet to get processes that have names that begin with “P”. The output shows that property values that are calculated by using script blocks are missing from the display.

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

Export-Clixml

NAME
    Export-Clixml

SYNOPSIS
    Creates an XML-based representation of an object or objects and stores it in a file.

SYNTAX
    Export-Clixml [-Path] <string> -InputObject <psobject> [-Depth <int>] [-Encoding <string>] [-Force] [-NoClobber] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Export-Clixml cmdlet creates an XML-based representation of an object or objects and stores it in a file. You can then use the Import-Clixml cmdlet to re-create the saved object based on the contents of that file.

    This cmdlet is similar to ConvertTo-Xml, except that Export-Clixml stores the resulting XML in a file. ConvertTo-Xml returns the XML, so you can continue to process it in Windows PowerShell.

PARAMETERS
    -Depth <int>
        Specifies how many levels of contained objects are included in the XML representation. The default value is 2.

        The default value can be overridden for the object type in the Types.ps1xml files. For more information, see about_types.ps1xml.

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

    -Encoding <string>
        Specifies the type of encoding for the target file. Valid values are ASCII, UTF8, UTF7, UTF32, Unicode, BigEndianUnicode, Default, and OEM. UTF8 is the default.

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

    -Force [<SwitchParameter>]
        Causes the cmdlet to clear the read-only attribute of the output file if necessary. The cmdlet will attempt to reset the read-only attribute when the command completes.

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

    -InputObject <psobject>
        Specifies the object to be converted. Enter a Variable that contains the objects, or type a command or expression that gets the objects. You can also pipe objects to Export-Clixml.

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

    -NoClobber [<SwitchParameter>]
        Ensures that the cmdlet does not overwrite the contents of an existing file. By default, if a file exists in the specified path, Export-Clixml overwrites the file without warning.

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

    -Path <string>
        Specifies the path to the file where the XML representation of the object will be stored.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     false
        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

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

INPUTS
    System.Management.Automation.PSObject
        You can pipe any object to Export-Clixml.

OUTPUTS
    System.IO.FileInfo
        Export-Clixml creates a file that contains the XML.

NOTES

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

    C:\PS>”This is a test” | Export-Clixml sample.xml

    Description
    ———–
    This command creates an XML file that stores a representation of the string, “This is a test”.

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

    C:\PS>Get-Acl C:\test.txt | Export-Clixml -Path fileacl.xml

    C:\PS> $fileacl = Import-Clixml fileacl.xml

    Description
    ———–
    This example shows how to export an object to an XML file and then create an object by importing the XML from the file.

    The first command uses the Get-Acl cmdlet to get the security descriptor of the Test.txt file. It uses a pipeline operator to pass the security descriptor to Export-Clixml, which stores an XML-based representation of the object in a file named FileACL.xml.

    The second command uses the Import-Clixml cmdlet to create an object from the XML in the FileACL.xml file. Then, it saves the object in the $FileAcl Variable.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113297
    Import-Clixml
    ConvertTo-Xml
    Export-Csv
    ConvertTo-Html

Export-Console

NAME
    Export-Console

SYNOPSIS
    Exports the names of snap-ins in the current session to a console file.

SYNTAX
    Export-Console [[-Path] <string>] [-Force] [-NoClobber] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Export-Console cmdlet exports the names of the Windows PowerShell snap-ins in the current session to a Windows PowerShell console file (.psc1). You can use this cmdlet to save the snap-ins for use in future sessions.

    To add the snap-ins in the .psc1 console file to a session, start Windows PowerShell (Powershell.exe) at the command line by using Cmd.exe or another Windows PowerShell session, and then use the PSConsoleFile parameter of Powershell.exe to specify the console file.

    For more information about Windows PowerShell snap-ins, see about_PSSnapins.

PARAMETERS
    -Force [<SwitchParameter>]
        Overwrites the data in a console file without warning, even if the file has the read-only attribute. The read-only attribute is changed and is not reset when the command completes.

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

    -NoClobber [<SwitchParameter>]
        Will not overwrite (replace the contents of) an existing console file. By default, if a file exists in the specified path, Export-Console overwrites the file without warning.

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

    -Path <string>
        Specifies a path and file name for the console file (*.psc1). Enter a path (optional) and name. Wildcards are not permitted.

        If you type only a file name, Export-Console creates a file with that name and the “.psc1” file name extension in the current directory.

        This parameter is required unless you have opened Windows PowerShell with the PSConsoleFile parameter or exported a console file during the current session. It is also required when you use the NoClobber parameter to prevent the current console file from being overwritten.

        If you omit this parameter, Export-Console overwrites (replaces the content of) the console file that was used most recently in this session. The path to the most recently used console file is stored in the value of the $ConsoleFileName automatic Variable. For more information, see about_Automatic_Variables.

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

    <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 path string to Export-Console.

OUTPUTS
    System.IO.FileInfo
        Export-Console creates a file that contains the exported Aliases.

NOTES

        When a console file (.psc1) is used to start the session, the name of the console file is automatically stored in the $ConsoleFileName automatic Variable. The value of $ConsoleFileName is updated when you use the Path parameter of Export-Console to specify a new console file. When no console file is used, $ConsoleFileName has no value ($null).

        To use a Windows PowerShell console file in a new session, use the following syntax to start Windows PowerShell:
        “powershell.exe -PsConsoleFile <ConsoleFile>.psc1”.

        You can also save Windows PowerShell snap-ins for future sessions by adding an Add-PSSnapin command to your Windows PowerShell profile. For more information, see about_profiles.

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

    C:\PS>Export-Console -Path $pshome\Consoles\ConsoleS1.psc1

    Description
    ———–
    This command exports the names of Windows PowerShell snap-ins in the current session to the ConsoleS1.psc1 file in the Consoles subdirectory of the Windows PowerShell installation directory, $pshome.

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

    C:\PS>Export-Console

    Description
    ———–
    This command exports the names of Windows PowerShell snap-ins from current session to the Windows PowerShell console file that was most recently used in the current session. It overwrites the previous file contents.

    If you have not exported a console file during the current session, you are prompted for permission to continue and then prompted for a file name.

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

    C:\PS>Add-PSSnapin NewPSSnapin

    C:\PS> Export-Console -Path NewPSSnapinConsole.psc1

    C:\PS> powershell.exe -PsConsoleFile NewPsSnapinConsole.psc1

    Description
    ———–
    These commands add the NewPSSnapin Windows PowerShell snap-in to the current session, export the names of Windows PowerShell snap-ins in the current session to a console file, and then start a Windows PowerShell session with the console file.

    The first command uses the Add-PSSnapin cmdlet to add the NewPSSnapin snap-in to the current session. You can only add Windows PowerShell snap-ins that are registered on your system.

    The second command exports the Windows PowerShell snap-in names to the NewPSSnapinConsole.psc1 file.

    The third command starts Windows PowerShell with the NewPSSnapinConsole.psc1 file. Because the console file includes the Windows PowerShell snap-in name, the cmdlets and providers in the snap-in are available in the current session.

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

    C:\PS>Export-Console -Path Console01

    C:\PS> notepad console01.psc1

    <?xml version=”1.0″ encoding=”utf-8″?>
    <PSConsoleFile ConsoleSchemaVersion=”1.0″>
     <PSVersion>2.0</PSVersion>
     <PSSnapIns>
        <PSSnapIn Name=”NewPSSnapin” />
     </PSSnapIns>
    </PSConsoleFile>

    Description
    ———–
    This command exports the names of the Windows PowerShell snap-ins in the current session to the Console01.psc1 file in the current directory.

    The second command displays the contents of the Console01.psc1 file in Notepad.

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

    C:\PS>powershell.exe -PSConsoleFile Console01.psc1

    C:\PS> Add-PSSnapin MySnapin

    C:\PS> Export-Console NewConsole.psc1

    C:\PS> $consolefilename

    C:\PS> Add-PSSnapin SnapIn03

    C:\PS> Export-Console

    Description
    ———–
    This example shows how to use the $ConsoleFileName automatic Variable to determine the console file that will be updated if you use Export-Console without a Path parameter value.

    The first command uses the PSConsoleFile parameter of PowerShell.exe to open Windows PowerShell with the Console01.psc1 file.

    The second command uses the Add-PSSnapin cmdlet to add the MySnapin Windows PowerShell snap-in to the current session.

    The third command uses the Export-Console cmdlet to export the names of all the Windows PowerShell snap-ins in the session to the NewConsole.psc1 file.

    The fourth command uses the $ConsoleFileName parameter to display the most recently used console file. The sample output shows that NewConsole.ps1 is the most recently used file.

    The fifth command adds SnapIn03 to the current console.

    The sixth command uses the ExportConsole cmdlet without a Path parameter. This command exports the names of all the Windows PowerShell snap-ins in the current session to the most recently used file, NewConsole.psc1.

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

Export-Counter

NAME
    Export-Counter

SYNOPSIS
    The Export-Counter cmdlet takes PerformanceCounterSampleSet objects and exports them as counter log files.

SYNTAX
    Export-Counter [-Path] <string> -InputObject <PerformanceCounterSampleSet[]> [-Circular <switch>] [-FileFormat <string>] [-Force <switch>] [-MaxSize <int>] [<CommonParameters>]

DESCRIPTION
    The Export-Counter cmdlet exports performance counter data (PerformanceCounterSampleSet objects) to log files in binary performance log (.blg), comma-separated value (.csv), or tab-separated value (.tsv) format. You can use this cmdlet to log or relog performance counter data.

    Export-Counter is designed to export data that is returned by the Get-Counter and Import-Counter cmdlets.

    Note: Export-Counter runs only on Windows 7, Windows Server 2008 R2, and later versions of Windows.

PARAMETERS
    -Circular <switch>
        Indicates that output file should be a circular log with first in, first out (FIFO) format. When you include this parameter, the MaxSize parameter is required.

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

    -FileFormat <string>
        Specifies the output format of the output log file. Valid values are CSV, TSV, and BLG. The default value is BLG.

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

    -Force <switch>
        Overwrites and replaces an existing file if one exists in the location specified by the Path parameter.

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

    -InputObject <PerformanceCounterSampleSet[]>
        Specifies the counter data to export. Enter a Variable that contains the data or a command that gets the data, such as a Get-Counter or Import-Counter command.

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

    -MaxSize <int>
        Specifies the maximum size of the output file.

        If the Circular parameter is specified, then when the log file reaches the specified maximum size, the oldest entries are deleted as newer ones are added. If the Circular parameter is not specified, then when the log file reaches the specified maximum size, no new data is added and the cmdlet generates a non-terminating error.

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

    -Path <string>
        Specifies the path and file name of the output file. Enter a relative or absolute path on the local computer, or a Uniform Naming Convention (UNC) path to a remote computer, such as \\Computer\Share\file.blg. This parameter is required.

        Note: The file format is determined by the value of the FileFormat parameter, not by the file name extension in the path.

        Required?                    true
        Position?                    2
        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
    Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSampleSet
        You can pipe performance counter data from Get-Counter or Import-Counter to Export-Counter.

OUTPUTS
    None

NOTES

        The log file generator expects that all input objects have the same counter path and that the objects are arranged in ascending time order.

        The counter type and path of the first input object determines the properties recorded in the log file. If other input objects do not have a value for a recorded property, the property field is empty. If the objects have property values that were not recorded, the extra property values are ignored.

        Performance Monitor might not be able to read all logs that Export-Counter generates. For example, Performance Monitor requires that all objects have the same path and that all objects are separated by the same time interval.

        The Import-Counter cmdlet does not have a ComputerName parameter. However, if the computer is configured for Windows PowerShell remoting, you can use the Invoke-Command cmdlet to run an Import-Counter command on a remote computer.

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

    C:\PS># Export-Counter

    Description
    ———–
    This command exports counter data to a .blg file.

    The command uses the Get-Counter cmdlet to collect processor time data. It uses a pipeline operator (|) to send the data to the Export-Counter cmdlet. The Export-Counter command uses the Path Variable to specify the output file.

    C:\PS> Get-Counter “\Processor(*)\% Processor Time” -max 50 | Export-Counter -Path $home\counters.blg

    Because the data set might be very large, this command sends the data to Export-Counter through the pipeline. If the data were saved in a Variable, the command might use a disproportionate amount of memory.

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

    C:\PS># Export-Counter

    Description
    ———–
    These commands convert a CSV file to a counter data BLG format.

    The first command uses the built-in Windows PowerShell conversion feature to store the value of 1 gigabyte (GB) in bytes in the $1GBinBytes Variable. When you type a value followed by K (kilobyte), MB (megabyte), or GB, Windows PowerShell returns the value in bytes.

    C:\PS> $1GBinBytes = 1GB

    The second command uses the Import-Counter cmdlet to import performance counter data from the Threads.csv file. The example presumes that this file was previously exported by using the Export-Counter cmdlet.

    A pipeline operator (|) sends the imported data to the Export-Counter cmdlet. The command uses the Path parameter to specify the location of the output file. It uses the Circular and MaxSize parameters to direct Export-Counter to create a circular log that wraps at 1 GB.

    C:\PS> Import-Counter threads.csv | Export-Counter -Path threadtest.blg -Circular -MaxSize $1GBinBytes

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

    C:\PS># Export-Counter

    Description
    ———–
    This example shows how to get performance counter data from a remote computer and save the data in a file on the remote computer.

    The first command uses the Get-Counter cmdlet to collect working set counter data from Server01, a remote computer. The command saves the data in the $c Variable.

    C:\PS> $c = Get-Counter -computername Server01 -counter “\Process(*)\Working Set – Private” -maxSamples 20

    The second command uses a pipeline operator (|) to send the data in $c to the Export-Counter cmdlet, which saves it in the Workingset.blg file in the Perf share on the Server01 computer.

    C:\PS> $c | Export-Counter -Path \\Server01\Perf\WorkingSet.blg

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

    C:\PS># Export-Counter

    Description
    ———–
    This example shows how to use the Import-Counter and Export-Counter cmdlets to relog existing data.

    The first command uses the Import-Counter cmdlet to import performance counter data from the DiskSpace.blg log. It saves the data in the $all Variable. This file contains samples of the “LogicalDisk\% Free Space” counter on more than 200 remote computers in the enterprise.

    C:\PS> $all = Import-Counter DiskSpace.blg

    The second command uses the CounterSamples property of the sample set object in $all and the Where-Object cmdlet (alias = “where”) to select objects with CookedValues of less than 15 (percent). The command saves the results in the $lowSpace Variable.

    C:\PS> $lowSpace = $all.countersamples | where {$_.cookedvalues -lt 15}

    The third command uses a pipeline operator (|) to send the data in the $lowSpace Variable to the Export-Counter cmdlet. The command uses the path Variable to indicate that the selected data should be logged in the LowDiskSpace.blg file.

    C:\PS> $lowSpace | Export-Counter -Path LowDiskSpace.blg

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=138337
    Get-Counter
    Import-Counter

Export-Csv

NAME
    Export-Csv

SYNOPSIS
    Converts Microsoft .NET Framework objects into a series of comma-separated value (CSV) Variable-length strings and saves the strings in a CSV file.

SYNTAX
    Export-Csv [[-Delimiter] <char>] [-Path] <string> -InputObject <psobject> [-Encoding <string>] [-Force] [-NoClobber] [-NoTypeInformation] [-Confirm] [-WhatIf] [<CommonParameters>]

    Export-Csv [-UseCulture] [-Path] <string> -InputObject <psobject> [-Encoding <string>] [-Force] [-NoClobber] [-NoTypeInformation] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Export-Csv cmdlet creates a CSV Variable-length file that represents the objects that you submit.
    You can then use the Import-Csv cmdlet to re-create objects from the CSV strings in the files. The resulting objects are CSV versions of the original objects that consist of string representations of the property values and no methods.

    You can also use the ConvertTo-Csv and ConvertFrom-Csv cmdlets to convert .NET Framework objects to CSV strings (and back). Export-Csv is the same as ConvertTo-Csv, except that it saves the CSV strings in a file.

    You can use the parameters of the Export-Csv cmdlet to specify a delimiter other than a comma or to direct Export-Csv to use the default delimiter for the current culture.

    When you submit multiple objects to Export-Csv, Export-Csv organizes the file based on the properties of the first object that you submit. If the remaining objects do not have one of the specified properties, the property value of that object is null, as represented by two consecutive commas. If the remaining objects have additional properties, those property values are not included in the file.

    For more information, see Export-Csv, and see the Notes section.

PARAMETERS
    -Delimiter <char>
        Specifies a delimiter to separate the property values. The default is a comma (,). Enter a character, such as a colon (:). To specify a semicolon (;), enclose it in quotation marks.

        Required?                    false
        Position?                    2
        Default value                , (comma)
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Encoding <string>
        Specifies the encoding for the exported CSV file. Valid values are Unicode, UTF7, UTF8, ASCII, UTF32, BigEndianUnicode, Default, and OEM. The default is ASCII.

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

    -Force [<SwitchParameter>]
        Overwrites the file specified in path without prompting.

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

    -InputObject <psobject>
        Specifies the objects to export as CSV strings. Enter a Variable that contains the objects or type a command or expression that gets the objects. You can also pipe objects to Export-Csv.

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

    -NoClobber [<SwitchParameter>]
        Do not overwrite (replace the contents) of an existing file. By default, if a file exists in the specified path, Export-Csv overwrites the file without warning.

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

    -NoTypeInformation [<SwitchParameter>]
        Omits the type information from the CSV file. By default, the first line of the CSV file contains “#TYPE ” followed by the fully-qualified name of the type of the .NET Framework object.

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

    -Path <string>
        Specifies the path to the CSV output file. The parameter is required.

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

    -UseCulture [<SwitchParameter>]
        Use the list separator for the current culture as the item delimiter. The default is a comma (,).

        This parameter is very useful in scripts that are being distributed to users worldwide. To find the list separator for a culture, use the following command: (Get-Culture).TextInfo.ListSeparator.

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

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

INPUTS
    System.Management.Automation.PSObject
        You can pipe any .NET Framework object to Export-Csv.

OUTPUTS
    System.String
        The CSV list is sent to the file designated in the Path parameter.

NOTES

        The Export-Csv cmdlet converts the objects that you submit into a series of CSV Variable-length strings and saves them in the specified text file. You can use Export-Csv to save objects in a CSV file and then use the Import-Csv cmdlet to create objects from the text in the CSV file.

        In the CSV file, each object is represented by a comma-separated list of the property values of the object. The property values are converted to strings (by using the ToString() method of the object), so they are generally represented by the name of the property value. Export-Csv does not export the methods of the object.

        The format of an exported file is as follows:
        — The first line of the CSV file contains the string ‘#TYPE ‘ followed by the fully qualified name of the .NET Framework type of the object, such as #TYPE System.Diagnostics.Process. To suppress this line, use the NoTypeInformation parameter.

        — The next line of the CSV file represents the column headers. It contains a comma-separated list of the names of all the properties of the first object.

        — Additional lines of the file consist of comma-separated lists of the property values of each object.

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

    C:\PS>Get-Process wmiprvse | Select-Object basePriority,ID,SessionID,WorkingSet | Export-Csv -Path data.csv

    Description
    ———–
    This command selects a few properties of the wmiprvse process and exports them to a CSV format file named data.csv.

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

    C:\PS>Get-Process | Export-Csv processes.csv

    C:\PS> Get-Process | Export-Csv processes.csv

    # In processes.csv

    #TYPE System.Diagnostics.Process
    __NounName,Name,Handles,VM,WS,PM,NPM,Path,Company,CPU,FileVersion,…
    Process,powershell,626,201666560,76058624,61943808,11960,C:\WINDOWS…
    Process,powershell,257,151920640,38322176,37052416,7836,C:\WINDOWS\…

    Description
    ———–
    This command exports objects representing the processes on the computer to the Processes.csv file in the current directory. Because it does not specify a delimiter, a comma (,) is used to separate the fields in the file.

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

    C:\PS>Get-Process | Export-Csv processes.csv -Delimiter “;”

    # In processes.csv

    #TYPE System.Diagnostics.Process
    __NounName;Name;Handles;VM;WS;PM;NPM;Path;Company;CPU;FileVersion;…
    Process;powershell;626;201666560;76058624;61943808;11960;C:\WINDOWS…
    Process;powershell;257;151920640;38322176;37052416;7836;C:\WINDOWS\…

    Description
    ———–
    This command exports objects representing the processes on the computer to the Processes.csv file in the current directory. It uses the Delimiter parameter to specify the semicolon (;). As a result, the fields in the file are separated by semicolons.

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

    C:\PS>Get-Process | Export-Csv processes.csv -UseCulture

    Description
    ———–
    This command exports objects representing the processes on the computer to the Processes.csv file in the current directory. It uses the UseCulture parameter to direct Export-Csv to use the delimiter specified by the ListSeparator property of the current culture.

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

    C:\PS>Get-Process | Export-Csv processes.csv -NoTypeInformation

    C:\PS> Get-Process | Export-Csv processes.csv -NoTypeInformation

    # In processes.csv

    __NounName,Name,Handles,VM,WS,PM,NPM,Path,Company,CPU,FileVersion,…
    Process,powershell,626,201666560,76058624,61943808,11960,C:\WINDOWS…
    Process,powershell,257,151920640,38322176,37052416,7836,C:\WINDOWS\…

    Description
    ———–
    This command exports objects representing the processes on the computer to the Processes.csv file in the current directory. It uses the NoTypeInformation parameter to suppress the type information in the file.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113299
    Import-Csv
    ConvertTo-Csv
    ConvertFrom-Csv

Export-Alias

NAME
    Export-Alias

SYNOPSIS
    Exports information about currently defined Aliases to a file.

SYNTAX
    Export-Alias [-Path] <string> [[-Name] <string[]>] [-Append] [-As {Csv | Script}] [-Description <string>] [-Force] [-NoClobber] [-PassThru] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Export-Alias cmdlet exports the Aliases in the current session to a file. If the output file does not exist, the cmdlet will create it.

    Export-Alias can export the Aliases in a particular scope or all scopes, it can generate the data in CSV format or as a series of Set-Alias commands that you can add to a session or to a Windows PowerShell profile.

PARAMETERS
    -Append [<SwitchParameter>]
        Appends the output to the specified file, rather than overwriting the existing contents of that file.

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

    -As <ExportAliasFormat>
        Determines the output format. CSV is the default.

        Valid values are:

        — CSV: Comma-separated value (CSV) format.
        — Script: Creates a Set-Alias command for each exported Alias. If you name the output file with a .ps1 file name extension, you can run it as a script to add the Aliases to any session.

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

    -Description <string>
        Adds a description to the exported file. The description appears as a comment at the top of the file, following the header information.

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

    -Force [<SwitchParameter>]
        Overwrites the output file, even if the read-only attribute is set on the file.

        By default, Export-Alias overwrites files without warning, unless the read-only or hidden attribute is set or the NoClobber parameter is used in the command. The NoClobber parameter takes precedence over the Force parameter when both are used in a command.

        The Force parameter cannot force Export-Alias to overwrite files with the hidden attribute.

        Required?                    false
        Position?                    named
        Default value                Does not overwrite read-only files.
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Name <string[]>
        Specifies the names of the Aliases to export. Wildcards are permitted.

        By default, Export-Alias exports all Aliases in the session or scope.

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

    -NoClobber [<SwitchParameter>]
        Prevents Export-Alias from overwriting any files, even if the Force parameter is used in the command.

        If the NoClobber parameter is omitted, Export-Alias will overwrite an existing file without warning, unless the read-only attribute is set on the file. NoClobber takes precedence over the Force parameter, which permits Export-Alias to overwrite a file with the read-only attribute.

        NoClobber does not prevent the Append parameter from adding content to an existing file.

        Required?                    false
        Position?                    named
        Default value                Overwrites read-write files.
        Accept pipeline input?     false
        Accept wildcard characters? false

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

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

    -Path <string>
        Specifies the path to the output file. Wildcards are permitted, but the resulting path value must resolve to a single file name. This parameter is required.

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

    -Scope <string>
        Specifies the scope from which the Aliases should be exported.

        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                Local
        Accept pipeline input?     false
        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

    <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
    None or System.Management.Automation.AliasInfo
        When you use the Passthru parameter, Export-Alias returns a System.Management.Automation.AliasInfo object that represents the Alias. Otherwise, this cmdlet does not generate any output.

NOTES

        You can only Export-Aliases to a file.

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

    C:\PS>Export-Alias -Path Alias.csv

    Description
    ———–
    This command exports current Alias information to a file named Alias.csv in the current directory.

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

    C:\PS>Export-Alias -Path Alias.csv -NoClobber

    Description
    ———–
    This command exports the Aliases in the current session to an Alias.csv file.

    Because the NoClobber parameter is specified, the command will fail if an Alias.csv file already exists in the current directory.

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

    C:\PS>Export-Alias -Path Alias.csv -Append -Description “Appended Aliases” -Force

    Description
    ———–
    This command appends the Aliases in the current session to the Alias.csv file.

    The command uses the Description parameter to add a description to the comments at the top of the file.

    The command also uses the Force parameter to overwrite any existing Alias.csv files, even if they have the read-only attribute.

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

    C:\PS>Export-Alias -Path Alias.ps1 -As script

    C:\PS> Add-Content -Path $profile -value (Get-Content Alias.ps1)

    C:\PS> $s = New-PSSession -computername Server01
    C:\PS> Invoke-Command -session $s -filepath .\alias.ps1

    Description
    ———–
    This example shows how to use the script file format that Export-Alias generates.

    The first command exports the Aliases in the session to the Alias.ps1 file. It uses the As parameter with a value of Script to generate a file that contains a Set-Alias command for each Alias.

    The second command adds the Aliases in the Alias.ps1 file to the CurrentUser-CurrentHost profile. (The path to the profile is saved in the $profile Variable.) The command uses the Get-Content cmdlet to get the Aliases from the Alias.ps1 file and the Add-Content cmdlet to add them to the profile. For more information, see about_profiles.

    The third and fourth commands add the Aliases in the Alias.ps1 file to a remote session on the Server01 computer. The third command uses the New-PSSession cmdlet to create the session. The fourth command uses the FilePath parameter of the Invoke-Command cmdlet to run the Alias.ps1 file in the new session.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113296
    Import-Alias
    Get-Alias
    New-Alias
    Set-Alias

Copy-ItemProperty

NAME
    Copy-ItemProperty

SYNOPSIS
    Copies a property and value from a specified location to another location.

SYNTAX
    Copy-ItemProperty [-LiteralPath] <string[]> [-Destination] <string> [-Name] <string> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

    Copy-ItemProperty [-Path] <string[]> [-Destination] <string> [-Name] <string> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Copy-ItemProperty cmdlet copies a property and value from a specified location to another location. For example, you can use Copy-ItemProperty to copy one or more Registry entries from one Registry key to another Registry key.

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

    -Destination <string>
        Specifies the path to the destination location.

        Required?                    true
        Position?                    2
        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 override restrictions such as renaming existing files as long as security is not compromised.

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

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

        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 to be copied.

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

    -PassThru [<SwitchParameter>]
        Returns an object representing the copied item property. By default, this cmdlet does not generate any output.

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

    -Path <string[]>
        Specifies the path to the property to be copied.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue, 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
    System.String
        You can pipe a string that contains a path to Copy-ItemProperty.

OUTPUTS
    None or System.Management.Automation.PSCustomObject
        When you use the Passthru parameter, Copy-ItemProperty generates a PsCustomObject representing the copied item property. Otherwise, this cmdlet does not generate any output.

NOTES

        The Copy-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>Copy-Itemproperty -Path MyApplication -Destination HKLM:\Software\MyApplicationRev2 -Name MyProperty

    Description
    ———–
    This command copies the property named MyProperty from the MyApplication Registry key to the MyApplicationRev2 Registry key.

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

Copy-Item

NAME
    Copy-Item

SYNOPSIS
    Copies an item from one location to another within a namespace.

SYNTAX
    Copy-Item [-LiteralPath] <string[]> [[-Destination] <string>] [-Container] [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

    Copy-Item [-Path] <string[]> [[-Destination] <string>] [-Container] [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Recurse] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Copy-Item cmdlet copies an item from one location to another in a namespace. Copy-Item does not delete the items being copied. The particular items that the cmdlet can copy depend on the Windows PowerShell providers available. For example, when used with the FileSystem provider, it can copy files and directories and when used with the Registry provider, it can copy Registry keys and entries.

PARAMETERS
    -Container [<SwitchParameter>]
        Preserves container objects during the copy operation.

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

        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

    -Destination <string>
        Specifies the path to the location where the items are to be copied.

        Required?                    false
        Position?                    2
        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 copy items that cannot otherwise be changed, such as copying over a read-only file or Alias.

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

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

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

    -LiteralPath <string[]>
        Specifies a path to the item. The value of the LiteralPath parameter 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

    -PassThru [<SwitchParameter>]
        Returns an object representing each copied item. By default, this cmdlet does not generate any output.

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

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

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

    -Recurse [<SwitchParameter>]
        Specifies a recursive copy.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        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
    System.String
        You can pipe a string that contains a path to Copy-ItemProperty.

OUTPUTS
    None or an object representing the copied item.
        When you use the PassThru parameter, Copy-Item returns an object that represents the copied item. Otherwise, this cmdlet does not generate any output.

NOTES

        Copy-Item is like the ‘cp’ or ‘copy’ commands in other shells.

        The Copy-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>Copy-Item C:\Wabash\Logfiles\mar1604.log.txt -Destination C:\Presentation

    Description
    ———–
    This command will copy the file mar1604.log.txt to the C:\Presentation directory. The command does not delete the original file.

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

    C:\PS>Copy-Item C:\Logfiles -Destination C:\Drawings -Recurse

    Description
    ———–
    This command copies the entire contents of the Logfiles directory into the Drawings directory. If the source directory contains files in subdirectories, those subdirectories will be copied with their file trees intact. The Container parameter is set to true by default. This preserves the directory structure.

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

    C:\PS>Copy-Item C:\Logfiles -Destination C:\Drawings\Logs -Recurse

    Description
    ———–
    This command copies the contents of the C:\Logfiles directory to the C:\Drawings\Logs directory. It will create the subdirectory \Logs if it does not already exist.

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