Active IQ Unified Manager Discussions
Active IQ Unified Manager Discussions
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!!!!
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
Do you have a sample ?
Thank You,
John Marotta
USAA, Storage Management
913-2596
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
just echos back the cmd but $aduser does not contain the data from the cmd.
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
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
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
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
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
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
-
john.marotta@xxxx.xxx<mailto:john.marotta@xxxx.xxx>
Thank You,
John Marotta
USAA, Storage Management
913-2596
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