![Anmeldung als Batch mithilfe eines Power Shell-Skripts gewähren - Funktioniert einwandfrei, wenn ich es manuell auf Windows Server 2016 ausführe, schlägt jedoch fehl, wenn es von OneOps ausgelöst wird](https://rvso.com/image/1671477/Anmeldung%20als%20Batch%20mithilfe%20eines%20Power%20Shell-Skripts%20gew%C3%A4hren%20-%20Funktioniert%20einwandfrei%2C%20wenn%20ich%20es%20manuell%20auf%20Windows%20Server%202016%20ausf%C3%BChre%2C%20schl%C3%A4gt%20jedoch%20fehl%2C%20wenn%20es%20von%20OneOps%20ausgel%C3%B6st%20wird.png)
Es erstellt tmp11.inf, exportiert aber nicht die Benutzerrechte in tmp11.inf 0kb. Das Skript schlägt bei $currentConfig = Get-Content -Path $tempConfigFile fehl, da tmp11.inf leer ist
- Ich habe die folgende Zeile hinzugefügt, um es als Administrator auszuführen, aber das Problem besteht immer noch dasselbe.
Start-Process -FilePath "powershell" -ArgumentList "$('-File ""')$(Get-Location)$('\')$($MyInvocation.MyCommand.Name)$('""')" -Verb runAs**
2) OneOps execution both failed same issue,
Method 1. ```powershell.exe -file E:\apps-packages\GrantLogonRights.ps1```
Method 2. ```PowerShell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process PowerShell -ArgumentList '-ExecutionPolicy Unrestricted','-File E:\apps-packages\GrantLogonRights.ps1' -Verb RunAs" ```
$username = "domain\account"
$rightBatch = "SeBatchLogonRight"
$tempConfigFile = "C:\Users\admin\AppData\Local\Temp\tmp11.inf"
$tempDbFile = "C:\Users\admin\AppData\Local\Temp\tmp11.sdb"
secedit /export /cfg $tempConfigFile /areas USER_RIGHTS
$currentConfig = Get-Content -Path $tempConfigFile
$sid = ((New-Object System.Security.Principal.NTAccount($username)).Translate([System.Security.Principal.SecurityIdentifier])).Value
$newConfig = $currentConfig -replace "^$right .+", "`$0,*$sid"
Set-Content -Path $tempConfigFile -Encoding ascii -Value $newConfig
secedit /import /cfg $tempConfigFile /db $tempDbFile
secedit /configure /db $tempDbFile /cfg $tempConfigFile /areas USER_RIGHTS
gpupdate /force