header image

Read-Host

Posted by: | September 1, 2008 | No Comment |

Came across a point on the newsgroup about read-host that is worth a reminder.  Read-host returns a string or a secure string

PS> $i = Read-Host "Enter a Number"
Enter a Number: 7
PS> $i | get-member

   TypeName: System.String

if you want a number to be returned

PS> [int]$i = Read-Host "Enter a Number"
Enter a Number: 7
PS> $i | get-member

   TypeName: System.Int32

If in doubt about what is returned check the help file.  It should tell you the return type

 

Share this post :

 

Technorati Tags:

under: PowerShell original