Skip to content

liquidz00/pymdm

Repository files navigation

pymdm

A Python utility package for macOS MDM deployment scripts, built for MacAdmins Python (#!/usr/local/bin/managed_python3) and Jamf Pro workflows. Windows/Intune support is included for teams managing mixed-platform fleets.

📖 Full documentation →

What's Included

Feature macOS (Jamf) Windows (Intune)
JamfParamParser Yes --
IntuneParamParser -- Yes
GenericParamParser Yes Yes
Dialog (swiftDialog) Yes Graceful no-op
CommandRunner Yes Yes
TextTools Yes Yes
SystemInfo Yes Yes
MdmLogger Yes Yes
WebhookSender Yes Yes
DarwinDefaults Yes --
DarwinServiceManager Yes --
Win32Registry -- Yes
Win32ServiceManager -- Yes

See the User Guide for what each piece does.

Note

Windows/Intune support is experimental. The Windows code paths are unit-tested but have not yet been validated on real Windows hardware. Treat them as a starting point rather than a guarantee. Bug reports and contributions from Windows/Intune admins are very welcome.

Installation

pip install pymdm[requests]

requests is an optional extra because the primary target, MacAdmins managed_python3, already bundles it, so a plain pip install pymdm is enough there. The uv, source, and fleet-deployment paths are in the installation guide.

Quick Example (macOS / Jamf Pro)

#!/usr/local/bin/managed_python3
"""Example Jamf Pro policy script."""

from pymdm import MdmLogger, CommandRunner, SystemInfo, WebhookSender
from pymdm.mdm import get_provider

params = get_provider("jamf")    # explicit; get_provider() now defaults to GenericParamParser
logger = MdmLogger(debug=params.get_bool(4), output_path="/var/log/my_script.log")
runner = CommandRunner(logger=logger)
logger.log_startup("my_script", version="1.0.0")

try:
    serial = SystemInfo.get_serial_number()
    hostname = SystemInfo.get_hostname()
    logger.info(f"Running on {hostname} ({serial})")

    output = runner.run(["/usr/bin/sw_vers", "-productVersion"])
    logger.info(f"macOS version: {output}")

    webhook = WebhookSender(url=params.get(5), logger=logger)
    webhook.send(hostname=hostname, serial=serial, status="success")
except Exception as e:
    logger.log_exception("Script failed", e, exit_code=1)

Windows/Intune, platform helpers, and per-module usage live in the Quick Start.

Development

git clone https://github.com/liquidz00/pymdm.git
cd pymdm
make install-dev   # dev dependencies (includes docs tooling)
make test
make format
make help          # list every target

See CONTRIBUTING to get started, and the CHANGELOG for release notes and version migration steps.

Requirements

License

Apache 2.0

About

Python utility functions for MDM scripts

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors