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
Solved

powershell quest new contact

Posted on 2014-01-23
10
792 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
  • 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 69

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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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 69

Accepted Solution

by:
Qlemo earned 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Read this checklist to learn more about the 15 things you should never include in an email signature.
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

839 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