Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell添加\单击代码仅写主机工作 [void][System.Reflection.Assembly]::LoadWithPartialName(“System.Drawing”) [void][System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')| Out Null $objForm=新对象System.Windows.Forms.Form $objForm.Text=“邮箱创建向导” $objForm.Size=新对象系统.Drawing.Size(380230) $objForm.StartPosition=“中心屏幕” $objForm.KeyPreview=$True #邮箱新用户检查 $UserButton=新建对象System.Windows.Forms.Button $UserButton.Location=新对象系统.图纸.尺寸(160,70) $UserButton.Size=新对象系统.Drawing.Size(150,23) $UserButton.Text=“检查新用户” $UserButton.Add\u单击({ $global:acns=[Microsoft.VisualBasic.Interaction]::输入框(“输入帐户名”、“确定新帐户”、“atsi”) 如果($ACN){ #如果get邮箱查询的输出有效,则该查询不起作用。例如,如果我放置了一个没有结果或没有有效结果的查询,则会收到一条错误消息。 获取邮箱-标识“$acns” } 否则{ 写入主机“未提供输入” } }) #else{写入主机“$acns”}) $objForm.Controls.Add($UserButton) #取消按钮 $CancelButton=新建对象System.Windows.Forms.Button $CancelButton.Location=新对象系统.图纸.尺寸(10160) $CancelButton.Size=新对象系统.Drawing.Size(150,23) $CancelButton.Text=“取消” $CancelButton.Add_单击({$objForm.Close()}) $objForm.Controls.Add($CancelButton) [void]$objForm.ShowDialog() 写入主机$acns_Forms_Powershell - Fatal编程技术网

Powershell添加\单击代码仅写主机工作 [void][System.Reflection.Assembly]::LoadWithPartialName(“System.Drawing”) [void][System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')| Out Null $objForm=新对象System.Windows.Forms.Form $objForm.Text=“邮箱创建向导” $objForm.Size=新对象系统.Drawing.Size(380230) $objForm.StartPosition=“中心屏幕” $objForm.KeyPreview=$True #邮箱新用户检查 $UserButton=新建对象System.Windows.Forms.Button $UserButton.Location=新对象系统.图纸.尺寸(160,70) $UserButton.Size=新对象系统.Drawing.Size(150,23) $UserButton.Text=“检查新用户” $UserButton.Add\u单击({ $global:acns=[Microsoft.VisualBasic.Interaction]::输入框(“输入帐户名”、“确定新帐户”、“atsi”) 如果($ACN){ #如果get邮箱查询的输出有效,则该查询不起作用。例如,如果我放置了一个没有结果或没有有效结果的查询,则会收到一条错误消息。 获取邮箱-标识“$acns” } 否则{ 写入主机“未提供输入” } }) #else{写入主机“$acns”}) $objForm.Controls.Add($UserButton) #取消按钮 $CancelButton=新建对象System.Windows.Forms.Button $CancelButton.Location=新对象系统.图纸.尺寸(10160) $CancelButton.Size=新对象系统.Drawing.Size(150,23) $CancelButton.Text=“取消” $CancelButton.Add_单击({$objForm.Close()}) $objForm.Controls.Add($CancelButton) [void]$objForm.ShowDialog() 写入主机$acns

Powershell添加\单击代码仅写主机工作 [void][System.Reflection.Assembly]::LoadWithPartialName(“System.Drawing”) [void][System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')| Out Null $objForm=新对象System.Windows.Forms.Form $objForm.Text=“邮箱创建向导” $objForm.Size=新对象系统.Drawing.Size(380230) $objForm.StartPosition=“中心屏幕” $objForm.KeyPreview=$True #邮箱新用户检查 $UserButton=新建对象System.Windows.Forms.Button $UserButton.Location=新对象系统.图纸.尺寸(160,70) $UserButton.Size=新对象系统.Drawing.Size(150,23) $UserButton.Text=“检查新用户” $UserButton.Add\u单击({ $global:acns=[Microsoft.VisualBasic.Interaction]::输入框(“输入帐户名”、“确定新帐户”、“atsi”) 如果($ACN){ #如果get邮箱查询的输出有效,则该查询不起作用。例如,如果我放置了一个没有结果或没有有效结果的查询,则会收到一条错误消息。 获取邮箱-标识“$acns” } 否则{ 写入主机“未提供输入” } }) #else{写入主机“$acns”}) $objForm.Controls.Add($UserButton) #取消按钮 $CancelButton=新建对象System.Windows.Forms.Button $CancelButton.Location=新对象系统.图纸.尺寸(10160) $CancelButton.Size=新对象系统.Drawing.Size(150,23) $CancelButton.Text=“取消” $CancelButton.Add_单击({$objForm.Close()}) $objForm.Controls.Add($CancelButton) [void]$objForm.ShowDialog() 写入主机$acns,forms,powershell,Forms,Powershell,当我在脚本末尾添加“Get Mailbox-Identity$acns”时,它会按预期工作。但是,当我放入add_click时,GUI应用程序没有控制台,所以通常的“将所有未保存的对象都扔到控制台”不适用。您需要指定它应该在控制台中以ex.Out Default,Out Host(Out Default发送到)的形式运行,或者转换为字符串并显示,例如 Get-Mailbox -Identity "$acns" | Out-Default Get-Mailbox -Identity "$acns"

当我在脚本末尾添加“Get Mailbox-Identity$acns”时,它会按预期工作。但是,当我放入add_click时,GUI应用程序没有控制台,所以通常的“将所有未保存的对象都扔到控制台”不适用。您需要指定它应该在控制台中以ex.
Out Default
Out Host
(Out Default发送到)的形式运行,或者转换为字符串并显示,例如

Get-Mailbox -Identity "$acns" | Out-Default
Get-Mailbox -Identity "$acns" | Out-Host
#Since you're still in the GUI-application you won't be able to use the output anyways, so you might as well print it as a string
Get-Mailbox -Identity "$acns" | Out-String | Write-Host

请记住:命令仍然有效,对象可以通过管道传输到
Set Mailbox
等。需要特别注意的只是控制台输出。我建议使用GUI进行用户输出,或者完全跳过GUI/单击后关闭它,让控制台显示其余部分。混合很混乱。

我认为这不是因为GUI,而是因为用
void
返回类型转换为委托<代码>([Action]{Write Output Test}).Invoke()。我不是开发人员,所以我不会争论背后的逻辑。:-)然而,这对我或他有什么帮助?是否有其他类型的EventHandler可用于返回对象的click事件?不管怎么说,只要在窗体关闭之前一直使用
ShowDialoge()
-函数,那么是否取出对象并不重要,因为无论如何,您都无法在管道中进一步处理它,因此对象与文本并不重要。好吧,如果
void
delegate,因为委托返回值将返回给该委托的调用方,而不是PowerShell管道。但你说得不对,即使你卡在
ShowDialoge()
方法中,也可以在管道中对对象进行管道和处理。是的,在
操作中,但正如我在更新的答案中所写,这在他的脚本中已经起作用了。:-)这就是PowerShell管道的工作原理<代码>进程
下一个管道命令块在
WriteObject
调用中工作。您是否使用了其他方法(如
ShowDialog()
)并不重要。尽管如此,如果您使用了其他方法,那么您需要引用连接到正确管道的
PSCmdlet
实例,并且您需要自己调用
WriteObject
,以将项目导入正确的位置。我做了一个演示。