Category Archives: Out

Out-Default

NAME
    Out-Default

SYNOPSIS
    Sends the output to the default formatter and to the default output cmdlet.

SYNTAX
    Out-Default [-InputObject <psobject>] [<CommonParameters>]

DESCRIPTION
    The Out-Default cmdlet sends output to the default formatter and the default output cmdlet. This cmdlet has no effect on the formatting or output of Windows PowerShell commands. It is a placeholder that lets you write your own Out-Default Function or cmdlet.

PARAMETERS
    -InputObject <psobject>

        Required?                    false
        Position?                    named
        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

OUTPUTS

NOTES

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

Out-File

NAME
    Out-File

SYNOPSIS
    Sends output to a file.

SYNTAX
    Out-File [-FilePath] <string> [[-Encoding] <string>] [-Append] [-Force] [-InputObject <psobject>] [-NoClobber] [-Width <int>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Out-File cmdlet sends output to a file. You can use this cmdlet instead of the redirection operator (>) when you need to use its parameters.

PARAMETERS
    -Append [<SwitchParameter>]
        Adds the output to the end of an existing file, instead of replacing the file contents.

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

    -Encoding <string>
        Specifies the type of character encoding used in the file. Valid values are “Unicode”, “UTF7”, “UTF8”, “UTF32”, “ASCII”, “BigEndianUnicode”, “Default”, and “OEM”. “Unicode” is the default.

        “Default” uses the encoding of the system’s current ANSI code page.

        “OEM” uses the current original equipment manufacturer code page identifier for the operating system.

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

    -FilePath <string>
        Specifies the path to the output file.

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

    -Force [<SwitchParameter>]
        Allows the cmdlet to overwrite an existing read-only file. 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

    -InputObject <psobject>
        Specifies the objects to be written to the file. Enter a Variable that contains the objects or type a command or expression that gets the objects.

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

    -NoClobber [<SwitchParameter>]
        Will not overwrite (replace the contents) of an existing file. By default, if a file exists in the specified path, Out-File overwrites the file without warning. If both Append and NoClobber are used, the output is appended to the existing file.

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

    -Width <int>
        Specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. If you omit this parameter, the width is determined by the characteristics of the host. The default for the Windows PowerShell console is 80 (characters).

        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

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

OUTPUTS
    None
        Out-File does not generate any output.

NOTES

        The Out cmdlets do not format objects; they just render them and send them to the specified display destination. If you send an unformatted object to an Out cmdlet, the cmdlet sends it to a formatting cmdlet before rendering it.

        The Out cmdlets do not have parameters for names or file paths. To send data to a cmdlet that contains the Out verb (an Out cmdlet), use a pipeline operator (|) to send the output of a Windows PowerShell command to the cmdlet. You can also store data in a Variable and use the InputObject parameter to pass the data to the cmdlet. For help, see the examples.

        Out-File sends data, but it does not emit any output objects. If you pipe the output of Out-File to Get-Member, Get-Member reports that no objects have been specified.

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

    C:\PS>Get-Process | Out-File -FilePath C:\Test1\process.txt

    Description
    ———–
    This command sends a list of processes on the computer to the Process.txt file. If the file does not exist, Out-File creates it. Because the name of the FilePath parameter is optional, you can omit it and submit the equivalent command “Get-Process | outfile C:\Test1\process.txt”.

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

    C:\PS>Get-Process | Out-File C:\Test1\process.txt -NoClobber

    Out-File : File C:\Test1\process.txt already exists and NoClobber was specified.
    At line:1 char:23
    + Get-Process | Out-File <<<< process.txt -NoClobber

    Description
    ———–
    This command also sends a list of processes to the Process.txt file, but it uses the NoClobber parameter, which prevents an existing file from being overwritten. The output shows the error message that appears when NoClobber is used with an existing file.

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

    C:\PS>$a = Get-Process

    C:\PS> Out-File -FilePath C:\Test1\process.txt -InputObject $a -Encoding ASCII -Width 50

    Description
    ———–
    These commands send a list of processes on the computer to the Process.txt file. The text is encoded in ASCII format so that it can be read by search programs like Findstr and Grep. By default, Out-File uses Unicode format.

    The first command gets the list of processes and stores them in the $a Variable. The second command uses the Out-File cmdlet to send the list to the Process.txt file.

    The command uses the InputObject parameter to specify that the input is in the $a Variable. It uses the Encoding parameter to convert the output to ASCII format. It uses the Width parameter to limit each line in the file to 50 characters. Because the lines of output are truncated at 50 characters, the rightmost column in the process table is omitted.

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

    C:\PS>Set-Location hklm:\software

    c:\PS>Get-Acl mycompany\mykey | Out-File -FilePath c:\ps\acl.txt

    c:\PS>Get-Acl mycompany\mykey | Out-File -FilePath FileSystem::acl.txt

    Description
    ———–
    These commands show how to use the Out-File cmdlet when you are not in a FileSystem drive.

    The first command sets the current location to the HKLM:\Software Registry key.

    The second and third commands have the same effect. They use the Get-Acl cmdlet to get the security descriptor of the MyKey Registry subkey (HKLM\Software\MyCompany\MyKey). A pipeline operator passes the result to the Out-File cmdlet, which sends it to the Acl.txt file.

    Because Out-File is not supported by the Windows PowerShell Registry provider, you must specify either the file system drive name, such as “c:”, or the name of the provider followed by two colons, “FileSystem::”, in the value of the FilePath parameter. The second and third commands demonstrate these methods.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113363
    Out-String
    Out-Null
    Out-Host
    Out-Printer
    Out-Default
    Tee-Object

Out-GridView

NAME
    Out-GridView

SYNOPSIS
    Sends output to an interactive table in a separate window.

SYNTAX
    Out-GridView [-InputObject <psobject>] [-Title <string>] [<CommonParameters>]

DESCRIPTION
    The Out-GridView cmdlet sends the output from a command to a grid view window where the output is displayed in an interactive table. This feature requires Microsoft .NET Framework 3.5 with Service Pack 1.

    You can use the following features of the table to examine your data:

    — Hide, Show, and Reorder Columns: To hide, show, or reorder a column, right-click a column header and then click “Select Columns.”

    — Sort. To sort the data, click a column header. Click again to toggle from ascending to descending order.

    — Quick Filter. Use the “Filter” box at the top of the window to search the text in the table. You can search for text in a particular column, search for literals, and search for multiple words.

    — Criteria Filter. Use the “Add criteria” drop-down menu to create rules to filter the data. This is very useful for very large data sets, such as event logs.

    — Copy and paste. To copy rows of data from Out-GridView, press CTRL+C (copy). You can paste the data into any text or spreadsheet program.

    For instructions for using these features, type “Get-Help Out-GridView -full” and see “How to Use the Grid View Window Features” in the NOTES section.

PARAMETERS
    -InputObject <psobject>
        Accepts input for Out-GridView.

        When you use the InputObject parameter to send a collection (more than one) of objects to Out-GridView, Out-GridView treats the collection as one collection object, and it displays one row that represents the collection. To display the each object in the collection, use a pipeline operator (|) to send objects to Out-GridView.

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

    -Title <string>
        Specifies the text that appears in the title bar of the Out-GridView window.

        By default, the title bar displays the command that invokes Out-GridView.

        Required?                    false
        Position?                    named
        Default value                The current command
        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 send any object to Out-GridView.

OUTPUTS
    None
        Out-GridView does not return any objects.

NOTES

        NOTES FOR Out-GridView
        ———————-

        You can download the Microsoft .NET Framework 3.5 with Service Pack 1 from the Microsoft Download Center.

        Because this cmdlet requires a user interface, it does not work on Server Core installations of Windows Server.

        You cannot use a remote command to open a grid view window on a remote computer.

        The command output that you send cannot be pre-formatted, such as by using the Format-Table or Format-Wide cmdlets. To select properties, use the Select-Object cmdlet.

        Deserialized output from remote commands might not be formatted correctly in the grid view window.

        KEYBOARD SHORTCUTS FOR Out-GridView
        ———————————–

        By using the following keyboard shortcuts, you can perform many tasks quickly.

        Use this key:     To perform this action:
        ————-     —————————————————————-
        TAB             Moves the cursor from the Filter box to the Add criteria menu to the table and back.
        UP ARROW         Move up one row. Will move to column headers.
        DOWN ARROW        Move down one row.
        LEFT ARROW        In column header row, move left one column.
        RIGHT ARROW     In column header row, move right one column.
        CONTEXT MENU KEY In column header row, displays the “Select Columns” option.
        ENTER or SPACEBAR In column header row, sort column data (toggle A-Z, Z-A).

        HOW TO USE THE GRID VIEW WINDOW FEATURES
        —————————————-
        The following topics explain how to use the features of the window that Out-GridView displays.

        How to Hide, Show, and Reorder Columns
        ————————————–
        To hide or show a column:

        1. Right click any column header and click “Select Columns”.

        2. In the “Select Columns” dialog box, use the arrow keys to move the columns between the “Selected columns” to the “Available columns” boxes. Only columns in the “Selected Columns” box appear in the grid view window.

        To reorder columns:

        — Drag and drop the column into the desired location.

        – or-

        1. Right click any column header and click “Select Columns”.

        2. In the “Select Columns” dialog box, use the “Move up” and “Move down” buttons to reorder the columns. Columns at the top of the list appear to the left of columns at the bottom of the list in the grid view window.

        How to Sort Table Data
        ———————-
        — To sort the data, click a column header.
        — To change the sort order, click the column header again. Each time you click the same header, the sort order toggles between ascending to descending order. The current order is indicated by a triangle in the column header.

        How to Select Table Data
        ————————
        — To select a row, click the row or use the up or down arrow to navigate to the row.
        — To select all rows (except for the header row), press CTRL+A.
        — To select consecutive rows, press and hold the SHIFT key while clicking the rows or using the arrow keys.
        — To select nonconsecutive rows, press the CTRL key and click to add a row to the selection.
        You cannot select columns, and you cannot select the entire column header row.

        How to Copy Rows
        ———————-
        — To copy one or more rows from the table, select the rows and then press CTRL+C.
        You can paste the data into any text or spreadsheet program. You cannot copy columns or parts of rows and you cannot copy the column header row.

        How to Search in the Table (Quick Filter)
        ———————————
        Use the “Filter” box to search for data in the table. When you type in the box, only items that include the typed text appear in the table.

        — Search for text. To search for text in the table, in the “Filter” box, type the text to find.

        — Search for multiple words. To search for multiple words in the table, type the words separated by spaces. Out-GridView displays rows that include all of the words (logical AND).

        — Search for literal phrases. To search for phrases that include spaces or special characters, enclose the phrase in quotation marks. Out-GridView displays rows that include an exact match for the phrase.

        — Search in columns. To search for text in one or more columns, use the following format:

         <column>:<text> [<column>:<text>] …

            For example, to find “Net” in the DisplayName column, in the “Filter” box, type:

         displayname:net

            To find rows with “Net” in the DisplayName and Name columns, in the “Filter” box, type:

         displayname:net name:net

        — Turn off search. To display the entire table again, click the red X button in the top right corner of the “Filter” box or delete the text from the Filter box.

        Use Criteria to Filter the Table
        ——————————–
        You can use rules or “criteria” to determine which items are displayed in the table. Items appear only when they satisfy all of the criteria that you establish. The available criteria are determined by the properties of the objects displayed in the grid view window and the .NET Framework types of those properties.

        Each criterion has the following format:
        <column> <operator> <value>

        Criteria for different properties are connected by AND. Criteria for the same property are connected by OR. You cannot change the logical connectors.

        The criteria only affects the display. It does not delete items from the table.

        How to Add Criteria
        —————————
        1. To display the “Add criteria” menu button, in the upper right corner of the window, click the “Expand” arrow.
        2. Click the “Add Criteria” menu button.
        3. Click to select columns (properties). You can select one or many properties.
        4. When you are finished selecting properties, click the Add button.
        5. To cancel the additions, click Cancel.
        6. To add more criteria, click the Add Criteria button again.

        How to Edit a Criterion
        ——————–
        — To change an operator, click the blue operator value, and then click to select a different
         operator from the drop-down list.
        — To enter or change a value, type a value in the value box. If you enter a value that is not valid, a circular X icon appears. To remove it, change the value.
        — To create an OR statement, add a criteria with the same property.

        How to Delete Criteria
        ————————-
        — To delete selected criteria, click the red X beside each criterion.
        — To delete all criteria, click the “Clear All” button.

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

    C:\PS>Get-Process | Out-GridView

    Description
    ———–
    This command gets the processes running on the local computer and sends them to a grid view window.

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

    C:\PS>$p = Get-Process

    C:\PS> $p | Out-GridView

    Description
    ———–
    This command also gets the processes running on the local computer and sends them to a grid view window.

    The first command uses the Get-Process command to get the processes on the computer and then saves the process objects in the $p Variable.

    The second command uses a pipeline operator to send the $p Variable to Out-GridView.

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

    C:\PS>Get-Process | Select-Object -property name, workingset, peakworkingset | Sort-Object -property workingset -desc | Out-GridView

    Description
    ———–
    This command displays a formatted table in a grid view window.

    It uses the Get-Process cmdlet to get the processes on the computer.

    Then, it uses a pipeline operator (|) to send the process objects to the Select-Object cmdlet. The command uses the Property parameter of Select-Object to select the Name, WorkingSet, and PeakWorkingSet properties to be displayed in the table.

    Another pipeline operator sends the filtered objects to the Sort-Object cmdlet, which sorts them in descending order by the value of the WorkingSet property.

    The final part of the command uses a pipeline operator (|) to send the formatted table to Out-GridView.

    You can now use the features of the grid view to search, sort, and filter the data.

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

    C:\PS>($a = Get-ChildItem -path $pshome -recurse) | Out-GridView

    Description
    ———–
    This command saves its output in a Variable and sends it to Out-GridView.

    The command uses the Get-ChildItem cmdlet to get the files in the Windows PowerShell installation directory and its subdirectories. The path to the installation directory is saved in the $pshome automatic Variable.

    The command uses the assignment operator (=) to save the output in the $a Variable and the pipeline operator (|) to send the output to Out-GridView.
    The parentheses in the command establish the order of operations. As a result, the output from the Get-ChildItem command is saved in the $a Variable before it is sent to Out-GridView.

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

    C:\PS>Get-Process -computername Server01| ogv -Title “Processes – Server01”

    Description
    ———–
    This command displays the processes that are running on the Server01 computer in a grid view window.

    The command uses “ogv,” which is the built-in Alias for the Out-GridView cmdlet, it uses the Title parameter to specify the window title.

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

    C:\PS>Invoke-Command -ComputerName S1, S2, S3 -scriptblock {Get-Culture} | Out-GridView

    Description
    ———–
    This example shows the correct format for sending data collected from remote computers to the Out-GridView cmdlet.

    The command uses the Invoke-Command cmdlet to run a Get-Culture command on three remote computers. It uses a pipeline operator to send the data that is returned to the Out-GridView cmdlet.

    Notice that the script block that contains the commands that are run remotely does not include the Out-GridView command. If it did, the command would fail when it tried to open a grid view window on each of the remote computers.

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

Out-Host

NAME
    Out-Host

SYNOPSIS
    Sends output to the command line.

SYNTAX
    Out-Host [-InputObject <psobject>] [-Paging] [<CommonParameters>]

DESCRIPTION
    The Out-Host cmdlet sends output to the Windows PowerShell host for display. The host displays the output at the command line. Because Out-Host is the default, you do not need to specify it unless you want to use its parameters to change the display.

PARAMETERS
    -InputObject <psobject>
        Specifies the objects that are written to the console. Enter a Variable that contains the objects, or type a command or expression that gets the objects.

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

    -Paging [<SwitchParameter>]
        Displays one page of output at a time, and waits for user input before displaying the remaining pages, much like the traditional “more” command. By default, all of the output is displayed on a single page. The page size is determined by the characteristics of the host.

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

OUTPUTS
    None
        Out-Host does not generate any output. However, the host might display the objects that Out-Host sends to it.

NOTES

        You can also refer to Out-Host by its built-in Alias, “oh”. For more information, see about_aliases.

        The cmdlets that contain the Out verb (the Out cmdlets) do not format objects; they just render them and send them to the specified display destination. If you send an unformatted object to an Out cmdlet, the cmdlet sends it to a formatting cmdlet before rendering it.

        The Out cmdlets do not have parameters for names or file paths. To send data to an Out cmdlet, use a pipeline operator (|) to send the output of a Windows PowerShell command to the cmdlet. You can also store data in a Variable and use the InputObject parameter to pass the data to the cmdlet. For help, see the examples.

        Out-Host sends data, but it does not emit any output objects. If you pipe the output of Out-Host to Get-Member, Get-Member reports that no objects have been specified.

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

    C:\PS>Get-Process | Out-Host -Paging

    Description
    ———–
    This command displays the processes on the system one page at a time. It uses the Get-Process command to get the processes on the system. The pipeline operator (|) sends the results to Out-Host, which displays them at the console. The Paging parameter displays one page of data at a time.

    The same command format is used for the Help Function that is built into Windows PowerShell. That Function gets data from Get-Help and then uses the Paging parameter of Out-Host to display the data one page at a time by using this command format: Get-Help $args[0] | Out-Host -Paging).

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

    C:\PS>$a = Get-History

    C:\PS>Out-Host -InputObject $a

    Description
    ———–
    These commands display the session history at the command line. The first command uses the Get-History cmdlet to get the session history, and then it stores the history in the $a Variable. The second command uses Out-Host to display the content of the $a Variable, and it uses the InputObject parameter to specify the Variable to Out-Host.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113365
    Out-Printer
    Out-Null
    Out-File
    Out-String
    Out-Default
    Write-Host

Out-Null

NAME
    Out-Null

SYNOPSIS
    Deletes output instead of sending it to the console.

SYNTAX
    Out-Null [-InputObject <psobject>] [<CommonParameters>]

DESCRIPTION
    The Out-Null cmdlet sends output to NULL, in effect, deleting it.

PARAMETERS
    -InputObject <psobject>
        Specifies the object that was sent to null (deleted). Enter a Variable that contains the objects, or type a command or expression that gets the objects.

        Required?                    false
        Position?                    named
        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
    System.Management.Automation.PSObject
        You can pipe any object to Out-Null.

OUTPUTS
    None
        Out-Null does not generate any output.

NOTES

        The cmdlets that contain the Out verb (the Out cmdlets) do not have parameters for names or file paths. To send data to an Out cmdlet, use a pipeline operator (|) to send the output of a Windows PowerShell command to the cmdlet. You can also store data in a Variable and use the InputObject parameter to pass the data to the cmdlet. For more information, see the examples.

        Out-Null does not return any output objects. If you pipe the output of Out-Null to Get-Member, Get-Member reports that no objects have been specified.

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

    C:\PS>Get-ChildItem | Out-Null

    Description
    ———–
    This command gets the items in the local directory, but then it discards them instead of passing them through the pipeline or displaying them at the command line. This is useful for discarding output that you do not need.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113366
    Out-Printer
    Out-Host
    Out-File
    Out-String
    Out-Default

Out-Printer

NAME
    Out-Printer

SYNOPSIS
    Sends output to a printer.

SYNTAX
    Out-Printer [[-Name] <string>] [-InputObject <psobject>] [<CommonParameters>]

DESCRIPTION
    The Out-Printer cmdlet sends output to the default printer or to an alternate printer, if one is specified.

PARAMETERS
    -InputObject <psobject>
        Specifies the objects to be sent to the printer. Enter a Variable that contains the objects, or type a command or expression that gets the objects.

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

    -Name <string>
        Specifies the alternate printer. The parameter name (“Name”) is optional.

        Required?                    false
        Position?                    1
        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 Out-Printer.

OUTPUTS
    None
        Out-Printer does not return any objects.

NOTES

        You can also refer to Out-Printer by its built-in Alias, “lp”. For more information, see about_aliases.

        The cmdlets that contain the Out verb (the Out cmdlets) do not format objects; they just render them and send them to the specified display destination. If you send an unformatted object to an Out cmdlet, the cmdlet sends it to a formatting cmdlet before rendering it.

        The Out cmdlets do not have parameters for names or file paths. To send data to an Out cmdlet, use a pipeline operator (|) to send the output of a Windows PowerShell command to the cmdlet. You can also store data in a Variable and use the InputObject parameter to pass the data to the cmdlet. For more information, see the examples.

        Out-Printer sends data, but it does not emit any output objects. If you pipe the output of Out-Printer to Get-Member, Get-Member reports that no objects have been specified.

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

    C:\PS>Get-Content $pshome\about_signing.help.txt | Out-Printer

    Description
    ———–
    This command prints the content of the about_Signing Help topic to the default printer. This example shows you how to print a file, even though Out-Printer does not have a Path parameter.

    The command uses the Get-Content cmdlet to get the contents of the Help topic. The path includes $pshome, a built-in Variable that stores the installation directory for Windows PowerShell. A pipeline operator (|) passes the results to Out-Printer, which sends it to the default printer.

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

    C:\PS>”Hello, World” | Out-Printer -Name “\\Server01\Prt-6B Color”

    Description
    ———–
    This command prints “Hello, World” to the “Prt-6B Color” printer on Server01. This command uses the Name parameter to specify the alternate printer. Because the parameter name is optional, you can omit it.

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

    C:\PS>$h = Get-Help -full Get-WmiObject

    C:\PS> Out-Printer -InputObject $h

    Description
    ———–
    These commands print the full version of the Help topic for Get-WmiObject. The first command uses the Get-Help cmdlet to get the full version of the Help topic for Get-WmiObject and stores it in the $h Variable. The second command sends the content to the default printer. It uses the InputObject parameter to pass the value of the $h Variable to Out-Printer.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113367
    Out-Host
    Out-Null
    Out-String
    Out-File
    Out-Default

Out-String

NAME
    Out-String

SYNOPSIS
    Sends objects to the host as a series of strings.

SYNTAX
    Out-String [-InputObject <psobject>] [-Stream] [-Width <int>] [<CommonParameters>]

DESCRIPTION
    The Out-String cmdlet converts the objects that Windows PowerShell manages into an array of strings. By default, Out-String accumulates the strings and returns them as a single string, but you can use the stream parameter to direct Out-String to return one string at a time. This cmdlet lets you search and manipulate string output as you would in traditional shells when object manipulation is less convenient.

PARAMETERS
    -InputObject <psobject>
        Specifies the objects to be written to a string. Enter a Variable that contains the objects, or type a command or expression that gets the objects.

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

    -Stream [<SwitchParameter>]
        Sends the strings for each object separately. By default, the strings for each object are accumulated and sent as a single string.

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

    -Width <int>
        Specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. If you omit this parameter, the width is determined by the characteristics of the host. The default for the PowerShell.exe host is 80 (characters).

        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 objects to Out-String.

OUTPUTS
    System.String
        Out-String returns the string that it creates from the input object.

NOTES

        The cmdlets that contain the Out verb (the Out cmdlets) do not format objects; they just render them and send them to the specified display destination. If you send an unformatted object to an Out cmdlet, the cmdlet sends it to a formatting cmdlet before rendering it.

        The Out cmdlets do not have parameters for names or file paths. To send data to an Out cmdlet, use a pipeline operator (|) to send the output of a Windows PowerShell command to the cmdlet. You can also store data in a Variable and use the InputObject parameter to pass the data to the cmdlet. For more information, see the examples.

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

    C:\PS>Get-Content C:\test1\testfile2.txt | Out-String

    Description
    ———–
    This command sends the content of the Testfile2.txt file to the console as a single string. It uses the Get-Content cmdlet to get the content of the file. The pipeline operator (|) sends the content to Out-String, which sends the content to the console as a string.

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

    C:\PS>$c = Get-Culture | Select-Object *

    C:\PS> Out-String -InputObject $c -Width 100

    Description
    ———–
    These commands get the regional settings for the current user and convert the data to strings. The first command uses the Get-Culture cmdlet to get the regional settings. The pipeline operator (|) sends the result to the Select-Object cmdlet, which selects all properties (*) of the culture object that Get-Culture retrieved. The command then stores the results in the $c Variable.

    The second command uses Out-String to convert the CultureInfo object to a series of strings (one string for each property). It uses the InputObject parameter to pass the $c Variable to Out-String. The width parameter is set to 100 characters per line to prevent truncation.

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

    C:\PS>Get-Alias | Out-String -Stream | Select-StringGet-Command

    Description
    ———–
    This command displays Aliases that include the phrase “Get-Command“. It uses the Get-Alias cmdlet to get a set of AliasInfo objects (one for each Alias in the current session). This example demonstrates the difference between working with objects and working with strings.

    The pipeline operator (|) sends the output of Get-Alias to Out-String, which converts the objects to a series of strings. It uses the Stream parameter to send each string individually, instead of concatenating them into a single string. Another pipeline operator sends the strings to Select-String, which selects the strings that include “Get-Command” anywhere in the string.

    If you omit the Stream parameter, the command displays all of the Aliases, because Select-String finds “Get-Command” in the single string that Out-String returns, and the formatter displays the string as a table.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113368
    Out-File
    Out-Null
    Out-Host
    Out-Printer
    Out-Default