#Requires -Version 7.0 #Requires -RunAsAdministrator [CmdletBinding()] param( [Parameter(Mandatory)][string] $Executable, [Parameter(Mandatory)][string] $Config, [Parameter(Mandatory)][pscredential] $ServiceCredential ) $ErrorActionPreference = 'Stop' $exePath = (Resolve-Path -LiteralPath $Executable).Path $configPath = (Resolve-Path -LiteralPath $Config).Path if ([System.IO.Path]::GetFileName($exePath) -ne 'Admin.NET.DataPlatform.Edge.exe') { throw 'Expected the published Edge executable.' } if (Get-Service -Name 'AiDopDataEdge' -ErrorAction SilentlyContinue) { throw 'Service already exists.' } $binary = "`"$exePath`" --run `"$configPath`"" New-Service -Name 'AiDopDataEdge' -DisplayName 'Ai-DOP Factory Data Ingress' -BinaryPathName $binary -Credential $ServiceCredential -StartupType Automatic Start-Service -Name 'AiDopDataEdge'