Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Move the client host to the specified OU

2025-03-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

# #

# move the client host to the specified OU #

# V1.0 #

# yuanzhe #

# add ActiveDirectory power shell module #

Import-Module ActiveDirectory

# assign Windows7 Enterprise Edition to the variable #

# $windows7enterpise=Get-ADComputer-SearchBase "CN=Computers,DC=ljstaff,DC=com"-Filter {OperatingSystem-eq "Windows 7 Enterprise Edition"}-Properties OperatingSystem,OperatingSystemVersion | select OperatingSystem,OperatingSystemVersion

$windows7enterpise = "Windows 7 Enterprise Edition"

# assign the Windows7 flagship version to the variable #

$windows7Uitimate= "Windows 7 Ultimate Edition"

# assign the Windows10 Enterprise Edition to the variable #

$windows10Enterpise= "Windows 10 Enterprise Edition"

# assign Windows 10 Professional Edition to variables #

Windows10ProfessionalEdition= "Windows 10 Professional Edition"

# View all computers in the computers directory #

$computers=Get-ADComputer-SearchBase "CN=Computers,DC=windows,DC=com"-Filter *-Properties OperatingSystem,OperatingSystemVersion

# add OU directory of domain host #

$dasou= "ou=das,dc=windows,dc=com"

Foreach ($lscomputer in $computers)

{

# move the Windows 7 Enterprise Edition computer under computers OU to DAS OU #

If ($lscomputer.OperatingSystem-eq "$windows7enterpise") {

Move-ADObject-Identity $lscomputer-TargetPath $dasou

# pause #

# Pause

}

# move the Windows 7 Ultimate Edition computer under computers OU to DAS OU #

If ($lscomputer.OperatingSystem-eq "$windows7Uitimate") {

Move-ADObject-Identity $lscomputer-TargetPath $dasou

# pause #

# Pause

}

# move the Windows 10 Enterprise Edition computer under computers OU to DAS OU #

If ($lscomputer.OperatingSystem-eq "$windows10Enterpise") {

Move-ADObject-Identity $lscomputer-TargetPath $dasou

# pause #

# Pause

}

# move the Windows 10 professional version of the computer under computers OU to DAS OU #

If ($lscomputer.OperatingSystem-eq "$windows10ProfessionalEdition") {

Move-ADObject-Identity $lscomputer-TargetPath $dasou

# pause #

# Pause

}

}

Make a task plan

Run the script every 4 hours

Add parameter

Program script: powershell # run tool

Add parameters: C:\ script\ Movecomputer.ps1 # script path

Start with: C:\ script\ # specify the program directory

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report