Author Posts

October 24, 2016 at 10:45 am

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

October 24, 2016 at 11:40 am

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#

October 25, 2016 at 1:05 am

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.

October 25, 2016 at 2:04 pm

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


October 26, 2016 at 6:35 am

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

October 26, 2016 at 12:23 pm

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.

October 26, 2016 at 1:14 pm

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:

October 26, 2016 at 1:32 pm

Gui above. There are issues with that building method.

October 27, 2016 at 6:59 am

Marks answers works great