The transition to NetApp MS Azure AD B2C is complete. If you missed the pre-registration, you will be invited to register at next log in.
Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Active IQ Unified Manager Discussions

WFA Query AD

braashcj3

Using the following statement

$aduser = "Get-ADUser -f {SamAccountName -eq $user} -Properties mail | select-Object mail"

Get-WFALogger -Info -message $aduser  ONLY returns the  "Get-ADUser -f {SamAccountName -eq $user} -Properties mail | select-Object mail"

Has anyone been able to get the return and assign it to a variable to work with in WFA?

THanks!!!!

11 REPLIES 11

sinhaa

If you want the value of the attribute mail for the user, the below statement will work.

$aduser = Get-ADUser -Filter {samAccountName -eq $user} -Properties mail |Select-Object "mail"

Get-WFALogger -Info -message $aduser.mail

--------

Your statement as below doesn't work, because you have declared it as a string. This has nothing to do with WFA, it will show similar result if executed with write-host on a powershell console.

$aduser = "Get-ADUser -f {SamAccountName -eq $user} -Properties mail | select-Object mail"

Write-Host $aduser

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

braashcj3

Do you have a sample ?

Thank You,

John Marotta

USAA, Storage Management

913-2596

braashcj3

here is what got:

PS Y:\> $aduser = "Get-ADUser -f {SamAccountName -eq '12345'} -Properties mail | select-Object mail"

PS Y:\> Write-Host $aduser

Get-ADUser -f {SamAccountName -eq '12345'} -Properties mail | select-Object mail

braashcj3

just echos back the cmd but $aduser does not contain the data from the cmd.

sinhaa

Of course, because you are trying the wrong command. I gave you the right one above ( in Green color ). Try that, it will work.

In powershell, anything withing double quotes will be treated as plain strings.

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

braashcj3

Thanks sinhaa, I tried the one you provided in WFA but got this:

$aduser = Get-ADUser -Filter {samAccountName -eq $user} -Properties mail |Select-Object "mail"

Get-WFALogger -Info -message $aduser.mail

The term 'Get-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

This exact cmd does work within powershell and returns the email from the $user:

$aduser = Get-ADUser -Filter {samAccountName -eq $user} -Properties mail |Select-Object mail

Thank You,

John Marotta

USAA, Storage Management

913-2596

sinhaa

You need to Import the ActiveDirectory Module in your WFA command. Since it worked from PS console I assume you have ActiveDirectory PS modules available. Also since its on localhost, you don't need provide credentials.

Type the below in WFA command code to import the Module :

###

Import-Module ActiveDirectory

$aduser = Get-ADUser -Filter {samAccountName -eq $user} -Properties mail |Select-Object "mail"

Get-WFALogger -Info -message $aduser.mail

---

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

braashcj3

Ok thanks again, tried

Import-Module ActiveDirectory

$aduser = Get-ADUser -Filter {samAccountName -eq $user} -Properties mail |Select-Object "mail"

Get-WFALogger -Info -message $aduser.mail

But got this:

Cannot bind argument to parameter 'message' because it is null.

Thank You,

John Marotta

USAA, Storage Management

913-2596

sinhaa

You got this because the $user you have provided has empty mail Attribute and hence the $aduser.mail is null. Does the user you have given has this attribute set? By default mail attributes are NOT set for AD users. To verify, On PS console print like: write-host $aduser.mail

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

braashcj3

Yes the xxxxx is my ID and from the PS console it returns my email

$aduser = Get-ADUser -f {samAccountName -eq 'xxxxx'} -Properties mail |Select-Object mail

mail

-


john.marotta@xxxx.xxx<mailto:john.marotta@xxxx.xxx>

Thank You,

John Marotta

USAA, Storage Management

913-2596

sinhaa

John,

     Post the screencap of your command and the failure message. Also the results from PS console. If you don't want to post here, send me via email at: sinhaa at netapp dot com

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public