In diesem Artikel wird ein PowerShell-Skript (.ps1) verwendet, um den Wert für ein benutzerdefiniertes Feld abzurufen und damit Sophos Antivirus auf einem Computer zu installieren.
Hinweise:
- Bevor Sie dieses Skript verwenden können, müssen Sie das PSAtera-Modul in Powershell installieren.
- Sie können das Skript an Ihre Bedürfnisse anpassen, indem Sie die Werte der Variablen in den ersten drei Zeilen des Skripts ändern.
1. Kopieren Sie das folgende Skript.
$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. Nehmen Sie alle erforderlichen Änderungen an den ersten 3 Variablen des Skripts vor.
3. Führen Sie das Skript auf dem gewünschten Rechner aus.
Sie können add das Script in Atera und ausführen es über ein IT-Automatisierungsprofil aus;
Hinweis: Das Skript wurde nicht auf seine Funktionalität geprüft und wir bieten keine Unterstützung bei der Fehlerbehebung an. Bitte prüfen und testen Sie es zunächst in Ihrer Laborumgebung.
Danke, Dave Long, für die Erstellung dieses Skripts und für deinen Beitrag zur Atera-Gemeinschaft!