A Python script to sync Microsoft Intune managed devices into Snipe-IT, with the ability to filter by device platform and Azure AD group membership.
- Fetch Intune managed devices via Microsoft Graph API
- Filter devices by Azure AD group membership (to sync only devices you're responsible for)
- Normalize Android-Enterprise UPNs
- Auto-create Snipe-IT categories, manufacturers, and models
- Import devices into Snipe-IT with correct
manufacturer_id,model_id,category_id, and status label - Check out assets to existing Snipe-IT users
--dry-runmode to preview actions without writing--platformflag to limit sync to one of:windows,android,ios,macos, orall--groupsflag orAZURE_GROUP_IDSenvironment variable to filter by group membership
- Python 3.7+
- Azure AD App Registration with Application permissions:
DeviceManagementManagedDevices.Read.AllGroup.Read.All(required if using group filtering)User.Read.All(if user info is fetched)
- Snipe-IT API credentials with write access
- Clone this repository:
git clone https://github.com/yourorg/intune-snipe-sync.git cd intune-snipe-sync - Install dependencies:
Or install manually:
pip install -r requirements.txt
pip install msal requests
Set environment variables (or add to .env):
export AZURE_TENANT_ID="<your-tenant-guid>"
export AZURE_CLIENT_ID="<your-client-id>"
export AZURE_CLIENT_SECRET="<your-client-secret>"
export SNIPEIT_URL="https://my-snipeit.example.com/api/v1"
export SNIPEIT_API_TOKEN="<your-snipeit-api-token>"
export SNIPEIT_DEFAULT_STATUS="Ready to Deploy"
# Optional: Filter devices by Azure AD group membership (comma-separated group object IDs)
export AZURE_GROUP_IDS="<group-id-1>,<group-id-2>"Preview actions without writing to Snipe-IT:
python3 app.py --dry-run --platform windowsSync devices (all platforms by default):
python3 app.pySync only Android devices:
python3 app.py --platform androidTo sync only devices that are members of specific Azure AD groups (useful when your organization is part of a larger tenant):
Using environment variable:
export AZURE_GROUP_IDS="<group-object-id-1>,<group-object-id-2>"
python3 app.py --platform windowsUsing command-line argument:
python3 app.py --platform windows --groups "<group-object-id-1>,<group-object-id-2>"Find your group object IDs:
- In Azure Portal: Azure Active Directory → Groups → Select your group → Overview → Object ID
- Or use:
az ad group list --display-name "Your Group Name" --query "[].id"
Note: Group filtering requires devices to be Azure AD registered/joined. Devices that are only Intune-managed without Azure AD registration will not be matched.
This project includes a Dockerfile and Kubernetes manifest (k8s/cronjob.yaml) that you can use to automate the sync process. It's recommended to test the script directly using Python first, and once you've verified it works correctly, deploy it using Docker or Kubernetes.
Build and run the Docker container:
# Build the image
docker build -t intune2snipe:latest .
# Run the container
docker run --rm \
-e AZURE_TENANT_ID="<your-tenant-id>" \
-e AZURE_CLIENT_ID="<your-client-id>" \
-e AZURE_CLIENT_SECRET="<your-client-secret>" \
-e SNIPEIT_URL="<your-snipeit-url>" \
-e SNIPEIT_API_TOKEN="<your-token>" \
intune2snipe:latest \
--platform windows --dry-runThe Kubernetes manifest includes a CronJob that runs the sync on a schedule (default: daily at 2:00 AM UTC).
-
Edit the Kubernetes manifest (
k8s/cronjob.yaml):- Update the Secret values with your actual credentials
- Update the image name to match your container registry
- Customize the schedule if needed (cron format)
- Adjust resource limits if necessary
-
Apply the manifest:
kubectl apply -f k8s/cronjob.yaml
-
Check the CronJob status:
kubectl get cronjob intune2snipe-sync kubectl get jobs -l app=intune2snipe-sync
The repository includes a GitHub Actions workflow (.github/workflows/docker-build.yml) that automatically builds and pushes Docker images to GitHub Container Registry (ghcr.io) on push to main/master branches. Update the image name in the Kubernetes manifest to match your repository path.
- Fetch Azure AD device IDs from specified groups (if
--groupsorAZURE_GROUP_IDSis set). - Fetch Intune managed devices via Graph API (filtering by
--platformand optionally by group membership). - Ensure Snipe-IT has an
Intunecategory, the default status label exists, and models/manufacturers are created. - Create hardware assets in Snipe-IT and check them out to users if assigned.
- 403 Forbidden: Ensure your Azure AD app has appropriate Graph permissions and admin consent. If using group filtering, ensure
Group.Read.Allpermission is granted. - No devices found in groups: Verify the group object IDs are correct and that devices are actually members of those groups in Azure AD.
- Missing fields: Verify your Snipe-IT instance has categories, models, and status labels enabled.
- Status label not found: Check
SNIPEIT_DEFAULT_STATUSmatches exactly an existing label. - Group filtering not working: Ensure devices are Azure AD registered/joined (not just Intune-managed). The script matches devices using their Azure AD device object ID.
Feel free to open issues or submit PRs.