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

Some powershell instructions

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1. Batch Mobile computer

$computer=get-adcomputer-filter *-searchabase "computer ou" | select name

Foreach ($I in $computer.name) {dsquery computer-name $I | dsmove-newparent "new ou"}

II. Disable accounts in bulk

Import-csv c:\ xx.csv | foreach {disable-adacount-identity $_ .name}

Third, use MOVE-ADobject to move computers in batch

1. Provide a list

$com=import-csv d:\ com.csv

$com | foreach {get-adcomputer-identity $_ .name} | select ObjectGUID | foreach {move-adobjec-identity $_ .name-

Targetpath "ou=it,dc=it581,dc=local"}

Open mailboxes in batches

Get-aduser-filter {name-like "Test*"} | select name | foreache {enable-mailbox-identity $_ .name}

Batch mobile diabled computers

Search-ADAccount-AccountDisabled-ComputersOnly | Move-ADObject-TargetPath "OU=discomputer,OU=IT

, DC=inovance,DC=local "

VI.

# set the initial password

$password = "p@ssw0rd"

# enter login name

$path ='.\ Users.txt'

Import-Module ActiveDirectory

$usernames = Get-Content-Path $path

$secure_password = ConvertTo-SecureString-String $password-AsPlainText-Force

Foreach ($username in $usernames) {

Try {

Set-ADAccountPassword-Identity $username-NewPassword $secure_password

}

Catch {

Write-Host "$($username) 'does not exist in AD, please check if it is typed incorrectly!" -ForegroundColor Red

}

}

Cmd / c pause

7. Batch Mobile computer

$a = Get-Content D:\ citrix_Ctrl_test.txt # text file that stores the computer name

Foreach ($I in $a)

{

Dsquery computer-name $I | dsmove-newparent "OU=citrix_other,OU=Servers,OU=Citrix,DC=cicdev,DC=com" # move the computer name to citrix_other OU

}

Set SMTP addresses in batches

1. Prepare a CSV file, which can have name and mailaddress fields

2. $user |% {set-mailbox-identity $_ .mailaddress @ {@ = $_ .mailaddress}}

In this way, smtp addresses can be added in batches.

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