Dans cet article, nous allons utiliser un script PowerShell (.ps1) pour obtenir la valeur d'un champ personnalisé et l'utiliser pour installer Sophos Antivirus sur une machine.
Notes :
- Vous devez installer le logiciel PSAtera dans Powershell avant d'utiliser ce script.
- Vous pouvez adapter le script à vos besoins en modifiant les valeurs des variables dans les trois premières lignes du script.
1. Copiez le script ci-dessous.
$AteraAPIKey = 'MY ATERA API KEY' $FieldName = 'Sophos Key' $SophosURI = 'https://SOME SHAREPOINT PUBLIC URL FOR/SophosSetup.exe' # Install and load the right version of Atera if (!(Get-Module -ListAvailable PSAtera)) { Install-Module -Name PSAtera -MinimumVersion 1.3.1 -Force } Import-Module -Name PSAtera -MinimumVersion 1.3.1 Set-AteraAPIKey -APIKey $AteraAPIKey # Get the agent information for the PC that's running the script $agent = Get-AteraAgent # Get the value from the Customer endpoint $customValue = Get-AteraCustomValue -ObjectType Customer -ObjectId $agent.CustomerID -FieldName $FieldName # Download Sophos Installer to temp path $SophosInstaller = Join-Path -Path $env:TEMP -ChildPath "SophosSetup.exe" Invoke-WebRequest -Uri $SophosURI -OutFile $SophosInstaller & $SophosInstaller --customertoken="$($customValue.ValueAsString)" --epiinstallerserver="api-cloudstation-us-east-2.prod.hydra.sophos.com" --products="all" --quiet # Get the status of the Sophos Install do { Get-Process -Name "*SophosSetup.exe*" Start-Sleep -Seconds 10 } while (Get-Process -Name "*SophosSetup.exe*" -ErrorAction SilentlyContinue) # After install is over, get the status of the Sophos Services Get-Service -Name "*Sophos*"
2. Apportez les modifications nécessaires aux trois premières variables du script.
3. Exécutez le script sur la machine souhaitée.
Vous pouvez add le script dans Atera et exécuter par le biais d'un profil IT Automaton ;
NOTE : Ce script n'a pas fait l'objet d'un contrôle de fonctionnalité et nous n'offrons pas d'assistance au dépannage. Veuillez d'abord l'examiner et le tester dans votre environnement de laboratoire.
Merci, Dave Long, pour la création de ce script et pour votre contribution à la communauté Atera!