# Abort backup if not if computer not in location x

**URL:** https://forum.duplicati.com/t/abort-backup-if-not-if-computer-not-in-location-x/13585
**Category:** How-To
**Created:** [December 14, 2021, 11:45pm UTC](https://forum.duplicati.com/t/abort-backup-if-not-if-computer-not-in-location-x/13585 "2021-12-14T23:45:12Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [December 15, 2021, 12:09am UTC](https://forum.duplicati.com/t/abort-backup-if-not-if-computer-not-in-location-x/13585/4 "2021-12-15T00:09:13Z")

</div>

I’m pretty sure you need to use “exit” instead of “return” in a PowerShell script to set the errorlevel. How you use “return” in your script probably just outputs the numeric value to the screen, which isn’t the same thing.

Also you should set the errorlevel to 1 if you want Duplicati to not run the backup and not produce a warning or error message. (See [this post](https://forum.duplicati.com/t/improvements-for-run-script-before-after-options/519) for more info on that.)

Set --run-script-before to be the full path to your PowerShell script, including the .ps1 extension.

---

_[View the full topic](https://forum.duplicati.com/t/abort-backup-if-not-if-computer-not-in-location-x/13585)._
