Solved

powershell quest new contact

Posted on 2014-01-23
10
764 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 68

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
 
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
Don't lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

 

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 68

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
In this video we show how to create a User Mailbox 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 Recipients >> Mailb…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now