[SOLVED] I can't use my Textbox Variable in my commands.
Posted: Wed Aug 21, 2019 4:24 am
Hi,
I'm having always the same problem in Powershell Studio and i have tried a lot of things and i can't resolve this problem. I have check a lot of articles on google and nothing works You are my last hope
My problem is simple and happen in many exemples, i can't use my variables in commands like in Powershell ISE ! And i'm sure it's an easy mistake from me but i do not understand.
On powershell ISE i got this return :
$ADusers
displayname
-----------
John CONNOR
John CONNOR2
On powershell Studio i got nothing. $ADusers is empty and i think it's because my $getMembers is not transformed with her value "connor" in the command. But i maybe made a mistake about that. Maybe a full part of the command is not interpreted but i don't see why.
Can you help me ?
Thanks
I'm having always the same problem in Powershell Studio and i have tried a lot of things and i can't resolve this problem. I have check a lot of articles on google and nothing works You are my last hope
My problem is simple and happen in many exemples, i can't use my variables in commands like in Powershell ISE ! And i'm sure it's an easy mistake from me but i do not understand.
- #i'm backing up my AD in a variable.
- $ADcache = Get-ADUser -Filter * -Properties SamAccountName, UserPrincipalName, Name, displayname | Select-Object SamAccountName, UserPrincipalName, Name, displayname
- #I write-host it to be sure it's full (And it is)
- Write-host $ADcache
- #Then i get a value from my textbox (Exemple connor entered with keyboard who is in my AD)
- [string]$script:getMembers = $gui_searchUser01.Text
- #I write-host both to be sure the variables are feed (And they are both with connor)
- Write-host $gui_searchUser01.Text
- Write-host $script:getMembers
- #So i try to do my filtering on the AD cache (It works well in powershell ISE with same code)
- $ADusers = $ADcache | select-object displayname | Where-Object { $_.displayname -Like "*$getMembers*" } | sort-object displayname
- #or
- $ADusers = $ADcache | select-object displayname | Where-Object displayname -like "*$getMembers*" | sort-object displayname
$ADusers
displayname
-----------
John CONNOR
John CONNOR2
On powershell Studio i got nothing. $ADusers is empty and i think it's because my $getMembers is not transformed with her value "connor" in the command. But i maybe made a mistake about that. Maybe a full part of the command is not interpreted but i don't see why.
Can you help me ?
Thanks