La gestion des extensions de navigateur pour plusieurs utilisateurs et systèmes est un challenge courant dans la gestion informatique. Les extensions de navigateur, bien qu’utiles, peuvent présenter des risques importants pour la sécurité si elles ne sont pas contrôlées correctement. Elles peuvent introduire des vulnérabilités, espionner les activités des utilisateurs ou devenir des points d’entrée pour les logiciels malveillants.
Ce script offre une solution optimale aux professionnels de l’informatique et aux fournisseurs de services gérés (MSP) pour obtenir l’inventaire des extensions de navigateur installées dans les navigateurs tels que Chrome, Firefox et Edge.
Contexte
Comme les entreprises s’appuient de plus en plus sur des applications basées sur le web, les extensions de navigateur jouent un rôle de plus en plus important. Cependant, cela augmente également le besoin de surveillance pour s’assurer que les extensions sont sécurisées et conformes aux politiques de l’entreprise. Ce script répond à ces besoins en fournissant un rapport complet de toutes les extensions de navigateur installées pour les principaux navigateurs, ce qui en fait un outil essentiel pour les professionnels de l’informatique et les entreprises MSP qui doivent maintenir la sécurité et la conformité.
Le script
#Requires -Version 5.1 <# .SYNOPSIS Reports on all installed browser extensions for Chrome, Firefox and Edge. .DESCRIPTION Reports on all installed browser extensions for Chrome, Firefox and Edge. .EXAMPLE (No Parameters) A Google Chrome installation was detected. Searching Chrome for browser extensions... A Microsoft Edge installation was detected. Searching Microsoft Edge for browser extensions... A Firefox installation was detected. Searching Firefox for browser extensions... Attempting to set Custom Field 'Multiline'. WARNING: 10,000 Character Limit has been reached! Trimming output until the character limit is satisfied... Successfully set Custom Field 'Multiline'! Attempting to set Custom Field 'WYSIWYG'. Successfully set Custom Field 'WYSIWYG'! Browser extensions were detected. Browser : Chrome User : cheart Name : askBelynda | Sustainable Shopping Extension ID : pcmbjnfbjkeieekkahdfgchcbjfhhgdi Description : Sustainable shopping made simple with askBelynda. Choose ethical products o(...) Browser : Chrome User : cheart Name : Beni - Your secondhand shopping assistant Extension ID : efdgbhncnligcbloejoaemnfhjihkccj Description : The easiest way to shop secondhand. Beni finds the best resale alternative(...) Browser : Chrome User : cheart Name : Bonjourr · Minimalist Startpage Extension ID : dlnejlppicbjfcfcedcflplfjajinajd Description : Improve your web browsing experience with Bonjourr, a beautiful, customizab(...) Browser : Chrome User : cheart Name : Boxel 3D Extension ID : mjjgmlmpeaikcaajghilhnioimmaibon Description : Boxel 3D is the 3rd release of your favorite box jumping game made by the d(...) ... PARAMETER: -MultilineCustomField "ReplaceMeWithNameOfAMultilineCustomField" Specify the name of a multiline custom field to optionally store the search results in. Leave blank to not set a multiline field. PARAMETER: -WysiwygCustomField "ReplaceMeWithAnyWYSIWYGCustomField" Specify the name of a WYSIWYG custom field to optionally store the search results in. Leave blank to not set a WYSIWYG field. .NOTES Minimum OS Architecture Supported: Windows 10, Windows Server 2016 Release Notes: Initial Release By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https://www.ninjaone.com/terms-of-use. Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA). #> [CmdletBinding()] param ( [Parameter()] [String]$MultilineCustomField, [Parameter()] [String]$WysiwygCustomField ) begin { # Replace parameters with the dynamic script variables. if ($env:multilineCustomFieldName -and $env:multilineCustomFieldName -notlike "null") { $MultilineCustomField = $env:multilineCustomFieldName } if ($env:wysiwygCustomFieldName -and $env:wysiwygCustomFieldName -notlike "null") { $WysiwygCustomField = $env:wysiwygCustomFieldName } # Check if $MultilineCustomField and $WysiwygCustomField are both not null and have the same value if ($MultilineCustomField -and $WysiwygCustomField -and $MultilineCustomField -eq $WysiwygCustomField) { Write-Host "[Error] Custom Fields of different types cannot have the same name." Write-Host "https://ninjarmm.zendesk.com/hc/en-us/articles/360060920631-Custom-Fields-Configuration-Device-Role-Fields" exit 1 } # Function to get user registry hives based on the type of account function Get-UserHives { param ( [Parameter()] [ValidateSet('AzureAD', 'DomainAndLocal', 'All')] [String]$Type = "All", [Parameter()] [String[]]$ExcludedUsers, [Parameter()] [switch]$IncludeDefault ) # Patterns for user SID depending on account type $Patterns = switch ($Type) { "AzureAD" { "S-1-12-1-(\d+-?){4}$" } "DomainAndLocal" { "S-1-5-21-(\d+-?){4}$" } "All" { "S-1-12-1-(\d+-?){4}$" ; "S-1-5-21-(\d+-?){4}$" } } # Fetch user profiles whose SIDs match the defined patterns and prepare objects with their details $UserProfiles = Foreach ($Pattern in $Patterns) { Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*" | Where-Object { $_.PSChildName -match $Pattern } | Select-Object @{Name = "SID"; Expression = { $_.PSChildName } }, @{Name = "UserName"; Expression = { "$($_.ProfileImagePath | Split-Path -Leaf)" } }, @{Name = "UserHive"; Expression = { "$($_.ProfileImagePath)\NTuser.dat" } }, @{Name = "Path"; Expression = { $_.ProfileImagePath } } } # Handle inclusion of the default user profile if requested switch ($IncludeDefault) { $True { $DefaultProfile = "" | Select-Object UserName, SID, UserHive, Path $DefaultProfile.UserName = "Default" $DefaultProfile.SID = "DefaultProfile" $DefaultProfile.Userhive = "$env:SystemDrive\Users\Default\NTUSER.DAT" $DefaultProfile.Path = "C:\Users\Default" $DefaultProfile | Where-Object { $ExcludedUsers -notcontains $_.UserName } } } # Return user profiles, excluding any specified users $UserProfiles | Where-Object { $ExcludedUsers -notcontains $_.UserName } } # Function to check if the current PowerShell session is running with elevated permissions function Test-IsElevated { $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() $p = New-Object System.Security.Principal.WindowsPrincipal($id) $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator) } function Set-NinjaProperty { [CmdletBinding()] Param( [Parameter(Mandatory = $True)] [String]$Name, [Parameter()] [String]$Type, [Parameter(Mandatory = $True, ValueFromPipeline = $True)] $Value, [Parameter()] [String]$DocumentName ) $Characters = $Value | Out-String | Measure-Object -Character | Select-Object -ExpandProperty Characters if ($Characters -ge 200000) { throw [System.ArgumentOutOfRangeException]::New("Character limit exceeded; the value is greater than or equal to 200,000 characters.") } # If requested to set the field value for a Ninja document, we'll specify it here. $DocumentationParams = @{} if ($DocumentName) { $DocumentationParams["DocumentName"] = $DocumentName } # This is a list of valid fields that can be set. If no type is specified, it is assumed that the input does not need to be changed. $ValidFields = "Attachment", "Checkbox", "Date", "Date or Date Time", "Decimal", "Dropdown", "Email", "Integer", "IP Address", "MultiLine", "MultiSelect", "Phone", "Secure", "Text", "Time", "URL", "WYSIWYG" if ($Type -and $ValidFields -notcontains $Type) { Write-Warning "$Type is an invalid type! Please check here for valid types: https://ninjarmm.zendesk.com/hc/en-us/articles/16973443979789-Command-Line-Interface-CLI-Supported-Fields-and-Functionality" } # The field below requires additional information to be set. $NeedsOptions = "Dropdown" if ($DocumentName) { if ($NeedsOptions -contains $Type) { # Redirect error output to the success stream to make it easier to handle errors if nothing is found or if something else goes wrong. $NinjaPropertyOptions = Ninja-Property-Docs-Options -AttributeName $Name @DocumentationParams 2>&1 } } else { if ($NeedsOptions -contains $Type) { $NinjaPropertyOptions = Ninja-Property-Options -Name $Name 2>&1 } } # If an error is received with an exception property, the function will exit with that error information. if ($NinjaPropertyOptions.Exception) { throw $NinjaPropertyOptions } # The below types require values not typically given in order to be set. The below code will convert whatever we're given into a format ninjarmm-cli supports. switch ($Type) { "Checkbox" { # Although it's highly likely we were given a value like "True" or a boolean datatype, it's better to be safe than sorry. $NinjaValue = [System.Convert]::ToBoolean($Value) } "Date or Date Time" { # Ninjarmm-cli expects the GUID of the option to be selected. Therefore, the given value will be matched with a GUID. $Date = (Get-Date $Value).ToUniversalTime() $TimeSpan = New-TimeSpan (Get-Date "1970-01-01 00:00:00") $Date $NinjaValue = $TimeSpan.TotalSeconds } "Dropdown" { # Ninjarmm-cli is expecting the guid of the option we're trying to select. So we'll match up the value we were given with a guid. $Options = $NinjaPropertyOptions -replace '=', ',' | ConvertFrom-Csv -Header "GUID", "Name" $Selection = $Options | Where-Object { $_.Name -eq $Value } | Select-Object -ExpandProperty GUID if (-not $Selection) { throw [System.ArgumentOutOfRangeException]::New("Value is not present in dropdown options.") } $NinjaValue = $Selection } default { # All the other types shouldn't require additional work on the input. $NinjaValue = $Value } } # We'll need to set the field differently depending on if its a field in a Ninja Document or not. if ($DocumentName) { $CustomField = Ninja-Property-Docs-Set -AttributeName $Name -AttributeValue $NinjaValue @DocumentationParams 2>&1 } else { $CustomField = $NinjaValue | Ninja-Property-Set-Piped -Name $Name 2>&1 } if ($CustomField.Exception) { throw $CustomField } } # Function to find installation keys based on the display name, optionally returning uninstall strings function Find-InstallKey { [CmdletBinding()] param ( [Parameter(ValueFromPipeline = $True)] [String]$DisplayName, [Parameter()] [Switch]$UninstallString, [Parameter()] [String]$UserBaseKey ) process { # Initialize an empty list to hold installation objects $InstallList = New-Object System.Collections.Generic.List[Object] # If no user base key is specified, search in the default system-wide uninstall paths if (!$UserBaseKey) { # Search for programs in 32-bit and 64-bit locations. Then add them to the list if they match the display name $Result = Get-ChildItem -Path "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | Get-ItemProperty | Where-Object { $_.DisplayName -like "*$DisplayName*" } if ($Result) { $InstallList.Add($Result) } $Result = Get-ChildItem -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" | Get-ItemProperty | Where-Object { $_.DisplayName -like "*$DisplayName*" } if ($Result) { $InstallList.Add($Result) } } else { # If a user base key is specified, search in the user-specified 64-bit and 32-bit paths. $Result = Get-ChildItem -Path "$UserBaseKey\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | Get-ItemProperty | Where-Object { $_.DisplayName -like "*$DisplayName*" } if ($Result) { $InstallList.Add($Result) } $Result = Get-ChildItem -Path "$UserBaseKey\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" | Get-ItemProperty | Where-Object { $_.DisplayName -like "*$DisplayName*" } if ($Result) { $InstallList.Add($Result) } } # If the UninstallString switch is specified, return only the uninstall strings; otherwise, return the full installation objects. if ($UninstallString) { $InstallList | Select-Object -ExpandProperty UninstallString -ErrorAction SilentlyContinue } else { $InstallList } } } if (!$ExitCode) { $ExitCode = 0 } } process { # Check if the script is running with elevated permissions (administrator rights) if (!(Test-IsElevated)) { Write-Host -Object "[Error] Access Denied. Please run with Administrator privileges." exit 1 } # Search for Chrome installations on the system and enable chrome extension search if found. Find-InstallKey -DisplayName "Chrome" | ForEach-Object { $ChromeInstallations = $True } # Search for Firefox installations on the system and enable firefox extension search if found. Find-InstallKey -DisplayName "Firefox" | ForEach-Object { $FireFoxInstallations = $True } # Search for Edge installations on the system and flag if found and enable edge extension search if found. Find-InstallKey -DisplayName "Edge" | ForEach-Object { $EdgeInstallations = $True } # Retrieve all user profiles from the system $UserProfiles = Get-UserHives -Type "All" # Loop through each profile on the machine Foreach ($UserProfile in $UserProfiles) { # Load User ntuser.dat if it's not already loaded If (($ProfileWasLoaded = Test-Path Registry::HKEY_USERS\$($UserProfile.SID)) -eq $false) { Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe LOAD HKU\$($UserProfile.SID) `"$($UserProfile.UserHive)`"" -Wait -WindowStyle Hidden } # Repeat search for installations of browsers but in the user's registry context Find-InstallKey -UserBaseKey "Registry::HKEY_USERS\$($UserProfile.SID)" -DisplayName "Chrome" | ForEach-Object { $ChromeInstallations = $True } Find-InstallKey -UserBaseKey "Registry::HKEY_USERS\$($UserProfile.SID)" -DisplayName "Firefox" | ForEach-Object { $FireFoxInstallations = $True } Find-InstallKey -UserBaseKey "Registry::HKEY_USERS\$($UserProfile.SID)" -DisplayName "Edge" | ForEach-Object { $EdgeInstallations = $True } # Unload NTuser.dat If ($ProfileWasLoaded -eq $false) { [gc]::Collect() Start-Sleep 1 Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe UNLOAD HKU\$($UserProfile.SID)" -Wait -WindowStyle Hidden | Out-Null } } # Initialize a list to store details of detected browser extensions $BrowserExtensions = New-Object System.Collections.Generic.List[object] # If Chrome was found, search for Chrome extensions in each user's profile if ($ChromeInstallations) { Write-Host -Object "A Google Chrome installation was detected. Searching Chrome for browser extensions..." $UserProfiles | ForEach-Object { if (!(Test-Path -Path "$($_.Path)\AppData\Local\Google\Chrome\User Data" -ErrorAction SilentlyContinue)) { return } if(Test-Path -Path "$($_.Path)\AppData\Local\Google\Chrome\User Data\Local State" -ErrorAction SilentlyContinue){ $AllProfiles = Get-Content -Path "$($_.Path)\AppData\Local\Google\Chrome\User Data\Local State" | ConvertFrom-JSON } $PreferenceFiles = Get-ChildItem "$($_.Path)\AppData\Local\Google\Chrome\User Data\*\Preferences" -Exclude "System Profile" | Select-Object -ExpandProperty Fullname foreach ($PreferenceFile in $PreferenceFiles) { $GooglePreferences = Get-Content -Path $PreferenceFile | ConvertFrom-Json if($AllProfiles){ $ProfileLocation = $PreferenceFile | Get-Item | Select-Object -ExpandProperty Directory | Split-Path -Leaf $ProfileName = $AllProfiles.profile.info_cache | Select-Object -ExpandProperty $ProfileLocation | Select-Object -ExpandProperty Name }else{ $ProfileName = $GooglePreferences.profile.name } foreach ($Extension in $GooglePreferences.extensions.settings.PSObject.Properties) { $BrowserExtensions.Add( [PSCustomObject]@{ Browser = "Chrome" User = $_.UserName Profile = $ProfileName Name = $Extension.Value.manifest.name "Extension ID" = $Extension.name Description = $Extension.Value.manifest.description } ) } } } } # If Edge was found, search for Edge extensions in each user's profile if ($EdgeInstallations) { Write-Host -Object "A Microsoft Edge installation was detected. Searching Microsoft Edge for browser extensions..." $UserProfiles | ForEach-Object { if (!(Test-Path -Path "$($_.Path)\AppData\Local\Microsoft\Edge\User Data" -ErrorAction SilentlyContinue)) { return } if(Test-Path -Path "$($_.Path)\AppData\Local\Microsoft\Edge\User Data\Local State" -ErrorAction SilentlyContinue){ $AllProfiles = Get-Content -Path "$($_.Path)\AppData\Local\Microsoft\Edge\User Data\Local State" | ConvertFrom-JSON } $PreferenceFiles = Get-ChildItem "$($_.Path)\AppData\Local\Microsoft\Edge\User Data\*\Preferences" -Exclude "System Profile" | Select-Object -ExpandProperty Fullname foreach ($PreferenceFile in $PreferenceFiles) { $EdgePreferences = Get-Content -Path $PreferenceFile | ConvertFrom-Json if($AllProfiles){ $ProfileLocation = $PreferenceFile | Get-Item | Select-Object -ExpandProperty Directory | Split-Path -Leaf $ProfileName = $AllProfiles.profile.info_cache | Select-Object -ExpandProperty $ProfileLocation | Select-Object -ExpandProperty Name }else{ $ProfileName = $EdgePreferences.profile.name } foreach ($Extension in $EdgePreferences.extensions.settings.PSObject.Properties) { if ($Extension.Value.active_bit -like "False" ) { continue } if (!$Extension.Value.manifest.name) { continue } $BrowserExtensions.Add( [PSCustomObject]@{ Browser = "Edge" User = $_.UserName Profile = $ProfileName Name = $Extension.Value.manifest.name "Extension ID" = $Extension.name Description = $Extension.Value.manifest.description } ) } } } } # If Firefox was found, search for Firefox extensions in each user's profile if ($FireFoxInstallations) { Write-Host -Object "A Firefox installation was detected. Searching Firefox for browser extensions..." $UserProfiles | ForEach-Object { if (!(Test-Path -Path "$($_.Path)\AppData\Roaming\Mozilla\Firefox\Profiles" -ErrorAction SilentlyContinue)) { return } $FirefoxProfileFolders = Get-ChildItem -Path "$($_.Path)\AppData\Roaming\Mozilla\Firefox\Profiles" -Directory | Where-Object { $_.Name -match "\.default-release$" } | Select-Object -ExpandProperty Fullname foreach ( $FirefoxProfile in $FirefoxProfileFolders ) { if (!(Test-Path -Path "$FirefoxProfile\extensions.json")) { continue } $Extensions = Get-Content -Path "$FirefoxProfile\extensions.json" | ConvertFrom-Json foreach ($Extension in $Extensions.addons) { $BrowserExtensions.Add( [PSCustomObject]@{ Browser = "Firefox" User = $_.UserName Profile = "N/A" Name = $Extension.defaultlocale.name "Extension ID" = $Extension.id Description = $Extension.defaultlocale.description } ) } } } } # Check if there are any browser extensions to process if ($BrowserExtensions.Count -gt 0) { # Format the BrowserExtensions list to include a shortened description if the description is too long. $BrowserExtensions = $BrowserExtensions | Select-Object Browser, User, Profile, Name, "Extension ID", @{ Name = "Description" Expression = { $Characters = $_.Description | Measure-Object -Character | Select-Object -ExpandProperty Characters if ($Characters -gt 75) { "$(($_.Description).SubString(0,75))(...)" } else { $_.Description } } } } # Check if extensions were found and if we were requested to set a multiline custom field if ($BrowserExtensions.Count -gt 0 -and $MultilineCustomField) { try { Write-Host "Attempting to set Custom Field '$MultilineCustomField'." $CustomFieldValue = New-Object System.Collections.Generic.List[string] # Sort and format the list of extensions for output $CustomFieldList = $BrowserExtensions | Sort-Object Browser, User, Profile, Name | Select-Object Browser, User, Profile, Name, "Extension ID", Description $CustomFieldValue.Add(($CustomFieldList | Format-List | Out-String)) # Measure the total character count of the formatted string $Characters = $CustomFieldValue | Out-String | Measure-Object -Character | Select-Object -ExpandProperty Characters if ($Characters -ge 9500) { Write-Warning "10,000 Character Limit has been reached! Trimming output until the character limit is satisfied..." # If it doesn't comply with the limits we'll need to recreate it with some adjustments. $i = 0 do { # Recreate the custom field output starting with a warning that we truncated the output. $CustomFieldValue = New-Object System.Collections.Generic.List[string] $CustomFieldValue.Add("This info has been truncated to accommodate the 10,000 character limit.") # Flip the array so that the last entry is on top. [array]::Reverse($CustomFieldList) # Remove the next item. $CustomFieldList[$i] = $null $i++ # We'll flip the array back to right side up. [array]::Reverse($CustomFieldList) # Add it back to the output. $CustomFieldValue.Add(($CustomFieldList | Format-List | Out-String)) # Check that we now comply with the character limit. If not restart the do loop. $Characters = $CustomFieldValue | Out-String | Measure-Object -Character | Select-Object -ExpandProperty Characters }while ($Characters -ge 9500) } Set-NinjaProperty -Name $MultilineCustomField -Value $CustomFieldValue Write-Host "Successfully set Custom Field '$MultilineCustomField'!" } catch { Write-Host "[Error] $($_.Exception.Message)" $ExitCode = 1 } } # Check if extensions were found and if we were requested to set a WYSIWYG custom field. if ($BrowserExtensions.Count -gt 0 -and $WysiwygCustomField) { try { Write-Host "Attempting to set Custom Field '$WysiwygCustomField'." # Prepare the custom field output. $CustomFieldValue = New-Object System.Collections.Generic.List[string] # Convert the matching events into an html report. $htmlTable = $BrowserExtensions | Sort-Object Browser, User, Profile, Name | Select-Object Browser, User, Profile, Name, "Extension ID", Description | ConvertTo-Html -Fragment # Add the newly created html into the custom field output. $CustomFieldValue.Add($htmlTable) # Check that the output complies with the hard character limits. $Characters = $CustomFieldValue | Out-String | Measure-Object -Character | Select-Object -ExpandProperty Characters if ($Characters -ge 199500) { Write-Warning "200,000 Character Limit has been reached! Trimming output until the character limit is satisfied..." # If it doesn't comply with the limits we'll need to recreate it with some adjustments. $i = 0 do { # Recreate the custom field output starting with a warning that we truncated the output. $CustomFieldValue = New-Object System.Collections.Generic.List[string] $CustomFieldValue.Add("<h1>This info has been truncated to accommodate the 200,000 character limit.</h1>") # Flip the array so that the last entry is on top. [array]::Reverse($htmlTable) # If the next entry is a row we'll delete it. if ($htmlTable[$i] -match '<tr><td>' -or $htmlTable[$i] -match '<tr class=') { $htmlTable[$i] = $null } $i++ # We'll flip the array back to right side up. [array]::Reverse($htmlTable) # Add it back to the output. $CustomFieldValue.Add($htmlTable) # Check that we now comply with the character limit. If not restart the do loop. $Characters = $CustomFieldValue | Out-String | Measure-Object -Character | Select-Object -ExpandProperty Characters }while ($Characters -ge 199500) } # Set the custom field. Set-NinjaProperty -Name $WysiwygCustomField -Value $CustomFieldValue Write-Host "Successfully set Custom Field '$WysiwygCustomField'!" } catch { Write-Host "[Error] $($_.Exception.Message)" $ExitCode = 1 } } if ($BrowserExtensions.Count -gt 0) { Write-Host "Browser extensions were detected." $BrowserExtensions | Sort-Object Browser, User, Profile, Name | Format-List | Out-String | Write-Host } else { Write-Host "No browser extensions were found!" } exit $ExitCode } end { }
Description détaillée
Ce script est écrit en PowerShell et nécessite la version 5.1 ou une plus récente. Voici une description détaillée de son fonctionnement :
1. Initialisation et paramètres :
- Le script commence par vérifier les paramètres requis, $MultilineCustomField et $WysiwygCustomField, qui peuvent être définis via des variables d’environnement ou transmis directement.
- Il valide que ces champs, s’ils sont tous deux fournis, ne sont pas identiques afin d’éviter les conflits.
2. Récupération de ruche d’utilisateur :
- La fonction Get-UserHives identifie les profils d’utilisateurs sur le système, y compris les comptes AzureAD et les comptes de domaine.
- Cette fonction est essentielle pour garantir que le script analyse tous les répertoires d’utilisateurs pertinents pour les données du navigateur.
3. Contrôle d’autorisation:
- La fonction Test-IsElevated permet de s’assurer que le script s’exécute avec des privilèges administratifs, nécessaires pour accéder aux ruches et aux répertoires du registre spécifiques à l’utilisateur.
4. Détection du navigateur :
- Le script recherche les installations de Chrome, Firefox et Edge à l’aide de la fonction Find-InstallKey, qui analyse les clés de registre du système et de l’utilisateur.
5. Chargement de profil :
- Pour chaque navigateur détecté, le script parcourt les profils des utilisateurs, charge les ruches d’enregistrement nécessaires et recherche les données relatives aux extensions du navigateur.
- Il s’agit de vérifier les répertoires spécifiques et les fichiers de configuration dans lesquels les navigateurs stockent les informations relatives aux extensions.
6. Collecte des données :
- Il compile une liste des extensions installées, comprenant des détails tels que le nom du navigateur, l’utilisateur, le profil, le nom de l’extension, l’ID et la description.
7. Mises à jour des champs personnalisés :
- Si des extensions sont trouvées, le script tente de définir des champs personnalisés dans un système de documentation à l’aide de Set-NinjaProperty. Il gère les limites potentielles de caractères en réduisant la sortie si nécessaire.
8. Résultat :
- Le résultat final est une liste triée des extensions de navigateur, qui peut être affichée ou stockée dans des champs personnalisés en vue d’une analyse plus approfondie.
Cas d’utilisation potentiels
Imaginez un professionnel de l’informatique qui gère l’infrastructure informatique d’une entreprise de taille moyenne. Il doit s’assurer que toutes les extensions de navigateur installées sur les machines des utilisateurs sont conformes aux politiques de l’entreprise. En exécutant ce script, il peut rapidement faire l’inventaire de toutes les extensions dans Chrome, Firefox et Edge, identifier les extensions non autorisées ou à risque, et prendre des mesures correctives.
Par exemple, si une nouvelle politique interdit les extensions qui n’ont pas été approuvées par le département informatique, ce script permet à l’administrateur informatique de générer une liste complète des extensions actuelles. L’administrateur peut ensuite croiser cette liste avec les extensions approuvées et supprimer à distance celles qui présentent un risque.
Comparaisons
Par rapport aux méthodes manuelles consistant à vérifier chaque navigateur et chaque profil d’utilisateur individuellement, ce script est nettement plus efficace et plus complet. D’autres approches peuvent impliquer l’utilisation d’outils spécifiques aux navigateurs ou une inspection manuelle, deux méthodes qui prennent du temps et sont sujettes aux erreurs humaines. Ce script automatise le processus, garantissant la cohérence et permettant de gagner un temps précieux.
FAQ
Q : Ce script peut-il être exécuté à distance ?
R : Oui, à condition que vous disposiez des autorisations administratives nécessaires et de l’accès aux machines distantes.
Q : Que se passe-t-il si la description d’une extension dépasse la limite de caractères ?
R : Le script réduit la description pour qu’elle tienne dans la limite des caractères, ce qui garantit que le résultat reste gérable.
Q : Le script fonctionne-t-il sur toutes les versions de Windows ?
R : Le script nécessite Windows 10 ou Windows Server 2016 et les versions plus récentes, car il dépend des fonctionnalités disponibles dans ces versions.
Q : Le script peut-il être modifié pour prendre en charge d’autres navigateurs ?
R : Oui, en apportant des modifications appropriées à la logique de détection et de collecte des données, il est possible de le rendre compatible avec d’autres navigateurs.
Implications
Les résultats de ce script peuvent avoir des conséquences importantes pour la sécurité informatique. En identifiant toutes les extensions de navigateur installées, les professionnels de l’informatique peuvent détecter les risques de sécurité potentiels et garantir la conformité avec les politiques de l’entreprise. Cette approche proactive permet d’atténuer le risque d’infections par des logiciels malveillants et de vols de données dues à des extensions malveillantes ou mal entretenues.
Recommandations
Lors de l’utilisation de ce script, il est important de suivre les bonnes pratiques suivantes :
- Exécutez le script régulièrement dans le cadre de votre programme de maintenance informatique.
- Examinez la liste des extensions détectées et comparez-les à votre liste approuvée.
- Sensibilisez les utilisateurs aux risques associés aux extensions de navigateur et encouragez-les à n’installer que des extensions approuvées.
Conclusion
La gestion des extensions de navigateur est un aspect essentiel du maintien de la sécurité informatique. Ce script fournit un moyen automatisé et efficace d’inventorier et de surveiller les extensions de navigateur pour plusieurs utilisateurs et navigateurs. En intégrant cet outil dans vos processus de gestion informatique, vous pouvez améliorer la posture de sécurité de votre entreprise et garantir le respect des politiques.
NinjaOne offre une gamme d’outils et de fonctionnalités qui complètent ce script, fournissant une solution complète pour la gestion et la sécurité informatique. Avec NinjaOne, vous pouvez automatiser les tâches de routine, surveiller les terminaux et garantir la sécurité et la conformité de votre environnement informatique.