microsoft / shell-intune-samples

Sample shell scripts for Intune admins.
MIT License
684 stars 222 forks source link

Syntax error when running downgradeUsertoStandard.sh #94

Closed mladminsmac closed 8 months ago

mladminsmac commented 1 year ago

Before importing the script into InTune I tried running downgradeUsertoStandard.sh directly on a test Mac. After running I get the following in the log file:

##############################################################
# Fri Apr  7 12:45:29 EDT 2023 | Starting Downgrade Admin Users to Standard
############################################################

Checking MDM Profile Type
Enrolled via DEP: Yes
Device is ABM Managed
DemoteAccounts.sh: line 80: syntax error near unexpected token `<'
DemoteAccounts.sh: line 80: `  done < <(dscl . list /Users UniqueID | awk '$2 >= 501 {print $1}')'

I've not been able to figure out what this syntax error is. Does this script only work when run through InTune?

theneiljohnson commented 11 months ago

Should work without Intune. I'll take a better look next week and see if I can figure out whats going on. I wrote these against macOS 11.x so a lot has changed.

ajishab commented 8 months ago

any updates here, this script shows as successful for me every time but users still remain admin

theneiljohnson commented 8 months ago

The script seemed to run fine for me, You need to modify the script to remove a # which comments out dseditgroup. This makes sure you've read the script before deploying since it's potentially very disruptive.

I've just re-written in ZSH and improved the logging.

Give it a try.