Script doesn't run via Policy

New Contributor III

I have a script that only runs locally - not via policy. Can anyone tell me what I'm doing wrong?


loggedInUser=$(ls -l /dev/console | awk '{print $3}')

defaults write /Users/$loggedInUser/Library/Preferences/ HowToCheck "Manual"

New Contributor III

If you want to enforce the manual check for office updates you can try a custom configuration profile.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Valued Contributor III

How are you invoking the policy? If it runs when no one is logged in it will do nothing as $loggedInUser will be empty.
If your running it as Login or Self Service you can use $3 directly as this will contain the username that either logged in or signed into Self Service. Outside of that contect you need to ensure that there is someone logged in.