알쓸신잡 Powershell 스크립트 모음8
[Explanation]
#컴퓨터개체를 N개로 분류하여 OU를 분리하고자 할 때 사용하는 스크립트
$Computer=New-Object System.Collections.ArrayList
$computer=Get-Content C:\Users\Administrator\Desktop\zin_cloudvm.txt
$count=$computer.count-1
for($n=0; $n -le $count ; $n++){
$vmnum=$computer[$n].Substring(13,2) -as[int]
$vmnum=$vmnum%3
switch($vmnum)
{
"0"
{
$computer[$n]+ " : " + "GroupA" | Out-File -Append -Filepath "C:\Users\Administrator\Desktop\result.txt"
get-adcomputer $computer[$n] | Move-ADObject -TargetPath "OU=Group_A,OU=Client,OU=ZIN Computers,DC=ZIN,DC=Domain,DC=com"
}
"1"
{
$computer[$n]+ " : " + "GroupB" | Out-File -Append -Filepath "C:\Users\Administrator\Desktop\result.txt" ;
get-adcomputer $computer[$n] | Move-ADObject -TargetPath "OU=Group_B,OU=Client,OU=ZIN Computers,DC=ZIN,DC=Domain,DC=com"
}
"2"
{
$computer[$n]+ " : " + "GroupC" | Out-File -Append -Filepath "C:\Users\Administrator\Desktop\result.txt" ;
get-adcomputer $computer[$n] | Move-ADObject -TargetPath "OU=Group_C,OU=Client,OU=ZIN Computers,DC=ZIN,DC=Domain,DC=com"
}
}
$vmnum = $null
}
댓글이나 의견은 언제든지 환영합니다.
Your Comments are Always Welcomed!
0 comments:
Post a Comment