9.1. Installing ASGARD Agent via Powershell Script

You can find a simple script to install the ASGARD Agent via Powershell. Place the installer and script in the same folder. Change the script as needed.

 1# Setting vars
 2$scriptpath = $MyInvocation.MyCommand.Path
 3$dir = Split-Path $scriptpath
 4$installer = "asgard2-agent-windows-amd64.exe"
 5$servicename = "asgard2-agent"
 7# Checking if ASGARD Agent is already installed
 8if (Get-Service -Name $servicename -ErrorAction SilentlyContinue) {
 9    Write-Host "ASGARD Agent already installed, exiting"
10    exit 0
11} else {
12    Write-Host "ASGARD Agent not found, trying to install..."
14    # Install ASGARD Agent
15    Start-Process -Wait -FilePath "$dir\$installer" -WorkingDirectory $dir -WindowStyle Hidden -PassThru
17    # Timeout just to make sure the service is up and running
18    Timeout /T 15
20    # Checking service to see if agent was installed
21    if (Get-Service -Name $servicename -ErrorAction SilentlyContinue) {
22        Write-Host "Installed ASGARD Agent successfully"
23        exit 0
24    } else {
25        $Host.UI.WriteErrorLine("Could not install ASGARD Agent")
26        exit 1
27    }

9.2. Deploy ASGARD Agents via SCCM

To deploy the ASGARD Agent (or any other .exe installer) via SCCM, you have to write a Powershell script with a few conditions to mark an installation correctly as successful or failed.

Please refer to Microsoft's Create applications in Configuration Manager .

 1# Get current directory
 2$scriptpath = $MyInvocation.MyCommand.Path
 3$dir = Split-Path $scriptpath
 5# Run the installer
 6$installer = "asgard2-agent-windows-amd64.exe"
 7Start-Process -Wait -FilePath "$dir\$installer" -WorkingDirectory $dir -WindowStyle Hidden -PassThru
 9# Timeout just to make sure the service is up and running
10Timeout /T 15
12# If the service exists, the script writes console output and exits with code 0
13# If the service does not exist, the script writes an error output and exits with code 1
14# See https://learn.microsoft.com/en-us/mem/configmgr/apps/deploy-use/create-applications#about-custom-script-detection-methods
16$servicename = "asgard2-agent"
17if (Get-Service -Name $servicename -ErrorAction SilentlyContinue) {
18    Write-Host "ASGARD Agent installed"
19    exit 0
20} else {
21    $Host.UI.WriteErrorLine("ASGARD Agent not installed")
22    exit 1


This is just an example script which should work with SCCM. If you encounter any problems, refer to the link provided above for additional information.

SCCM Applications can also use a script to detect the Deployment. You can use this part of the script to detect if the installation was successful:

1$servicename = "asgard2-agent"
2if (Get-Service -Name $servicename -ErrorAction SilentlyContinue) {
3   Write-Host "ASGARD Agent installed"
4   exit 0
5} else {
6   $Host.UI.WriteErrorLine("ASGARD Agent not installed")
7   exit 1