Good morning everyone,
Question. Is there a straight forward way to pass an error or general output from a script to a dashboard. For instance, I’d like to display a message on the dashboard if the user is already in a CSV file. My code looks like this,
Invoke-PSUScript 'CSV_Populator.ps1' FormData $EventData -Integrated -Wait
Here is CSV_Populator.ps1,
<#
.SYNOPSIS
Comparing Current Date with date set for 'Coverage Until' and 'Transfer Date'
.DESCRIPTION
Comparing Current Date with date set for 'Coverage Until' and 'Transfer Date'
#>
param(
[Parameter(Mandatory)]
$FormData
)
$FileName = 'C:\PSU_Employee_Transfer\Employee_Transfer_Schedule.CSV'
#Make sure object properties are correct before exporting to CSV.
if ($FormData[0].CoverageSelection -eq 'No'){
$FormData[0].CoverageDate = 'N/A'
}
#Check to see if CSV exists.
if([System.IO.File]::Exists($FileName)){
$CSV = Import-CSV -Path $FileName
if ($FormData[0].SamAccountName -in $CSV.SamAccountName){
'DISPLAY MESSAGE HERE'
return $false
}
$FormData[0] | Export-Csv -Path $FileName -NoTypeInformation -Encoding UTF8 -Append
}
else{
$FormData[0] | Export-Csv -Path $FileName -NoTypeInformation -Encoding UTF8
}
The only way I can think of how to do this would be to do $true
or $false
check, and do something like this on the dashboard,
$Validation = Invoke-PSUScript 'CSV_Populator.ps1' FormData $EventData -Integrated -Wait
if ($Validation -eq $false){
"DISPLAY SOMETHING HERE"
}
There has to be a cleaner way to do this. Would anyone be able to provide insight on this for me? Thank you, and your help is greatly appreciated.
Throwing up a hailmary for a quick fix and tagging @adam