Nudge has the same issue. I think we have it on th...
# macos
Nudge has the same issue. I think we have it on the backlog to find a way to add variables to policies and then find a way to provide this info but it hasn’t been prioritized so far
We have something like the following in a github action for Nudge
Copy code
import requests
import urllib3
import tzlocal
import json
import datetime

# Read the file nudge.json and return the JSON object
def read_json_file(file_name):
    with open(file_name) as json_file:
        return json.load(json_file)

# Get latest macOS version from <>
def get_latest_macos_version():
    url = "<>"
    # disable the
    response = requests.get(url, verify=False)
    products = response.json()["PublicAssetSets"]["macOS"]
    lastest_version = 0
    # if the version is two dots long make it three by adding a zero to the end
    # version is a string in the key ProductVersion which needs converting to a float
    for product in products:
        version = product["ProductVersion"]
        if len(version.split(".")) == 2:
            version = version + ".0"
        version = int(version.replace(".", ""))
        if version > lastest_version:
            lastest_version = version
    return lastest_version

# Convert to macOS version string and let's hope there is not a 12.10.0
def convert_int_to_version_string(version):
    version = str(version)
    version = version[0:2] + "." + version[2:3] + "." + version[3:4]
    return version

def main():
    # This should ideally be a command line argument for a file name.
    nudge_data = read_json_file("nudge.json")
    nudge_current_version = nudge_data["osVersionRequirements"][0][
    latestMacOSUpdate = get_latest_macos_version()
    # if the nudge_current_version is less than the latestMacOSUpdate then update the nudge.json file and make the nudge_instalL_date 30 days from now the date format is ISO-8601
    if int(nudge_current_version.replace(".", "")) < latestMacOSUpdate:
            "requiredMinimumOSVersion"] = convert_int_to_version_string(
        # make the required installation date 30 days from time now
            "requiredInstallationDate"] = str(
                tzlocal.get_localzone().localize( +

        with open("nudge.json", "w") as json_file:
            json.dump(nudge_data, json_file, indent=4)

if __name__ == "__main__":
let's hope there is not a 12.10.0
(I mean history says that's a pretty safe bet, but