![Power Shell 스크립트를 사용하여 AS 배치 로그온 부여 - Windows Server 2016에서 수동으로 실행하면 제대로 작동하지만 oneops에서 트리거되면 실패합니다.](https://rvso.com/image/1671477/Power%20Shell%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20AS%20%EB%B0%B0%EC%B9%98%20%EB%A1%9C%EA%B7%B8%EC%98%A8%20%EB%B6%80%EC%97%AC%20-%20Windows%20Server%202016%EC%97%90%EC%84%9C%20%EC%88%98%EB%8F%99%EC%9C%BC%EB%A1%9C%20%EC%8B%A4%ED%96%89%ED%95%98%EB%A9%B4%20%EC%A0%9C%EB%8C%80%EB%A1%9C%20%EC%9E%91%EB%8F%99%ED%95%98%EC%A7%80%EB%A7%8C%20oneops%EC%97%90%EC%84%9C%20%ED%8A%B8%EB%A6%AC%EA%B1%B0%EB%90%98%EB%A9%B4%20%EC%8B%A4%ED%8C%A8%ED%95%A9%EB%8B%88%EB%8B%A4..png)
tmp11.inf를 생성하지만 사용자 권한을 tmp11.inf 0kb로 내보내지 않습니다. tmp11.inf가 비어 있으므로 $currentConfig = Get-Content -Path $tempConfigFile에서 스크립트가 실패합니다.
- 관리자 권한으로 실행하기 위해 아래 줄을 추가했지만 여전히 동일한 문제가 발생합니다.
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