Rāda ziņas ar etiķeti Windows 2008. Rādīt visas ziņas
Rāda ziņas ar etiķeti Windows 2008. Rādīt visas ziņas

ceturtdiena, 2013. gada 28. marts

How to add users to ou in domain via Powershell Windows 2008



Before to use PowerShell you have to allow powershell scripts via policy, while there are lot of policies I just allow scripts on separate DomainController with higher access restritions
So you have to type in  PowerShell terminal

Set-ExecutionPolicy Unrestricted

So here are powershell script itself

Import-Module ActiveDirectory 
$Users = Import-Csv -Delimiter ";" -Path ".\userslist.csv"  
foreach ($User in $Users)  
{  
    $OU = "OU=yourou,DC=yourdomain,DC=comorothersuffix"  
    $Password = $User.password 
echo $Password
    $SPassword = ConvertTo-SecureString $Password -AsPlainText -Force 
echo $SPassword
    $Detailedname = $User.firstname
    $SAM =  $User.Name 
    New-ADUser -Name $Detailedname -SamAccountName $SAM -DisplayName $Detailedname -AccountPassword $SPassword -Enabled $true -Path $OU