How can I pass a Data Item/value into a PowerShell script as a parameter?

bxe445

New Member
I'm currently looping through a collection containing emails I'd like to query within AD using Utility - PowerShell. My current PowerShell script is as follows:

"Param (
[String]$email
)

Get-ADUser -Filter {EmailAddress -eq $email} -Properties name | Select SamAccountName"

and my 'Parameters' input contains the following: "email = ", where Email is a data item containing the email from the current record within the collection. This approach does not seem to work, and the output collection is populated with empty cells where the 'SamAccountName' should be returned. If I pass an example email into the 'Parameters' input the expected return is generated, but I can't seem to use the value stored within a data item in this way. I'm considering storing the value in the data item in a text file to be continuously updated and subsequently accessed by PowerShell each time, but that approach would be rather long winded especially if there's an easier way to plug in the value.
 
Top