Something like this?

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strMail = CurrentUser.Mail
strDisplayName = CurrentUser.DisplayName
strUserPrincipalName = CurrentUser.userPrincipalName
strSamAccountName = CurrentUser.samAccountName

From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of James Rankin
Sent: Monday, June 27, 2016 12:21 PM
To: ntsysadm@lists.myitforum.com
Subject: RE: [NTSysADM] RE: PowerShell weaknesses

Open to all suggestions…that might indeed be better. I was disappointed to find 
I couldn’t use something like dsquery…

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Stephen Gestwicki
Sent: 27 June 2016 17:12
To: ntsysadm@lists.myitforum.com<mailto:ntsysadm@lists.myitforum.com>
Subject: RE: [NTSysADM] RE: PowerShell weaknesses

Why don’t you use ADSI instead of installing RSAT on everyone’s computers?
http://stackoverflow.com/questions/10184052/get-a-users-email-address-from-the-username-via-powershell-and-wmi

- Stephen

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of James Rankin
Sent: Monday, June 27, 2016 11:58 AM
To: ntsysadm@lists.myitforum.com<mailto:ntsysadm@lists.myitforum.com>
Subject: RE: [NTSysADM] RE: PowerShell weaknesses

Actually might be worth extending this debate slightly…

I’m trying to build Outlook signature files on the fly using AD attributes. So 
I basically need to grab certain AD attributes and set them as variables. This 
is not a problem.

However, as I am doing this at user first logon, I need to query the AD 
attributes in the context of the user. Get-ADUser is the cmdlet I’m using, but 
this is unavailable on my Windows 10 clients unless I install the RSAT. So…

Is there a way to programmatically install the RSAT feature on Windows 10 with 
the AD PowerShell stuff enabled? I’d rather not have to go back and create a 
new image.

I found Enable-WindowsOptionalFeature but don’t seem to be able to crack the 
right syntax for it…

Cheers,



JR

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com] On Behalf Of Charles F Sullivan
Sent: 27 June 2016 16:29
To: ntsysadm@lists.myitforum.com<mailto:ntsysadm@lists.myitforum.com>
Subject: RE: [NTSysADM] RE: PowerShell weaknesses

I was going to suggest:

Get-ADUser -identity jrankin -Properties mail

That will get you the defaults plus Mail.
I mention this because I find it easier to remember, though of course it’s a 
matter of preference.


From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com>] 
On Behalf Of James Rankin
Sent: Monday, June 27, 2016 10:41 AM
To: ntsysadm@lists.myitforum.com<mailto:ntsysadm@lists.myitforum.com>
Subject: [NTSysADM] RE: PowerShell weaknesses

Doh!

Put it in brackets would be the thing I’m missing

(Get-ADUser -filter jrankin -Properties mail).mail

Never mind…. ☺


From: James Rankin
Sent: 27 June 2016 15:39
To: 'ntsysadm@lists.myitforum.com<mailto:ntsysadm@lists.myitforum.com>' 
<ntsysadm@lists.myitforum.com<mailto:ntsysadm@lists.myitforum.com>>
Subject: PowerShell weaknesses

How can I used Get-ADUser to query a single attribute for a specific user? If I 
use something like

Get-ADUser -filter jrankin -Properties mail

To query the email address in AD, I don’t just get that attribute returned, I 
get a bunch of default stuff too…

DistinguishedName : CN=James Rankin,OU=Desktop1,OU=Standard Users,OU=User 
Accounts,DC=JRR,DC=test,DC=local
Enabled           : True
GivenName         : James
mail              : ja...@htguk.com<mailto:ja...@htguk.com>
Name              : James Rankin
ObjectClass       : user
ObjectGUID        : 694d15e1-d550-483a-8f21-cb7415f05342
SamAccountName    : jrankin
SID               : S-1-5-21-2950944927-1203068717-1704750700-1114
Surname           : Rankin
UserPrincipalName : jran...@jrr.test.local<mailto:jran...@jrr.test.local>

Am I missing something blatantly obvious here?

Cheers,


James Rankin
EUC Solutions Architect | 07809 668579 | ja...@htguk.com<mailto:ja...@htguk.com>
One Trinity Green, Eldon Street, South Shields, Tyne & Wear, NE33 1SA
Tel: 0191 481 3446



-----------------------------------------
This message, and any attachments to it, may contain information that is 
privileged, confidential, and exempt from disclosure under applicable law.  If 
the reader of this message is not the intended recipient, you are notified that 
any use, dissemination, distribution, copying, or communication of this message 
is strictly prohibited.  If you have received this message in error, please 
notify the sender immediately by return e-mail and delete the message and any 
attachments.  Thank you.

Reply via email to