Install-EdgeService.ps1 862 B

123456789101112131415161718192021
  1. #Requires -Version 7.0
  2. #Requires -RunAsAdministrator
  3. [CmdletBinding()]
  4. param(
  5. [Parameter(Mandatory)][string] $Executable,
  6. [Parameter(Mandatory)][string] $Config,
  7. [Parameter(Mandatory)][pscredential] $ServiceCredential
  8. )
  9. $ErrorActionPreference = 'Stop'
  10. $exePath = (Resolve-Path -LiteralPath $Executable).Path
  11. $configPath = (Resolve-Path -LiteralPath $Config).Path
  12. if ([System.IO.Path]::GetFileName($exePath) -ne 'Admin.NET.DataPlatform.Edge.exe') {
  13. throw 'Expected the published Edge executable.'
  14. }
  15. if (Get-Service -Name 'AiDopDataEdge' -ErrorAction SilentlyContinue) {
  16. throw 'Service already exists.'
  17. }
  18. $binary = "`"$exePath`" --run `"$configPath`""
  19. New-Service -Name 'AiDopDataEdge' -DisplayName 'Ai-DOP Factory Data Ingress' -BinaryPathName $binary -Credential $ServiceCredential -StartupType Automatic
  20. Start-Service -Name 'AiDopDataEdge'