I'm a PS noob myself but, trying to learn so excuse me if I'm wrong but...........wouldn't the column heading be "employeegui"?
-oa
@{ipphone=$_.ipphone;mobile=$_.mobile;employeeid=$_.employeeid;employeenumber=$_.employeegui}
`
Regards,
Don Guyer
Catholic Health East - Information Technology
Enterprise Directory & Messaging Services
3805 West Chester Pike, Suite 100, Newtown Square, Pa 19073
email: [email protected]<mailto:[email protected]>
Office: 610.550.3595 | Cell: 610.955.6528 | Fax: 610.271.9440
For immediate assistance, please open a Service Desk ticket or call the
helpdesk @ 610-492-3839.
[cid:[email protected]]
From: Candee [mailto:[email protected]]
Sent: Wednesday, April 17, 2013 11:48 AM
To: NT System Admin Issues
Subject: Re: PowerShell noob help
nah, I tried that. The column heading is employeenumber, but no data is
exported.
I have to add the attribute to the $creatednames array somehow.
On Wed, Apr 17, 2013 at 11:20 AM, Guyer, Don
<[email protected]<mailto:[email protected]>> wrote:
Wouldn't you just change "$createdusers|select
name,displayname,email|export-csv "C:\temp\scripts\Epicor_export.csv" -notype"
to
"$createdusers|select name,displayname,employeenumber,email|export-csv
"C:\temp\scripts\Epicor_export.csv" -notype"?
Regards,
Don Guyer
Catholic Health East - Information Technology
Enterprise Directory & Messaging Services
3805 West Chester Pike, Suite 100, Newtown Square, Pa 19073
email: [email protected]<mailto:[email protected]>
Office: 610.550.3595<tel:610.550.3595> | Cell: 610.955.6528<tel:610.955.6528>
| Fax: 610.271.9440<tel:610.271.9440>
For immediate assistance, please open a Service Desk ticket or call the
helpdesk @ 610-492-3839<tel:610-492-3839>.
[cid:[email protected]]
From: Candee [mailto:[email protected]<mailto:[email protected]>]
Sent: Wednesday, April 17, 2013 10:46 AM
To: NT System Admin Issues
Subject: Re: PowerShell noob help
Thanks!
I will see if I can figure out how.
:)
On Wed, Apr 17, 2013 at 9:19 AM, Michael B. Smith
<[email protected]<mailto:[email protected]>> wrote:
I don't use the QAD tools, but my guess is that New-QadUser does not return
employeeNumber as one of the attributes of the resulting object. You would
need to add that.
From: Candee [mailto:[email protected]<mailto:[email protected]>]
Sent: Wednesday, April 17, 2013 8:37 AM
To: NT System Admin Issues
Subject: Re: PowerShell noob help
Okay you guys...
here it is; credit card numbers changed to protect the innocent.
;)
Any advice is appreciated - I can take it. Really.
When it's done it sends the logs and newusers file to me.
Thanks all!
___________________________________________
#Import from HR
#Create SAM, UPN
#modified 4/16/2013 - CDV
Import-module activedirectory
add-PSSnapin quest.activeroles.admanagement
$newusers = "C:\temp\scripts\newusers_ver2.csv"
$date = Get-Date
#Exchange database for new mailboxes
$userdb = "ops"
#specify path to save log file
$logpath = "C:\temp\scripts\Error.logs"
#parent container for all new users
$OU = 'ourdomain.local/organization/internal/us/greene/newusers'
#create password
$pass = ConvertTo-SecureString -asplaintext R@ym0nd!! -Force
#Set Domain Controller
Set-ADServerSettings -PreferredServer usnygrds01.ourdomain.local
#Set Domain root
$DNSROOT = '@'+"ourdomain.com<http://ourdomain.com/>"
Start-Transcript C:\temp\scripts\Epicor_Import.logs -append
$createdusers = @()
Import-Csv $newusers |foreach {
$preferredfirstname = $_.preferredfirstname
$lastnamepreferred = $_.lastnamepreferred
$SAM = $preferredfirstname.substring(0,1)+$lastnamepreferred
$UPN = $preferredfirstname +"."+$lastnamepreferred+$DNSROOT
$Displayname = $lastnamepreferred +" "+$preferredfirstname
$Email = $UPN
$testemail = get-recipient -identity $email -ErrorAction SilentlyContinue
$user = Get-QADUser -SamAccountName $SAM
if($user -ne $Null) {
"
*********************************************************************************
$($User.name) already exists -
*****THIS USER NEEDS TO BE MANUALLY CREATED*****
"
} Elseif ($testemail -ne $Null) {
"
*********************************************************************************
$($DISPLAYNAME) Email address already exists
*****THIS MAILBOX NEEDS TO BE MANUALLY CREATED*****"
}ELSE{
"
*********************************************************************************
Creating a new user account for $($DISPLAYNAME)"
$NewUser = New-qaduser -name $SAM `
-parentcontainer $OU `
-userprincipalname $UPN `
-samaccountname $SAM `
-displayname $displayname `
-mail $email `
-givenname $_.preferredfirstname`
-sn $_.lastnamepreferred `
-userPassword $pass `
-company $_.Company `
-department $_.department -title $_.businesscardtitle -telephonenumber
$_.telephone `
-city $_.city -postalcode $_.zip -state $_.state `
-streetaddress $_.street -manager $_.manager `
-oa
@{ipphone=$_.ipphone;mobile=$_.mobile;employeeid=$_.employeeid;employeenumber=$_.employeegui}
`
start-sleep -s 10
if($_.mailenabled -eq 'true') {
"Creating a mailbox for $($Newuser.name)"
$Newuser |foreach-object {enable-mailbox -identity $newuser.email -database
$userdb } `
}Else {
"User does not require Email"
}#end of mailenabled
}#end of create new user
$createdusers += $Newuser
$createdusers|select name,displayname,email|export-csv
"C:\temp\scripts\Epicor_export.csv" -notype
}
Stop-transcript
On Wed, Apr 17, 2013 at 7:30 AM, Webster
<[email protected]<mailto:[email protected]>> wrote:
That is why you publish your code so others can use it and help you refine it.
Carl Webster
Consultant and Citrix Technology Professional
http://www.CarlWebster.com<http://www.carlwebster.com/>
From: James Rankin [mailto:[email protected]<mailto:[email protected]>]
Sent: Wednesday, April 17, 2013 4:43 AM
To: NT System Admin Issues
Subject: Re: PowerShell noob help
Well that lil' bit of PS worked so well I did a blog post about it (naturally
with appropriate credits)
http://appsensebigot.blogspot.co.uk/2013/04/flagging-os-of-device-connecting-to.html
This is about the time I will find out it doesn't work on anyone else's
infrastructure and have to spend weeks rewriting it :-(
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
Confidentiality Notice:
This e-mail, including any attachments is the
property of Catholic Health East and is intended
for the sole use of the intended recipient(s).
It may contain information that is privileged and
confidential. Any unauthorized review, use,
disclosure, or distribution is prohibited. If you are
not the intended recipient, please delete this message, and
reply to the sender regarding the error in a separate email.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
Confidentiality Notice:
This e-mail, including any attachments is the
property of Catholic Health East and is intended
for the sole use of the intended recipient(s).
It may contain information that is privileged and
confidential. Any unauthorized review, use,
disclosure, or distribution is prohibited. If you are
not the intended recipient, please delete this message, and
reply to the sender regarding the error in a separate email.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin<<inline: image001.jpg>>
