?
Solved

powershell quest new contact

Posted on 2014-01-23
10
Medium Priority
?
808 Views
Last Modified: 2014-01-31
I am trying to run this script and it keeps failing. I am out of ideas as to what could be the issue any help. I am trying to create some contacts any help is appreciated/

   import-csv c:\temp\contacts.csv New-QADObject -Type Contact -Name $_.displayname; -firstname $_.firstname; -lastname $_.lastname -externalemailaddress $_.externalemailaddress }
 

displayname  firstname lastname externalemailaddress
new user      user      last      newuser@hotmail.com
new second      new      app      lastname@hotmail.com
0
Comment
Question by:techdrive
[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
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 8

Expert Comment

by:Jeff Perry
ID: 39804116
You probably need to use "Set-ExecutionPolicy" you can use get-help to get more detail but here are the basics.

Set-ExecutionPolicy Unrestricted

Will allow unsigned powershell scripts to run.

 
Set-ExecutionPolicy Restricted

Will not allow unsigned powershell scripts to run.

 
Set-ExecutionPolicy RemoteSigned

Will allow only remotely signed powershell scripts to run.
0
 

Author Comment

by:techdrive
ID: 39804160
huh? I have been running other scripts successfully and this has been setup for almost a year.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39804197
Is that a copy&paste error, or is a pipe misssing before New-QADObject, and a false semicolon after $_.displayname ?
import-csv c:\temp\contacts.csv |
  New-QADObject -Type Contact -Name $_.displayname `
      -firstname $_.firstname; -lastname $_.lastname `
      -externalemailaddress $_.externalemailaddress }

Open in new window

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 8

Expert Comment

by:Jeff Perry
ID: 39804232
Well without the actual error message I am left to guess what may be the issue, which is why my answer was qualified with "probably".

The most common reason that powershell scripts fail is that running scripts is disabled by default.
0
 

Author Comment

by:techdrive
ID: 39804289
I could not get it to work still and found a few things that could have been wrong
import-csv c:\temp\contacts.csv |
 foreach {New-QADObject -Type Contact -Name $_.displayname `
      -firstname $_.firstname -lastname $_.lastname `
      -externalemailaddress $_.externalemailaddress } 

Open in new window

New-QADObject : A parameter cannot be found that matches parameter name 'firstname'.
At C:\temp\doe.ps1:3 char:17
+       -firstname <<<<  $_.firstname -lastname $_.lastname `
    + CategoryInfo          : InvalidArgument: (:) [New-QADObject], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.NewObjectCmdlet

New-QADObject : A parameter cannot be found that matches parameter name 'firstname'.
At C:\temp\doe.ps1:3 char:17
+       -firstname <<<<  $_.firstname -lastname $_.lastname `
    + CategoryInfo          : InvalidArgument: (:) [New-QADObject], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.NewObjectCmdlet

Open in new window

0
 
LVL 70

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 39804424
Do you have the original content of the script, before you garbled it? There are a lot of keywords missing after and instead of the semicolon, as New-QADObject just doesn't support the parameters as provided.

We could try to fix that all, but I fear there has been more you lost than only the obvious parts.
import-csv c:\temp\contacts.csv | foreach {
  New-QADObject -Type Contact -Name $_.displayname -ObjectAttributes @{
      firstname = $_.firstname
      lastname = $_.lastname
      externalemailaddress = $_.externalemailaddress
  }
}

Open in new window

0
 
LVL 8

Expert Comment

by:Jeff Perry
ID: 39804463
Well I have looked through the PowerGui site and I don't see the -firstname, -lastname, ect...parameters .

I am guessing you will have to use the other permitted parameters of New-QADObject.
0
 

Author Comment

by:techdrive
ID: 39804526
Qlemo looks much better but it is prompting me for the parentcontainer each time. I am going to try and work with this but 80 percent much better than I had before you fixed this, thanks
0
 
LVL 37

Expert Comment

by:Jamie McKillop
ID: 39804665
Hello,

I'm wondering why you are trying to use New-QADObject to create these contacts? Why not just use the native Exchange New-MailContact command?

import-csv c:\temp\contacts.csv |% {
      New-MailContact -Name $_.displayname -FirstName $_.firstname `
     -LastName $_.lastname  -ExternalEmailAddress $_.externalemailaddress `
     -OrganizationalUnit "Contacts"
}

Open in new window


-JJ
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
New style of hardware planning for Microsoft Exchange server.
how to add IIS SMTP to handle application/Scanner relays into office 365.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

752 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