?
Solved

Exception calling "SetInfo" with "0" argument(s):

Posted on 2010-11-21
3
Medium Priority
?
3,518 Views
Last Modified: 2012-05-10
I am trying to create a simple user account with vbscripting, yet I can not because of the following error. Can someone pls show me why the error occurs with Setinfo()?

$objUser=[ADSI]"LDAP://OU=People,DC=pit,DC=com,DC=au"
$objUser=$objOU.Create("user","CN=Scott Mitchell")
$objUser.Put("sAMAccountName","Scott Mitchell")
$objUser.SetInfo()

PS C:\Users\Administrator\Documents> .\newusers.ps1
Exception calling "SetInfo" with "0" argument(s): "There is a naming violation. (Exception from HR
At C:\Users\Administrator\Documents\Newusers.ps1:4 char:17
+ $objUser.SetInfo( <<<< )
0
Comment
Question by:Network_Padawan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Expert Comment

by:GundogTrainer
ID: 34186596
Can you confirm you have:
1. Sufficient permissions to create account in that OU.
2. The Samaccountname and user are unique and have not already been created.
0
 
LVL 8

Accepted Solution

by:
GundogTrainer earned 1000 total points
ID: 34186746
Actually looking at it I have noticed the first line appears to be incorrect as it should define the OU for the user object to be create in.

$objOU=[ADSI]"LDAP://OU=People,DC=pit,DC=com,DC=au"

$objUser=$objOU.Create("user","CN=Scott Mitchell")
$objUser.Put("sAMAccountName","Scott Mitchell")
$objUser.SetInfo()
0
 

Author Closing Comment

by:Network_Padawan
ID: 34187267
Doh! Can't believe I missed that.

Thanks
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question