popscreen to fill in data

Hi People,

I want to create a script that when i run it, there is a pop-up where i can fill in the data that is needed lik.
activate windows server

$slmgr = slmgr -ipk 
slmgr -upk

not sure if this is what your after

“Enter Data” would be the question you want to ask not the data held in string, Run it you will see what i mean

$data = Read-Host "Enter Data "

#$data now contains whatever you wrote#

Also want to note that slui.exe is kind of the GUI version of slmgr. It will prompt the user to enter a key and activate for you, no need to build anything around slmgr.

function Call-tb_psf {

	[void][reflection.assembly]::Load('System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089')
	$form1 = New-Object 'System.Windows.Forms.Form'
	$button1 = New-Object 'System.Windows.Forms.Button'
	$textbox1 = New-Object 'System.Windows.Forms.TextBox'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	 $script:text = $textbox1.text
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$form1.WindowState = $InitialFormWindowState
		catch [Exception]
		{ }
	$form1.AutoScaleDimensions = '6, 13'
	$form1.AutoScaleMode = 'Font'
	$form1.ClientSize = '287, 95'
	$form1.Name = 'form1'
	$form1.Text = 'Form'

	$button1.DialogResult = 'OK'
	$button1.Location = '164, 60'
	$button1.Name = 'button1'
	$button1.Size = '75, 23'
	$button1.TabIndex = 1
	$button1.Text = 'button1'
	$button1.UseVisualStyleBackColor = $True
	$textbox1.Location = '36, 29'
	$textbox1.Name = 'textbox1'
	$textbox1.Size = '203, 20'
	$textbox1.TabIndex = 0
	$InitialFormWindowState = $form1.WindowState
	return $form1.ShowDialog()


Call-tb_psf | out-null


Sorry, mayby it was smart for me to tell you guys what the purpose of the script is.

I whant to create a script tu delete and put in a new windows key for servers, and desktops

That can be done i know with just to line that we have to fill in. but i want to create a script that gives me a pop-up screen where i put in the key and it then is be done


Have you tried Mark’s suggestion with Read-Host. It’s probably the simplest method to get input into a script. Then you would use Start-Process to call cscript.exe slmgr.

Mark’s answer also has the added benefit of being accessible to a PSRemoting session. You could push your config to one or more systems from the convenience of your own desk!

If you really must have a GUI, take a look at this blog series: https://foxdeploy.com/2015/04/10/part-i-creating-powershell-guis-in-minutes-using-visual-studio-a-new-hope/

Gui above. There are issues with that building method.

Marks answers works great