본문 바로가기
Windows Server

로컬보안정책 Powershell 로 처리하기 / secpol.msc

by 정보봇따리 2022. 1. 20.
728x90
반응형
SMALL

AD 못 쓰니까 불편하네오..................

 

1. 기존 로컬 보안정책에 "서비스로 로그인" 항목만 수정할 것임

2. 아래 파워쉘은 기존 로컬 보안 정책을 백업하고, 거기에 SeServiceLogonRight 를 추가한 다음, 다시 import 하는 것임

 

$Username = 사용자 이름
secedit /export /cfg "C:\Jenkins\tmp.inf" | Out-Null
(gc -Encoding ascii "C:\Jenkins\tmp.inf") -replace '^SeServiceLogonRight .+', "`$0,$Username" | sc -Encoding ascii "C:\Jenkins\tmp.inf"
secedit /import /cfg "C:\Jenkins\tmp.inf" /db "C:\Jenkins\tmp.sdb" | Out-Null
secedit /configure /db "C:\Jenkins\tmp.sdb" /cfg "C:\Jenkins\tmp.inf" | Out-Null
Remove-Item "C:\Jenkins\tmp.inf" 
Remove-Item "C:\Jenkins\tmp.sdb"
Remove-Item "C:\Jenkins\tmp.jfm"

 

 

 

728x90
반응형
LIST