中的[tag]已解决[/tag]无法在powershell Studio中的GUI的powershell命令中使用我的变量
我在powershell中有点无所事事,我正在尝试在powershell Studio 2018中构建一个简单的用户界面,以便在活动方向上搜索名为like的用户列表。 在Powershell Studio之外,它工作得非常好,但在PS2018内部,我无法在命令中使用变量 我的目标只是在列表框中输出结果 $gui_searchUser01.text在我的鼠标单击事件中很好地返回,所以我将其转换为 “*姓名已输入*” $searchstringADname='*+$gui\U searchUser01.Text+*' 如果我这样做 Get-ADUser-Filter{name-like'*nameintered*'}-Properties name |选择对象名称 它在texbox1中输出良好,但在下一行中不起作用: $ADUser=Get ADUser-Filter{name-like'*+$gui_searchUser01.Text+*'}-Properties-name |选择对象名称 $textbox1.Text=$ADusers $gui_UsersResults01.Items.AddRange[System.Collections.ArrayList]$ADusers** 当然,我也尝试直接将$searchstringADname放入我的命令中,结果相同,不适用于gui,但在经典的powershell中运行良好 另一次尝试无效: $button1\u单击={ TODO:在此处放置自定义脚本 [字符串]$getvalue=$textbox1.Text [字符串]$searchstringADname='*+$getvalue+*' [string]$results=Get ADUser-Filter{name-like$searchstringADname}-Properties name |选择对象名称 $textbox2.Text=$results } $searchstringADname没有返回到命令中,它保持为null,但当我直接将主机写入textbox2时,我得到了我的值$搜索StringAdName!我会自杀的哈哈 解决方案:问题来自我想要使用的Get ADuser。解决我的问题的好语法是: $ADusers=Get ADUser-Filter*-Properties name |其中对象{$\名称-Like$searchstringADname}|选择名称,UserPrincipalName 我在这里找到了我的答案,我停下来关注变量范围的问题:中的[tag]已解决[/tag]无法在powershell Studio中的GUI的powershell命令中使用我的变量,powershell,user-interface,powershell-studio,Powershell,User Interface,Powershell Studio,我在powershell中有点无所事事,我正在尝试在powershell Studio 2018中构建一个简单的用户界面,以便在活动方向上搜索名为like的用户列表。 在Powershell Studio之外,它工作得非常好,但在PS2018内部,我无法在命令中使用变量 我的目标只是在列表框中输出结果 $gui_searchUser01.text在我的鼠标单击事件中很好地返回,所以我将其转换为 “*姓名已输入*” $searchstringADname='*+$gui\U searchUser0