Try & Catch

by Feb 3, 2015

Hi ,

I would like to use ERROR handling with Try&Catch, that can handle $computername variable, if computer is not found, message comes up: "hey I did not find computer with this name"
to where should I insert try&catch to, in my stuff? a little explanation would be appreciated..

#OSversion attempt:

$ends = ""
while ($ends -ne "END") {
$computername = Read-Host "Enter Server's Name "
Get-WmiObject -Class Win32_OperatingSystem -ComputerName $computername | format-list (
 $ends = read-host "Continue or END "
Thank you in advance