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
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()
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.
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.
In response to the comment:
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.