Not working as expected
Posted: Fri Oct 24, 2014 1:18 pm
I have the following code in a form:
foreach ($item in $vara)
{
[String]$item = $item
if ($item -match 'User=212Z')
{
[array]$lookupmailaddress = Get-ADObject -LDAPFilter "(sAMAccountName=$tempsamconvert)" -SearchBase 'DC=212Z,DC=mgd2,DC=msft,DC=net' -Properties * -Server 212Z.msft.net | Select-Object mail
}
Else
#do something else.
When I set the $vara from the shell to the SAM account name ($NVP000-H8RNU4T06F1P) and then run the above code:
Get-ADObject -LDAPFilter "(sAMAccountName=$tempsamconvert)" -SearchBase 'DC=212Z,DC=mgd2,DC=msft,DC=net' -Properties * -Server 212Z.msft.net | Select-Object mail
it works? Just not in the application. Can someone help explain this? It's passing the same value in $tempsamconvert as I typed out and set in the shell. It's just being set in the form not on the shell.
Thank you.
foreach ($item in $vara)
{
[String]$item = $item
if ($item -match 'User=212Z')
{
[array]$lookupmailaddress = Get-ADObject -LDAPFilter "(sAMAccountName=$tempsamconvert)" -SearchBase 'DC=212Z,DC=mgd2,DC=msft,DC=net' -Properties * -Server 212Z.msft.net | Select-Object mail
}
Else
#do something else.
When I set the $vara from the shell to the SAM account name ($NVP000-H8RNU4T06F1P) and then run the above code:
Get-ADObject -LDAPFilter "(sAMAccountName=$tempsamconvert)" -SearchBase 'DC=212Z,DC=mgd2,DC=msft,DC=net' -Properties * -Server 212Z.msft.net | Select-Object mail
it works? Just not in the application. Can someone help explain this? It's passing the same value in $tempsamconvert as I typed out and set in the shell. It's just being set in the form not on the shell.
Thank you.