Quantcast
Channel: Symantec Connect - Endpoint Management - Discussions
Viewing all articles
Browse latest Browse all 6689

How to get task error to output properties?

$
0
0
I need a solution

I have task with powershell script in it but, when it fails on following lise I would like to capture Write-error(see highlate din bold) message to optput properties in Altiris console. Is there any easy way to do this?

see attached full script

if ($Username -eq "Administrator" -Or $UserPrefix -eq "SUP")

{

$ErrorActionPreference = "Stop"

Write-Error "Local Administrator or SUP account is logged in, we are not adding local administrator/sup account again, Log file(C:\LabIT\AdminRights_Enabled.txt) will not be updated"

} Else {

# Add logged in user to group & write user information to log file

$objGroup.PSBase.Invoke("Add",$objUser.PSBase.Path)

$Domain + "\" + $Username + "\" + $date | Out-File $LogFile

}

I would like to capture this at following location and only shows failed but, nothing in Output properties:

Capture.JPG


Viewing all articles
Browse latest Browse all 6689

Trending Articles



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