понедельник, 19 декабря 2016 г.

Перенос пользователей из списка в указанный OU Active Directory

Скрипт на PowerShell. Запуск с повышением прав.

CSV файл создается в Excel. Одна колонка. Первая строка содержит name. Ниже логин пользователя без домена.

clear
# Import AD Module 
import-module ActiveDirectory 

# Import CSV  
$MoveList = Import-Csv -Path "C:\export\otherUser.csv" 
# Specify target OU.This is where users will be moved. 
$TargetOU =  "OU=otherUser,OU=LOCK-OBJ,OU=MAIN,DC=gladspir,DC=ru" 
# Import the data from CSV file and assign it to variable  
$Imported_csv = Import-Csv -Path "C:\export\otherUser.csv"  

$Imported_csv | ForEach-Object { 
     # Retrieve DN of User. 
     $UserDN  = (Get-ADUser -Identity $_.Name).distinguishedName 
     Write-Host " Moving Accounts ..... " 
     # Move user to target OU. 
     Move-ADObject  -Identity $UserDN  -TargetPath $TargetOU 
      
 } 
 Write-Host " Completed move "  
 $total = ($MoveList).count 
 Write-Host "  $total accounts have been moved succesfully..."

Экспорт пользователей из Active Directory в csv

Ниже скрипт на PowerShell. Запуск с повышением прав

clear
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = "LDAP://dc=gladspir,dc=ru"
$objSearcher.Filter = "(&(objectCategory=person)(!userAccountControl:1.2.840.113556.1.4.803:=2))"
$users = $objSearcher.FindAll()
# Количество учетных записей
$users.Count
$users | ForEach-Object {
   $user = $_.Properties
   New-Object PsObject -Property @{
   Должность = [string]$user.description
   Отдел = [string]$user.department
   Логин = [string]$user.userprincipalname
   Телефон = [string]$user.telephonenumber
   MТелефон = [string]$user.mobile
   Комната = [string]$user.physicaldeliveryofficename
   ФИО = [string]$user.cn
   ФАМ = [string]$user.sn
   ИМЯ = [string]$user.givenname
   ГОРОД = [string]$user.l
   МЫЛО = [string]$user.mail
   РасположениеАД = ([string]$user.distinguishedname).Substring( `
    ([string]$user.distinguishedname).IndexOf("OU") `
    , ` 
    ([string]$user.distinguishedname).Length - ([string]$user.distinguishedname).IndexOf("OU"))
   ПоследнийВход = [datetime]::FromFileTime([string]$user.lastlogon).ToString('g')
    }
} | Export-Csv -NoClobber -Encoding Unicode -Path  C:\export\list_users_act.csv

Failed to install module libnvdimmvmxnet3

The fix is this: in /etc/dracut.conf.d/*.conf > nvdimm-security.conf > vmware-tools.conf, edit the "add_drivers" line to ...