Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

PowerShell Newbie Help - Hiding an error message

$
0
0

Hi Guys

Hope you can help! I am not great with PowerShell just yet, getting to grips slowly but am stuck on something simple, even after some searching.

So I have a script something like this;

$taskcheck = schtasks /tn "Scheduled Task"
IF($taskcheck)
{
Write-Host "Already Exists!"
}
Else
{
Write-Host "Doesn't Exist, Creating"
}

So if the task name does exist, it works great. However, when the task doesn't exist, it throws this messy looking error in red font - how can I hide this and just show my message "Doesn't Exist, Creating"


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>