Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Import from CSV, set Dial in Tab and ad to user

$
0
0

Hi All

I'm going to aplogise in advance for this - its been many years since I've done any coding so am doing a crash-course in Powershell - it will be evident in what I post!

I am struggling with setting the Dial In tab to active when doing a bulk import from a csv file.  I suspect my syntax is wrong, but I've been looking at it so long that I can't see my error.

I would prefer not to use Quest as I want this to be fairly portable, but so far I can't find a way around it.

Any help very much appreciated. 

 

=========

Import-Module ActiveDirectory
Add-PSSnapin Quest.ActiveRoles.ADManagement
$Users = Import-Csv -Delimiter ";" -Path ".\userslist.csv"
foreach ($User in $Users)
{
    $OU = "OU=Test, DC=test,DC=test,DC=test"
    $password = ConvertTo-SecureString -AsPlainText "Test0nly" -Force
    $Detailedname = $User.firstname + $User.name
    $SAM = $User.Firstname + $User.name
    
    New-ADUser -Name $Detailedname -SamAccountName $SAM -UserPrincipalName ($SAM + '@test') -DisplayName $Detailedname -GivenName $user.firstname -Surname $user.name -AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) -Enabled $true -Path $OU  

# Modify remote access permissions for all users in "example" OU

Get-QADUser -SearchBase 'OU=Test, DC=test,DC=test,DC=test' -Filter * -SizeLimit 0
Set-QADUser -ObjectAttributes @{msNPAllowDialin=$true}|
% { Add-ADGroupMember 'radius' -Members $_ }
}

===========================

error message is

cmdlet Set-QADUser at command pipeline position 1
Supply values for the following parameters:
Identity: Get-QA
Set-QADUser : Cannot resolve directory object for the given identity: 'Get-QA'.
At line:10 char:12
+ Set-QADUser <<<<  -ObjectAttributes @{msNPAllowDialin=$true}|
    + CategoryInfo          : NotSpecified: (:) [Set-QADUser], ObjectNotFoundException
    + FullyQualifiedErrorId : Quest.ActiveRoles.ArsPowerShellSnapIn.DirectoryAccess.ObjectNotFoundException,Quest.Acti
   veRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.SetUserCmdlet

 


Viewing all articles
Browse latest Browse all 8583

Trending Articles