How to change desktop background in OS X through Desired Configuration Management

19 users found this article helpful

Information

To change the desktop background in OS X through Desired Configuration Management, you can create a script with appropriate instructions and include it in a configuration item that will be used to evaluate Macs for compliance.

Update: For macOS Mojave, Catalina and new please follow this KB article.

Note: This article does not provide details about setting up and using Desired Configuration Management. For the complete information about creating configuration items and evaluation scripts, please read Parallels Mac Management for Microsoft SCCM Administrator’s Guide.

Follow the instructions provided in the guide (see link above) and open the Create Configuration Item Wizard. When specifying the settings on the Create Setting dialog, create a discovery script as follows:

  1. In the Setting type list box, select Script.
  2. In the Data type list box, select String.
  3. In the Discovery script section, click Add Script.
  4. In the Edit Discovery Script dialog, copy and paste the following script in the Script edit box (change the value of the WALLPAPER_PATH variable to contain a path to your image file):

    WALLPAPER_PATH="/Library/Desktop Pictures/Snow.jpg"
    
    CONSOLE_USER=$(ls -la /dev/console | awk '{print $3}')
    if [[ ${CONSOLE_USER} == "root" ]]; then
        exit 0 # Silently exit if there is no console user
    fi
    
    if [[ ! -f ${WALLPAPER_PATH} ]]; then
        echo "No such file: ${WALLPAPER_PATH}" 1>&2
        exit 2
    fi
    
    sudo -u $CONSOLE_USER /usr/bin/osascript -e "tell application \"System Events\" to set picture of every desktop to \"${WALLPAPER_PATH}\""
    EXIT_CODE=$(echo $?)
    
    if [[ ${EXIT_CODE} != 0 ]]; then 
        exit ${EXIT_CODE}
    fi
    
    echo "OK"
    exit 0
    

When done adding the script, click OK to close the Edit Discovery Script dialog.

You now need to create a compliance rule using the following steps:

  1. Click the Compliance Rules tab in the Create Setting dialog.
  2. Click New to open the Create Rule dialog.
  3. Type in the rule name and an optional description.
  4. In the Rule type list box, select Value.
  5. In The value returned by the specified script list box, select Equals.
  6. In the following values edit box, type “OK” (without quotes).

Complete the Create Configuration Item as described in the Parallels Mac Management for Microsoft SCCM Administrator’s Guide.

Was this article helpful?

Tell us how we can improve it.