Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Blog: Creates a launchd job that updates the AWS PowerShell .NET Core module on a daily basis.
This PowerShell script will create and register a new launchd job that keeps the AWSPowerShell.NetCore module
up-to-date on your MacOS system.
If you receive an error upon registration, it's probably just because the service doesn't already exist.
This script tries to unload and reload the service, whether or not it exists, hence the error on initial run.
$PListFile = @'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<string>Install-Module -Name AWSPowerShell.NetCore -Scope CurrentUser -Force</string>
$Params = @{
Path = '~/Library/LaunchAgents/update.awspowershell.plist'
Value = $PListFile
Set-Content @Params
launchctl unload $Params.Path
Write-Host -Object 'Deregistering service'
launchctl load $Params.Path
Write-Host -Object 'Registering service'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment