Solved

powershell quest new contact

Posted on 2014-01-23
10
802 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

705 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