Documentation
Audit sans déploiement
Inventaire des extensions par MDM
Lister les extensions d'un parc Windows, macOS ou Linux avec un script poussé par le MDM.
Le MDM exécute un script sur chaque poste. Le script relève les identifiants des extensions de chaque utilisateur du poste. Il affiche une seule ligne : chaque identifiant suivi de son nombre d'utilisateurs sur le poste. Le MDM conserve cette ligne pour chaque poste.
Exemple de résultat pour un poste :
aapbdbdomjkkjkaonfhkkikfgjllcleb:2 uBlock0@raymondhill.net:1
aapbdbdomjkkjkaonfhkkikfgjllcleb:2 uBlock0@raymondhill.net:1
aapbdbdomjkkjkaonfhkkikfgjllcleb:2 uBlock0@raymondhill.net:1
aapbdbdomjkkjkaonfhkkikfgjllcleb:2 uBlock0@raymondhill.net:1
Les scripts ci-dessous sont un exemple : ils couvrent Chrome, Edge, Brave et Firefox. Le périmètre de l'audit se définit avec l'équipe Ostral.
Les scripts lisent seulement les noms des dossiers d'extensions des navigateurs. Ils n'ouvrent aucun fichier, ne modifient rien et ne contactent aucun serveur. Le résultat ne contient aucun nom d'utilisateur.
1. Pousser le script
Le script s'exécute avec les droits administrateur (Windows) ou root (macOS, Linux), le mode habituel des scripts de MDM.
MDM | Où ajouter le script | Où lire le résultat |
|---|---|---|
Microsoft Intune | Appareils > Scripts et corrections, onglet Corrections : créer un package avec le script Windows comme script de détection. Exécution en contexte système, dans PowerShell 64 bits | La sortie de la détection, poste par poste, exportable |
Jamf Pro | Paramètres > Gestion des ordinateurs > Attributs d'extension : créer un attribut de type script, avec le script macOS | Une recherche avancée d'ordinateurs qui affiche cet attribut, exportable en CSV |
Iru, Mosyle, Workspace ONE ou autre MDM | Un script personnalisé, exécuté en administrateur ou en root | Le rapport de sortie du script |
Intune conserve jusqu'à 2 048 caractères de sortie par poste, soit une cinquantaine d'extensions.
2. Envoyer le résultat
Attendre que les postes aient exécuté le script, en général sous 24 heures.
Exporter le rapport du MDM.
Envoyer le fichier à contact@ostral.ai. La colonne des noms de postes peut être retirée avant l'envoi.
Ostral additionne les résultats de tous les postes.
Windows
# Inventaire-Extensions-Windows.ps1 # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the computer. Prints a single line: each ID followed by its number of users on # the computer, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # computer and contacts no server. # Run it with administrator rights (system context of the MDM). #Requires -Version 5.1 $ErrorActionPreference = 'Stop' $counts = @{} foreach ($user in Get-ChildItem -Path "$env:SystemDrive\Users" -Directory -ErrorAction SilentlyContinue) { $local = Join-Path $user.FullName 'AppData\Local' $roaming = Join-Path $user.FullName 'AppData\Roaming' # Chrome, Edge and Brave: one folder per extension, named after its ID. $chromium = Get-Item -ErrorAction SilentlyContinue -Path @( "$local\Google\Chrome\User Data\*\Extensions\*" "$local\Microsoft\Edge\User Data\*\Extensions\*" "$local\BraveSoftware\Brave-Browser\User Data\*\Extensions\*" ) | Where-Object { $_.PSIsContainer -and $_.Name -match '^[a-p]{32}$' } | ForEach-Object { $_.Name } # Firefox: one <ID>.xpi file per extension. $firefox = Get-Item -ErrorAction SilentlyContinue -Path "$roaming\Mozilla\Firefox\Profiles\*\extensions\*.xpi" | ForEach-Object { $_.BaseName } foreach ($id in @(@($chromium) + @($firefox) | Where-Object { $_ } | Sort-Object -Unique)) { $counts[$id] = 1 + $counts[$id] } } # Result on one line, read by the MDM. ($counts.GetEnumerator() | Sort-Object Name | ForEach-Object { '{0}:{1}' -f $_.Name, $_.Value }) -join ' ' exit 0
# Inventaire-Extensions-Windows.ps1 # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the computer. Prints a single line: each ID followed by its number of users on # the computer, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # computer and contacts no server. # Run it with administrator rights (system context of the MDM). #Requires -Version 5.1 $ErrorActionPreference = 'Stop' $counts = @{} foreach ($user in Get-ChildItem -Path "$env:SystemDrive\Users" -Directory -ErrorAction SilentlyContinue) { $local = Join-Path $user.FullName 'AppData\Local' $roaming = Join-Path $user.FullName 'AppData\Roaming' # Chrome, Edge and Brave: one folder per extension, named after its ID. $chromium = Get-Item -ErrorAction SilentlyContinue -Path @( "$local\Google\Chrome\User Data\*\Extensions\*" "$local\Microsoft\Edge\User Data\*\Extensions\*" "$local\BraveSoftware\Brave-Browser\User Data\*\Extensions\*" ) | Where-Object { $_.PSIsContainer -and $_.Name -match '^[a-p]{32}$' } | ForEach-Object { $_.Name } # Firefox: one <ID>.xpi file per extension. $firefox = Get-Item -ErrorAction SilentlyContinue -Path "$roaming\Mozilla\Firefox\Profiles\*\extensions\*.xpi" | ForEach-Object { $_.BaseName } foreach ($id in @(@($chromium) + @($firefox) | Where-Object { $_ } | Sort-Object -Unique)) { $counts[$id] = 1 + $counts[$id] } } # Result on one line, read by the MDM. ($counts.GetEnumerator() | Sort-Object Name | ForEach-Object { '{0}:{1}' -f $_.Name, $_.Value }) -join ' ' exit 0
# Inventaire-Extensions-Windows.ps1 # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the computer. Prints a single line: each ID followed by its number of users on # the computer, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # computer and contacts no server. # Run it with administrator rights (system context of the MDM). #Requires -Version 5.1 $ErrorActionPreference = 'Stop' $counts = @{} foreach ($user in Get-ChildItem -Path "$env:SystemDrive\Users" -Directory -ErrorAction SilentlyContinue) { $local = Join-Path $user.FullName 'AppData\Local' $roaming = Join-Path $user.FullName 'AppData\Roaming' # Chrome, Edge and Brave: one folder per extension, named after its ID. $chromium = Get-Item -ErrorAction SilentlyContinue -Path @( "$local\Google\Chrome\User Data\*\Extensions\*" "$local\Microsoft\Edge\User Data\*\Extensions\*" "$local\BraveSoftware\Brave-Browser\User Data\*\Extensions\*" ) | Where-Object { $_.PSIsContainer -and $_.Name -match '^[a-p]{32}$' } | ForEach-Object { $_.Name } # Firefox: one <ID>.xpi file per extension. $firefox = Get-Item -ErrorAction SilentlyContinue -Path "$roaming\Mozilla\Firefox\Profiles\*\extensions\*.xpi" | ForEach-Object { $_.BaseName } foreach ($id in @(@($chromium) + @($firefox) | Where-Object { $_ } | Sort-Object -Unique)) { $counts[$id] = 1 + $counts[$id] } } # Result on one line, read by the MDM. ($counts.GetEnumerator() | Sort-Object Name | ForEach-Object { '{0}:{1}' -f $_.Name, $_.Value }) -join ' ' exit 0
# Inventaire-Extensions-Windows.ps1 # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the computer. Prints a single line: each ID followed by its number of users on # the computer, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # computer and contacts no server. # Run it with administrator rights (system context of the MDM). #Requires -Version 5.1 $ErrorActionPreference = 'Stop' $counts = @{} foreach ($user in Get-ChildItem -Path "$env:SystemDrive\Users" -Directory -ErrorAction SilentlyContinue) { $local = Join-Path $user.FullName 'AppData\Local' $roaming = Join-Path $user.FullName 'AppData\Roaming' # Chrome, Edge and Brave: one folder per extension, named after its ID. $chromium = Get-Item -ErrorAction SilentlyContinue -Path @( "$local\Google\Chrome\User Data\*\Extensions\*" "$local\Microsoft\Edge\User Data\*\Extensions\*" "$local\BraveSoftware\Brave-Browser\User Data\*\Extensions\*" ) | Where-Object { $_.PSIsContainer -and $_.Name -match '^[a-p]{32}$' } | ForEach-Object { $_.Name } # Firefox: one <ID>.xpi file per extension. $firefox = Get-Item -ErrorAction SilentlyContinue -Path "$roaming\Mozilla\Firefox\Profiles\*\extensions\*.xpi" | ForEach-Object { $_.BaseName } foreach ($id in @(@($chromium) + @($firefox) | Where-Object { $_ } | Sort-Object -Unique)) { $counts[$id] = 1 + $counts[$id] } } # Result on one line, read by the MDM. ($counts.GetEnumerator() | Sort-Object Name | ForEach-Object { '{0}:{1}' -f $_.Name, $_.Value }) -join ' ' exit 0
macOS
#!/bin/bash # # Inventaire-Extensions-macOS.sh # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the Mac. Prints a single line: each ID followed by its number of users on the # Mac, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # Mac and contacts no server. # Run it as root (MDM context). all="" for home in /Users/*; do app="$home/Library/Application Support" [ -d "$app" ] || continue ids=$( # Chrome, Edge and Brave: one folder per extension, named after its ID. for dir in "$app/Google/Chrome"/*/Extensions/* \ "$app/Microsoft Edge"/*/Extensions/* \ "$app/BraveSoftware/Brave-Browser"/*/Extensions/*; do [ -d "$dir" ] && basename "$dir" done | grep -E '^[a-p]{32}$' # Firefox: one <ID>.xpi file per extension. for file in "$app/Firefox/Profiles"/*/extensions/*.xpi; do [ -f "$file" ] && basename "$file" .xpi done ) all="$all$(printf '%s\n' "$ids" | sort -u)"$'\n' done # Result on one line, in the format Jamf expects for an extension attribute. # Other MDMs show the same line. result=$(printf '%s' "$all" | grep -v '^$' | sort | uniq -c | awk '{ printf "%s:%s ", $2, $1 }') echo "<result>${result% }</result>" exit 0
#!/bin/bash # # Inventaire-Extensions-macOS.sh # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the Mac. Prints a single line: each ID followed by its number of users on the # Mac, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # Mac and contacts no server. # Run it as root (MDM context). all="" for home in /Users/*; do app="$home/Library/Application Support" [ -d "$app" ] || continue ids=$( # Chrome, Edge and Brave: one folder per extension, named after its ID. for dir in "$app/Google/Chrome"/*/Extensions/* \ "$app/Microsoft Edge"/*/Extensions/* \ "$app/BraveSoftware/Brave-Browser"/*/Extensions/*; do [ -d "$dir" ] && basename "$dir" done | grep -E '^[a-p]{32}$' # Firefox: one <ID>.xpi file per extension. for file in "$app/Firefox/Profiles"/*/extensions/*.xpi; do [ -f "$file" ] && basename "$file" .xpi done ) all="$all$(printf '%s\n' "$ids" | sort -u)"$'\n' done # Result on one line, in the format Jamf expects for an extension attribute. # Other MDMs show the same line. result=$(printf '%s' "$all" | grep -v '^$' | sort | uniq -c | awk '{ printf "%s:%s ", $2, $1 }') echo "<result>${result% }</result>" exit 0
#!/bin/bash # # Inventaire-Extensions-macOS.sh # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the Mac. Prints a single line: each ID followed by its number of users on the # Mac, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # Mac and contacts no server. # Run it as root (MDM context). all="" for home in /Users/*; do app="$home/Library/Application Support" [ -d "$app" ] || continue ids=$( # Chrome, Edge and Brave: one folder per extension, named after its ID. for dir in "$app/Google/Chrome"/*/Extensions/* \ "$app/Microsoft Edge"/*/Extensions/* \ "$app/BraveSoftware/Brave-Browser"/*/Extensions/*; do [ -d "$dir" ] && basename "$dir" done | grep -E '^[a-p]{32}$' # Firefox: one <ID>.xpi file per extension. for file in "$app/Firefox/Profiles"/*/extensions/*.xpi; do [ -f "$file" ] && basename "$file" .xpi done ) all="$all$(printf '%s\n' "$ids" | sort -u)"$'\n' done # Result on one line, in the format Jamf expects for an extension attribute. # Other MDMs show the same line. result=$(printf '%s' "$all" | grep -v '^$' | sort | uniq -c | awk '{ printf "%s:%s ", $2, $1 }') echo "<result>${result% }</result>" exit 0
#!/bin/bash # # Inventaire-Extensions-macOS.sh # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the Mac. Prints a single line: each ID followed by its number of users on the # Mac, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # Mac and contacts no server. # Run it as root (MDM context). all="" for home in /Users/*; do app="$home/Library/Application Support" [ -d "$app" ] || continue ids=$( # Chrome, Edge and Brave: one folder per extension, named after its ID. for dir in "$app/Google/Chrome"/*/Extensions/* \ "$app/Microsoft Edge"/*/Extensions/* \ "$app/BraveSoftware/Brave-Browser"/*/Extensions/*; do [ -d "$dir" ] && basename "$dir" done | grep -E '^[a-p]{32}$' # Firefox: one <ID>.xpi file per extension. for file in "$app/Firefox/Profiles"/*/extensions/*.xpi; do [ -f "$file" ] && basename "$file" .xpi done ) all="$all$(printf '%s\n' "$ids" | sort -u)"$'\n' done # Result on one line, in the format Jamf expects for an extension attribute. # Other MDMs show the same line. result=$(printf '%s' "$all" | grep -v '^$' | sort | uniq -c | awk '{ printf "%s:%s ", $2, $1 }') echo "<result>${result% }</result>" exit 0
Linux
#!/bin/bash # # Inventaire-Extensions-Linux.sh # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the computer. Prints a single line: each ID followed by its number of users on # the computer, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # computer and contacts no server. # Run it as root (context of the MDM or management tool). all="" for home in /home/*; do [ -d "$home" ] || continue ids=$( # Chrome, Edge and Brave: one folder per extension, named after its ID. for dir in "$home/.config/google-chrome"/*/Extensions/* \ "$home/.config/microsoft-edge"/*/Extensions/* \ "$home/.config/BraveSoftware/Brave-Browser"/*/Extensions/*; do [ -d "$dir" ] && basename "$dir" done | grep -E '^[a-p]{32}$' # Firefox, standard or Snap install: one <ID>.xpi file per extension. for file in "$home/.mozilla/firefox"/*/extensions/*.xpi \ "$home/snap/firefox/common/.mozilla/firefox"/*/extensions/*.xpi; do [ -f "$file" ] && basename "$file" .xpi done ) all="$all$(printf '%s\n' "$ids" | sort -u)"$'\n' done # Result on one line, read by the management tool. result=$(printf '%s' "$all" | grep -v '^$' | sort | uniq -c | awk '{ printf "%s:%s ", $2, $1 }') echo "${result% }" exit 0
#!/bin/bash # # Inventaire-Extensions-Linux.sh # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the computer. Prints a single line: each ID followed by its number of users on # the computer, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # computer and contacts no server. # Run it as root (context of the MDM or management tool). all="" for home in /home/*; do [ -d "$home" ] || continue ids=$( # Chrome, Edge and Brave: one folder per extension, named after its ID. for dir in "$home/.config/google-chrome"/*/Extensions/* \ "$home/.config/microsoft-edge"/*/Extensions/* \ "$home/.config/BraveSoftware/Brave-Browser"/*/Extensions/*; do [ -d "$dir" ] && basename "$dir" done | grep -E '^[a-p]{32}$' # Firefox, standard or Snap install: one <ID>.xpi file per extension. for file in "$home/.mozilla/firefox"/*/extensions/*.xpi \ "$home/snap/firefox/common/.mozilla/firefox"/*/extensions/*.xpi; do [ -f "$file" ] && basename "$file" .xpi done ) all="$all$(printf '%s\n' "$ids" | sort -u)"$'\n' done # Result on one line, read by the management tool. result=$(printf '%s' "$all" | grep -v '^$' | sort | uniq -c | awk '{ printf "%s:%s ", $2, $1 }') echo "${result% }" exit 0
#!/bin/bash # # Inventaire-Extensions-Linux.sh # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the computer. Prints a single line: each ID followed by its number of users on # the computer, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # computer and contacts no server. # Run it as root (context of the MDM or management tool). all="" for home in /home/*; do [ -d "$home" ] || continue ids=$( # Chrome, Edge and Brave: one folder per extension, named after its ID. for dir in "$home/.config/google-chrome"/*/Extensions/* \ "$home/.config/microsoft-edge"/*/Extensions/* \ "$home/.config/BraveSoftware/Brave-Browser"/*/Extensions/*; do [ -d "$dir" ] && basename "$dir" done | grep -E '^[a-p]{32}$' # Firefox, standard or Snap install: one <ID>.xpi file per extension. for file in "$home/.mozilla/firefox"/*/extensions/*.xpi \ "$home/snap/firefox/common/.mozilla/firefox"/*/extensions/*.xpi; do [ -f "$file" ] && basename "$file" .xpi done ) all="$all$(printf '%s\n' "$ids" | sort -u)"$'\n' done # Result on one line, read by the management tool. result=$(printf '%s' "$all" | grep -v '^$' | sort | uniq -c | awk '{ printf "%s:%s ", $2, $1 }') echo "${result% }" exit 0
#!/bin/bash # # Inventaire-Extensions-Linux.sh # # Lists the IDs of the extensions installed in Chrome, Edge, Brave and Firefox for every # user of the computer. Prints a single line: each ID followed by its number of users on # the computer, for example "<ID>:2". # # The script only reads folder and file names. It opens no file, changes nothing on the # computer and contacts no server. # Run it as root (context of the MDM or management tool). all="" for home in /home/*; do [ -d "$home" ] || continue ids=$( # Chrome, Edge and Brave: one folder per extension, named after its ID. for dir in "$home/.config/google-chrome"/*/Extensions/* \ "$home/.config/microsoft-edge"/*/Extensions/* \ "$home/.config/BraveSoftware/Brave-Browser"/*/Extensions/*; do [ -d "$dir" ] && basename "$dir" done | grep -E '^[a-p]{32}$' # Firefox, standard or Snap install: one <ID>.xpi file per extension. for file in "$home/.mozilla/firefox"/*/extensions/*.xpi \ "$home/snap/firefox/common/.mozilla/firefox"/*/extensions/*.xpi; do [ -f "$file" ] && basename "$file" .xpi done ) all="$all$(printf '%s\n' "$ids" | sort -u)"$'\n' done # Result on one line, read by the management tool. result=$(printf '%s' "$all" | grep -v '^$' | sort | uniq -c | awk '{ printf "%s:%s ", $2, $1 }') echo "${result% }" exit 0