Converting the FileSystemObject's GetStandardStream Method
Definition: Returns a string (TextStream object) that corresponds to StdIn, StdOut, or StdErr
PowerShell provides cmdlets to read from and write to the console. To read from StdIn, use the Read-Host cmdlet:
PS C:\scripts> Read-Host
Typing in some standard input
Typing in some standard input
To write to StdOut, use the Write-Host cmdlet:
PS C:\scripts> $a = "A text string to output"
PS C:\scripts> Write-Host $a
A text string to output
Of course, be default all output from PowerShell commands goes to the console. So this also works:
PS C:\scripts> $a = "A text string to output"
PS C:\scripts> $a
A text string to output
We’re not sure why you’d do this instead of using the cmdlets, but you can read and write input to and from the console by using the .NET Framework System.Console class.
This command reads StdIn, meaning that when you run this command it will wait for input from the console before PowerShell will continue:
PS C:\scripts> [System.Console]::ReadLine()
Typing in some standard input
Typing in some standard input
Here’s an example of writing specifically to StdOut:
PS C:\scripts> $a = "A text string to output"
PS C:\scripts> [system.console]::writeline($a)
A text string to output
See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page