在powershell中输出 [英] Outputting in powershell
本文介绍了在powershell中输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下午好,
我需要使用AWS s3 ls命令并将其自动输出到文本框,而不是在按钮按下时执行。我怎样才能做到这一点?
[void] [System.Reflection.Assembly] :: LoadWithPartialName(System.Drawing)
[void ] [System.Reflection.Assembly] :: LoadWithPartialName(System.Windows.Forms)
$ Form = New-Object System.Windows.Forms.Form
$ Form.Size = New-Object System.Drawing.Size(600,400)
############################### ###############开始函数
函数s3Info {
$ s3Result = aws s3 ls | fl |乱串;
$ outputBox.text = $ s3Result
} #end s3Info
####################### ####################### end functions
############# #################################开始文本字段
$ outputBox = New-Object System.Windows.Forms.TextBox
$ outputBox.Location = New-Object System.Drawing.Size(10,150)
$ outputBox.Size = New-Object System.Drawing.Size(565,200) )
$ outputBox.MultiLine = $ True
$ outputBox.ScrollBars =Vertical
$ Form.Controls.Add($ outputBox)
#### ########################################## end text fields
###############################################开始按钮
$ Button = New-Object System.Windows.Forms.Button
$ Button.Location = New-Object System.Drawing.Size(400,30)
$ Button .Size = New-Object System.Drawing.Size(110,80)
$ Button.Text =Ping
$ Button.Add_Click({s3Info})
$ Form.Controls。添加($ Button)
###################### ######################## end按钮
$ Form.Add_Shown({$ Form.Activate()})
[void] $ Form.ShowDialog()
我尝试了什么:
我试图删除该函数并向outputBox.text添加一个out-string而没有正面结果。
解决方案
< blockquote> Form = New-Object System.Windows.Forms.Form
Form.Size = New-Object System.Drawing.Size(600,400)
## #################################################### $ $
$ b函数s3Info {
s3Result = aws s3 ls | fl |出字符串;
Good Afternoon,
I need to utilize the AWS s3 ls command and have it automatically output to the textbox, instead of being required to execute on button push. How can I make this happen?
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$Form = New-Object System.Windows.Forms.Form
$Form.Size = New-Object System.Drawing.Size(600,400)
############################################## Start functions
function s3Info {
$s3Result= aws s3 ls | fl | out-string;
$outputBox.text=$s3Result
} #end s3Info
############################################## end functions
############################################## Start text fields
$outputBox = New-Object System.Windows.Forms.TextBox
$outputBox.Location = New-Object System.Drawing.Size(10,150)
$outputBox.Size = New-Object System.Drawing.Size(565,200)
$outputBox.MultiLine = $True
$outputBox.ScrollBars = "Vertical"
$Form.Controls.Add($outputBox)
############################################## end text fields
############################################## Start buttons
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size(400,30)
$Button.Size = New-Object System.Drawing.Size(110,80)
$Button.Text = "Ping"
$Button.Add_Click({s3Info})
$Form.Controls.Add($Button)
############################################## end buttons
$Form.Add_Shown({$Form.Activate()})
[void] $Form.ShowDialog()
What I have tried:
I have tried to remove the function and add just an out-string to outputBox.text with no positive results.
解决方案
Form = New-Object System.Windows.Forms.Form
Form.Size = New-Object System.Drawing.Size(600,400) ############################################## Start functions function s3Info {
s3Result= aws s3 ls | fl | out-string;
这篇关于在powershell中输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文