Use FORM to add DNS records


hi all,

i new powershell, please forgive me if dont understand basic logic of powersell.

last week started adding new dns records powershell. today like, ok, kewl make little gui adds dns records. watched youtube movies , downloaded primalscript. made form needed textboxes, , @ end want add dns record using add-dns.... command variables textboxes.

before start testing ( can test in production environment ) have questions script ready testing.

1. near bottom of script there line: if ($form1.showdialog() -eq 0). reflect cancel button scriptblock? scriptblock having 'dialogresult = 0'. while line @ bottom of script says 'showdialog'.

2. want run tool (can make .exe out of it) on remote server. mean have add couple of other commands, "import-module dnsserver", , guess "enter-pssession hostname_dns_server". should place 2 additional commands? can add them anywhere in top of script? or should somehow merge them last command 'add-dns.....' ?

3. $result in last line execute add-dns... command? me newby looks making variable , putting in it. 

thanks help!

[reflection.assembly]::loadwithpartialname("system.windows.forms")    # create form  $form1 = new-object system.windows.forms.form  $form1.text = "add dns record"  $form1.height = 200  $form1.width = 250  $form1.formborderstyle = 3    # create ok , cancel scriptblocks  $oksb = {  	$form1.dialogresult = 1  	$form1.hide()  }  $cancelsb = {  	$form1.dialogresult = 0  	$form1.hide()  }    # create ok button  $okbutton1 = new-object system.windows.forms.button  $okbutton1.text = "ok"  $okbutton1.height=25  $okbutton1.width=75  $okbutton1.top=130  $okbutton1.left=147  $okbutton1.add_click($oksb)  $form1.controls.add($okbutton1)    # create cancel button  $cancelbutton1 = new-object system.windows.forms.button  $cancelbutton1.text = "cancel"  $cancelbutton1.height=25  $cancelbutton1.width=75  $cancelbutton1.top=130  $cancelbutton1.left=66  $cancelbutton1.add_click($cancelsb)  $form1.controls.add($cancelbutton1)    # create label1  $label1 = new-object system.windows.forms.label  $label1.text = "enter dns name:"  $label1.left=12  $label1.top=9  $label1.width=205  $label1.height=13  $form1.controls.add($label1)    # create text box1  $text1 = new-object system.windows.forms.textbox  $text1.left=15  $text1.top=25  $text1.height=20  $text1.width=205  $form1.controls.add($text1)    # create label3  $label3 = new-object system.windows.forms.label  $label3.text = "enter dns zone:"  $label3.left=12  $label3.top=50  $label3.width=205  $label3.height=13  $form1.controls.add($label3)    # create text box3  $text3 = new-object system.windows.forms.textbox  $text3.left=15  $text3.top=66  $text3.height=20  $text3.width=205  $form1.controls.add($text3)    # create label4  $label4 = new-object system.windows.forms.label  $label4.text = "enter ipv4 address:"  $label4.left=12  $label4.top=91  $label4.width=205  $label4.height=13  $form1.controls.add($label4)    # create text box4  $text4 = new-object system.windows.forms.textbox  $text4.left=15  $text4.top=107  $text4.height=20  $text4.width=205  $form1.controls.add($text4)    # show form 1  if ($form1.showdialog() -eq 0) {  	# cancelled  	break  }    # add dns record  $result = add-dnsserverresourcerecorda -name "$text1.text" -zonename "$text3.text" -allowupdateany -ipv4address "$text4.text" -timetolive 01:00:00  

please ask single scripting question.  issues how use primalscript create exe or access aremote system need post in vendors forum.

what scripting question? errors getting? post compete error message.


¯\_(ツ)_/¯



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

CRL Revocation always failed

Failed to query the results of bpa xpath

0x300000d errors in Microsoft Remote Desktop client