Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
Active Directory
New-QADObject error
Last Post 20 Nov 2011 09:34 PM by
Roy Atkins
. 2 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
Greg
New Member
Posts:38
16 Feb 2009 07:40 AM
I am writing a script to create accounts and contacts in AD. Each account gets a contact as well, but I want to create the contact first and then the account. I am using the comlet New QADObject to create the contact, but I am receiving the following error:
Missing expression after unary operator '-'.
At E:\scripts\CreateStudentAccounts.ps1:39 char:11
+ -O <<<< bjectAttributes @{givenName=$_.FirstName;
This is the command I am using:
New-QADObject -ParentContainer $Contact_OU -Type Contact -ObjectAttributes @{givenName=$_.FirstName; sn=$_.LastName; cn=$_.DisplayName; displayName=$_.DisplayName; mail=$_.EmailAddress; mailNickname=$_.Name; title=$_.Title; company=$_.Company; targetAddress='SMTP:'+$_.EmailAddress} -WhatIf
I don't see a problem. Any thoughts? Thanks.
Greg
New Member
Posts:38
16 Feb 2009 07:42 AM
By the way, the contact is mail enabled. Their account will be mail enabled as well and we setup a forwarding to their contact email address.
Roy Atkins
New Member
Posts:1
20 Nov 2011 09:34 PM
Bit late, I know.
Two things
1. You're missing the -Name parameter. This will set the common name (cn) for the object.
2. You cannot use -ObjectAttributes paremeter to set the cn. This is why we have the rename-qadobject cmdlet.
You are not authorized to post a reply.
Using PowerShell
--General PowerShell
--Active Directory
--Exchange Server
--Lync Server
--SharePoint
--SQL Server
--System Center
--Non-Microsoft Products
--Books, Tools, and Videos
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
Active Directory
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2