Quantcast
Channel: Configuration Manager 2012 - Application Management forum
Viewing all articles
Browse latest Browse all 4762

PowerShell based package / program- how to return "failure"

$
0
0

I've created a package that periodically runs robocopy via a PowerShell script to keep a few files up to date (things like custom powershell modules) on workstations. However, I accidentally forgot to update a file some time ago and it has not worked since. I picked this up and found that the log files have errors every time it runs, but reports "success".

This is understandable as I hadn't actually written code to handle errors for some reason.  So, I wrote a section in the PowerShell script that now throws an error if Robocopy returns an unfavourable error code.

However, even if the code is executed (i.e. an error thrown), the package still states that it was installed!

What I'm hoping for is for some way that I can tell the agent on the workstation that the package failed installation.  I don't need to diagnose at this point, just that a failure happened. I know packages can't use error codes, but isn't there a way that the PowerShell script can return a failure to the agent?


Viewing all articles
Browse latest Browse all 4762


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