Workflow Notification - Capture PowerShell error

Hi Team. 

I have a Workflow that is running a Powershell script and then when its done it sends off a notification rule. 

Is it possible at all to capture parts of the Output to use in the eMail notification? I would like to send an email to the person running the Workflow so they can see that 

The PnP Teams site exists with the given display name or mail nickname.

if ((Get-PnpTeamsTeam -Filter "DisplayName eq '$TeamName'" -ErrorAction SilentlyContinue) -or (Get-PnpTeamsTeam -Filter "MailNickname eq '$TeamNickName'" -ErrorAction SilentlyContinue))
{
    Write-Output "The PnP Teams site exists with the given display name or mail nickname." | Out-File $logfile -Append
}
else
{


try
{
New-PnPTeamsTeam @TeamsProperties | Out-File $logfile -Append
}
catch
{

# Write a message into the AR Server event log

$EventLog.ReportEvent($Constants.EDS_EVENTLOG_WARNING_TYPE, ("Problem with New-PnPTeamsTeam" + $Error[0]))
}

}
}

Top Replies

Parents
  • Hi  

    Yes it's possible, as an example I created a change workflow ("Email something") triggered on the modification of some attribute on a user object.

    My workflow has 3 steps on pre operation

    1) Modify Requested Changed - This activity step sets the value of AdminDescription based on the output from a script

    2) Notification - This activity step send an email to me, which has the value of AdminDescription

    3) Modify Requested Changed - This activity step clears the value of AdminDescription, this could be removed if you either use a non-store VA or you want to retain the value in the user object and change history

    My script is not doing anything particularly interesting other than getting a list of Services starting App on the ARS server, joining them together with a "; ", removing a trailing  " " (granted I could have just trimmed), then returning the value back to the attribute to be set.

    When testing I get an email like the below

Reply
  • Hi  

    Yes it's possible, as an example I created a change workflow ("Email something") triggered on the modification of some attribute on a user object.

    My workflow has 3 steps on pre operation

    1) Modify Requested Changed - This activity step sets the value of AdminDescription based on the output from a script

    2) Notification - This activity step send an email to me, which has the value of AdminDescription

    3) Modify Requested Changed - This activity step clears the value of AdminDescription, this could be removed if you either use a non-store VA or you want to retain the value in the user object and change history

    My script is not doing anything particularly interesting other than getting a list of Services starting App on the ARS server, joining them together with a "; ", removing a trailing  " " (granted I could have just trimmed), then returning the value back to the attribute to be set.

    When testing I get an email like the below

Children
No Data