PowerShell Logo Small

oss



This is the built-in help made by Microsoft for the command 'oss', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Sends objects to the host as a series of strings.

SYNTAX


Out-String [-InputObject <PSObject>] [-Stream] [-Width <Int32>] [<CommonParameters>]



Search powershellhelp.space

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.



<

RELATED LINKS

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

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>get-content C:\test1\testfile2.txt | out-string



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

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 returned. The command then stores the results in the $c
variable.
PS C:\>$c = Get-Culture | Select-Object *

The second command uses the Out-String cmdlet 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.
PS C:\>Out-String -InputObject $c -Width 100



These commands get the regional settings for the current user and convert the data to strings.




-------------------------- EXAMPLE 3 --------------------------

PS C:\>get-alias | out-string -stream | select-string "Get-Command"



This example demonstrates the difference between working with objects and working with strings. The 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).

The pipeline operator (|) sends the output of the Get-Alias cmdlet to the Out-String cmdlet, which converts the objects to a series of
strings. It uses the Stream parameter of Out-String to send each string individually, instead of concatenating them into a single string.
Another pipeline operator sends the strings to the Select-String cmdlet, 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.