是否可以有一个窗口来插入由powershell制作的数据? [英] is it possible to have a window to insert data made by powershell?

查看:20
本文介绍了是否可以有一个窗口来插入由powershell制作的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在服务器上宣布我的更改时,我总是使用我的相当大的 xml 文件,我会搜索我的内容的正确位置,例如 servernametimedata 和我的 name 他们处于不太舒服的位置,我想自动化一点.是否有可能像我的绘画作品那样使用 powershell 制作的图形界面"?

when I announce my changes on a server i always use my xml file which is pretty big and I search for the right place of my content like servername , time , data and my name they are at a not so comfortable postion and I want to automate this a bit. Is it possible to have a "graphical interface" made by powershell like my paint work shows ?

然后我将我的数据插入到 4 个列中,然后将它们放置在正确的位置.

And than I insert my data into the 4 colums which are then placed at the right position.

如果可能,有人可以给我 cmdlet 的名称或其他任何名称吗?然后我会弄清楚如何使用它..

If it is possible, can someone give me the name of the cmdlet or whatever it is ? i will figure out how to use it then..

推荐答案

TechNet 有一个 有用指南 使用 Windows 窗体使用 powershell 创建一个简单的输入框.本质上,您使用 New-Object 创建 System.Windows.Forms 命名空间 并在使表单可见之前根据自己的喜好设置对象属性.表单对象是您的基础"对象,您可以从那里添加标签、按钮、列表框和其他方便的表单元素,如下所示:

TechNet has a useful guide to create a simple input box with powershell using Windows Forms. Essentially you use New-Object to create form objects of the System.Windows.Forms Namespace and set object properties to your liking before you make the form visible. The form object is your "base" object, and from there you can add labels, buttons, listboxes, and other handy form elements like so:

# The Base Form
$myForm = New-Object System.Windows.Forms.Form 
$myForm.Text = "My Form Title"
$myForm.Size = New-Object System.Drawing.Size($width, $height) 
$myForm.StartPosition = "CenterScreen"

# Add a Form Component
$myFormComponent = New-Object System.Windows.Forms.Button
... Set component properties ...
$myForm.Controls.Add($myFormComponent)

.. Add additional components to build a complete form ...

# Show Form
$myForm.Topmost = $True
$myForm.Add_Shown({$myForm.Activate()})
[void] $myForm.ShowDialog()

一旦你完成了这些组件的修改,你就会想要这样做.按照任何类似的通过 powershell 创建 Windows 窗体的在线指南应该足以让您开始接受输入.

You'll want to do that once you've finished modifying those components. Following any similar online guide for creating a windows form via powershell should be enough to get you started accepting input.

接受输入后,您可以将每种类型的时间、数据、服务器和名称"存储在不同的变量中,并根据需要对 XML 文件进行操作.

Once you've accepted input, you can store each type "time, data, server, and name" in different variables and operate on your XML file as needed.

回应评论:

您添加的每个组件都应该与自身隔离,您可以使用变量获取/设置您想要的任何内容.使用 TextBox 的 text 属性成分.例如:

Each component you add should be isolated to itself and you can get/set whatever content you want there with variables. Use the text property of the TextBox component. So for example:

$myTextBox = New-Object System.Windows.Forms.TextBox 

// Assign content to a string.
$myTextBox.Text = "Text Goes Here"

// Assign content to an existing variable.
$myTextBox.Text = $myString

// Store content in a variable.
$myString = $myTextBox.Text

对于两个文本字段,您只需制作另一个独特的文本框,如上所示.请记住,您的独特组件在范围内是孤立的.

For two textfields, you just make another unique textbox as demonstrated above. Remember, your unique components are isolated in scope.

这篇关于是否可以有一个窗口来插入由powershell制作的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆