[파워쉘]로컬계정 활성화 및 비활성화# Script/Powershell2016. 1. 5. 16:50
Table of Contents
728x90
반응형
EnableDisableUser.ps1
param($computer="localhost", $a, $user, $password, $help)
function funHelp()
{
$helpText=@"
DESCRIPTION:
NAME: EnableDisableUser.ps1
Enables or Disables a local user on either a local or remote machine.
PARAMETERS:
-computer Specifies the name of the computer upon which to run the script
-a(ction) Action to perform < e(nable) d(isable) >
-user Name of user to create
-help prints help file
SYNTAX:
EnableDisableUser.ps1
Generates an error. You must supply a user name
EnableDisableUser.ps1 -computer MunichServer -user myUser
-password Passw0rd^&! -a e
Enables a local user called myUser on a computer named MunichServer
with a password of Passw0rd^&!
EnableDisableUser.ps1 -user myUser -a d
Disables a local user called myUser on the local machine
EnableDisableUser.ps1 -help ?
Displays the help topic for the script
"@
$helpText
exit
}
$EnableUser = 512
$DisableUser = 2
if($help){ "Obtaining help ..." ; funhelp }
if(!$user)
{
$(Throw 'A value for $user is required.
Try this: EnableDisableUser.ps1 -help ?')
}
$ObjUser = [ADSI]"WinNT://$computer/$user"
switch($a)
{
"e" {
if(!$password)
{
$(Throw 'a value for $password is required.
Try this: EnableDisableUser.ps1 -help ?')
}
$objUser.setpassword($password)
$objUser.description = "Enabled Account"
$objUser.userflags = $EnableUser
$objUser.setinfo()
}
"d" {
$objUser.description = "Disabled Account"
$objUser.userflags = $DisableUser
$objUser.setinfo()
}
DEFAULT
{
"You must supply a value for the action.
Try this: EnableDisableUser.ps1 -help ?"
}
}
728x90
반응형
'# Script > Powershell' 카테고리의 다른 글
[파워쉘]특정날짜 지난 폴더(하위폴더 포함) 삭제 (0) | 2016.12.21 |
---|---|
[파워쉘]파일내 특정문자열 치환 (0) | 2016.03.15 |
[파워쉘]IIS웹사이트 추출 (0) | 2016.02.24 |
[파워쉘]로컬사용자 패스워드 변경 (0) | 2016.01.05 |
[파워쉘]로컬사용자 리스트 추출 (0) | 2016.01.04 |
@다크쉐라빔 :: 다크쉐라빔의 주절주절
안녕하세요. 이곳은 IT위주의 잡다한 정보를 올려두는 개인 블로그입니다.
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!