feat: add Windows hardware inventory collector and NetBox sync
feat: add self-contained Windows build and Intune deployment scripts docs: document configuration, permissions, and deployment ci: build x64 and arm64 agent artifacts
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
param(
|
||||
[ValidateSet('win-x64', 'win-arm64')][string]$Runtime = 'win-x64',
|
||||
[string]$Configuration = 'Release'
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$projectRoot = Split-Path $PSScriptRoot -Parent
|
||||
$output = Join-Path $projectRoot "dist\$Runtime"
|
||||
dotnet publish (Join-Path $projectRoot 'NetBoxAgent.csproj') `
|
||||
-c $Configuration -r $Runtime --self-contained true `
|
||||
-p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true `
|
||||
-p:DebugType=None -p:DebugSymbols=false -o $output
|
||||
Write-Host "Erstellt: $output\agent.exe"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
param(
|
||||
[string]$SourceDirectory = $PSScriptRoot,
|
||||
[string]$InstallDirectory = "$env:ProgramFiles\NetBox Windows Agent",
|
||||
[string]$Schedule = 'DAILY',
|
||||
[string]$StartTime = '09:00'
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if (-not (Test-Path (Join-Path $SourceDirectory 'agent.exe'))) { throw 'agent.exe fehlt im Quellverzeichnis.' }
|
||||
if (-not (Test-Path (Join-Path $SourceDirectory 'config.json'))) { throw 'config.json fehlt im Quellverzeichnis.' }
|
||||
New-Item -ItemType Directory -Path $InstallDirectory -Force | Out-Null
|
||||
Copy-Item (Join-Path $SourceDirectory 'agent.exe') (Join-Path $InstallDirectory 'agent.exe') -Force
|
||||
Copy-Item (Join-Path $SourceDirectory 'config.json') (Join-Path $InstallDirectory 'config.json') -Force
|
||||
$acl = Get-Acl $InstallDirectory
|
||||
$acl.SetAccessRuleProtection($true, $false)
|
||||
$admins = New-Object System.Security.AccessControl.FileSystemAccessRule('BUILTIN\Administrators', 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
||||
$system = New-Object System.Security.AccessControl.FileSystemAccessRule('NT AUTHORITY\SYSTEM', 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
||||
$acl.SetAccessRule($admins); $acl.SetAccessRule($system); Set-Acl $InstallDirectory $acl
|
||||
$command = '"' + (Join-Path $InstallDirectory 'agent.exe') + '" --config "' + (Join-Path $InstallDirectory 'config.json') + '"'
|
||||
schtasks.exe /Create /TN 'NetBox Windows Agent' /SC $Schedule /ST $StartTime /RU SYSTEM /RL HIGHEST /TR $command /F | Out-Null
|
||||
& (Join-Path $InstallDirectory 'agent.exe') --config (Join-Path $InstallDirectory 'config.json')
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
param([string]$InstallDirectory = "$env:ProgramFiles\NetBox Windows Agent")
|
||||
$ErrorActionPreference = 'Stop'
|
||||
schtasks.exe /Delete /TN 'NetBox Windows Agent' /F 2>$null
|
||||
if (Test-Path -LiteralPath $InstallDirectory) {
|
||||
$resolved = (Resolve-Path -LiteralPath $InstallDirectory).Path
|
||||
$programFiles = (Resolve-Path -LiteralPath $env:ProgramFiles).Path
|
||||
if (-not $resolved.StartsWith($programFiles + '\', [StringComparison]::OrdinalIgnoreCase)) { throw "Unsicheres Ziel: $resolved" }
|
||||
Remove-Item -LiteralPath $resolved -Recurse -Force
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user