
This is part two of a series walking through how Hydra can integrate with Login Enterprise for further automated testing capabilities. If you haven’t read that article, check this out:
Better Together: Login Enterprise & Hydra (Part 1)
That blog talks about how Hydra can orchestrate fully-automated Launcher deployments, leveraging an Azure Marketplace vanilla image customized by Hydra Script Collections.
The workflow
This time we’ll focus on the Session Host, or in LE terms– the testing Target. In Login Enterprise, there is one primary dependency here, the Logon Executable, whose primary responsibility is to trigger automation scripts once a Virtual User logs in. The process looks like:
- Virtual User logs into Windows Desktop
- Logon Executable is triggered by Startup (e.g., GPO, Registry, Startup folder placement)
- Logon Executable “calls home” to download dependencies and initiate its job
Configuring the Logon Executable
This script is very similar to the Launcher Installation and Startup Shortcut configuration covered in Part 1, except this can be directly downloaded from a Login Enterprise Virtual Appliance.
The PowerShell script automates the configuration by a) downloading the standalone Logon Executable from the specified appliance and b) creating a shortcut in the Startup folder.
Anyway, here is the code:
LogWriter("Downloading Logon EXE")
# Base FQDN of the appliance
$applianceFQDN = "https://<your_login_enterprise_fqdn_here>"
# URL of the ZIP file to download
$url = "$applianceFQDN/contentDelivery/api/logonApp"
# Arguments to pass to the EXE (adjust as needed)
$arguments = $applianceFQDN
# Define temp paths
$tempDir = "C:\LoginVSI"
$zipName = [IO.Path]::GetFileName($url)
$zipPath = Join-Path $tempDir "$zipName.zip"
$extractDir = Join-Path $tempDir ([IO.Path]::GetFileNameWithoutExtension($zipName))
# Define shortcut properties
# Define target executable and Startup shortcut paths
$targetPath = "C:\LoginVSI\logonApp\LoginPI.Logon.exe"
$shortcutPath = "$env:ALLUSERSPROFILE\Microsoft\Windows\Start Menu\Programs\Startup\LoginPI_Logon.lnk"
# Ensure the extract directory exists (or recreate it)
if (Test-Path $extractDir) {
Remove-Item -LiteralPath $extractDir -Recurse -Force
}
New-Item -ItemType Directory -Path $extractDir | Out-Null
try {
# Download the ZIP file
Invoke-WebRequest -Uri $url -OutFile $zipPath -UseBasicParsing
# Extract the ZIP into $extractDir; -Force will overwrite if files already exist
Expand-Archive -Path $zipPath -DestinationPath $extractDir -Force
# Find the first .exe in the extracted folder (recursively)
$exe = Get-ChildItem -Path $extractDir -Filter '*.exe' -Recurse |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if (-not $exe) {
throw "No executable (.exe) found in '$extractDir'."
}
# Create the shortcut
try {
# Verify the target executable exists
if (-not (Test-Path -Path $targetPath -PathType Leaf)) {
throw "Target executable not found: $targetPath"
}
# Ensure the Startup folder exists (it should, but just in case)
$startupFolder = Split-Path -Parent $shortcutPath
if (-not (Test-Path -Path $startupFolder -PathType Container)) {
throw "Startup folder does not exist: $startupFolder"
}
# Create the WScript.Shell COM object
try {
$WshShell = New-Object -ComObject WScript.Shell
}
catch {
throw "Unable to create WScript.Shell COM object: $_"
}
# Create the shortcut
$shortcut = $WshShell.CreateShortcut($shortcutPath)
# Assign properties to the shortcut
$shortcut.TargetPath = $targetPath
$shortcut.Arguments = $arguments
$shortcut.WorkingDirectory = Split-Path -Parent $targetPath
# Save the shortcut to disk
$shortcut.Save()
Write-Host "Shortcut successfully created at: $shortcutPath"
LogWriter("Shortcut created!")
}
catch {
Write-Error "Failed to create shortcut: $_"
LogWriter("Failed to create shortcut! $_")
}
}
catch {
Write-Error "An error occurred: $_"
LogWriter("An error occurred! $_")
}
What’s next?
This was the first series that covered how Hydra and Login Enterprise can operate better together. Perhaps there will be similar installments down the line, so look out for those.
Leave a comment