Solved

powershell quest new contact

Posted on 2014-01-23
10
785 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
This video discusses moving either the default database or any database to a new volume.

777 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