Page 1 of 2
Dialog Form not displaying IP Address information in Label
Posted: Thu Aug 15, 2019 11:14 am
by dca2rr
First of all, I am new to PowerShell Studio and I am loving it.
I am running PowerShell studio 2018.
Here is my script
$form1_Load = {
#TODO: Initialize Form Controls here
$env:computername
$label1.Text = "$env:COMPUTERNAME"
$label2.Text = 'Your Computer name is;'
$info = Get-NetIPAddress NetIPAddress | select-object IPAddress
$label3.Text = "$($info.Caption)"
$label1_Click = {
#TODO: Place custom script here
}
My label number 3 is not displaying anything in the form, I left more than enough space in the box to make sure the data fits. I am not getting any errors just nothing is displaying. Labels 1 and 2 are perfect. This is how it looks like, please help.
Re: Dialog Form not displaying IP Address information in Label
Posted: Thu Aug 15, 2019 11:22 am
by mxtrinidad
Simple!
You are saving only the IPAddress property in your $Info variable.
Change $label3.Text = "$($info.Caption)" to $label3.Text = "$($info.IPAddress)"
It should work!
Re: Dialog Form not displaying IP Address information in Label
Posted: Thu Aug 15, 2019 11:55 am
by jvierra
A much simpler way to the following:
$label3.Text = (Get-NetIPAddress -InterfaceAlias Wi-Fi).IpAddress |Out-String
This will return multiple addresses if that is what you want. Adapaters will nearly always have from 2 to 6 or more IP addresses. The name is called "InterfaceAlias" and is not the default.
Re: Dialog Form not displaying IP Address information in Label
Posted: Thu Aug 15, 2019 11:58 am
by jvierra
You can also do it like this:
Code: Select all
$label3.Text = Get-NetAdapter Wi-Fi |Get-NetIPAddress | select -Expand IpAddress | Out-String
Re: Dialog Form not displaying IP Address information in Label
Posted: Thu Aug 15, 2019 12:10 pm
by dca2rr
You are awesome! That did it. Now, how can I display the IP’s in a column instead of a row? I really appreciate your expertise.
Re: Dialog Form not displaying IP Address information in Label
Posted: Thu Aug 15, 2019 1:24 pm
by jvierra
dca2rr wrote: ↑Thu Aug 15, 2019 12:10 pm
You are awesome! That did it. Now, how can I display the IP’s in a column instead of a row? I really appreciate your expertise.
That is what my example does.
Re: Dialog Form not displaying IP Address information in Label
Posted: Mon Aug 19, 2019 12:02 pm
by dca2rr
mxtrinidad wrote: ↑Thu Aug 15, 2019 11:22 am
Simple!
You are saving only the IPAddress property in your $Info variable.
Change $label3.Text = "$($info.Caption)" to $label3.Text = "$($info.IPAddress)"
It should work!
I hate to bug you mxtrinidad but, since you fixed my other problem I am hoping you can help me again. Now I need to display the OS Version ( build ) This is what I got but again is not displaying the OS build in the label.
$form1_Load={#TODO: Initialize Form Controls here
$os = (Get-CimInstance Win32_OperatingSystem).version
$label1.Text = "$($os.version)"}
}
Re: Dialog Form not displaying IP Address information in Label
Posted: Mon Aug 19, 2019 12:21 pm
by jvierra
Simple.
$label1.Text = (Get-CimInstance Win32_OperatingSystem).version
Re: Dialog Form not displaying IP Address information in Label
Posted: Mon Aug 19, 2019 12:29 pm
by dca2rr
jvierra wrote: ↑Mon Aug 19, 2019 12:21 pm
Simple.
$label1.Text = (Get-CimInstance Win32_OperatingSystem).version
That worked perfect! thanks a million man
Re: Dialog Form not displaying IP Address information in Label
Posted: Fri Aug 23, 2019 4:53 am
by dca2rr
dca2rr wrote: ↑Mon Aug 19, 2019 12:29 pm
jvierra wrote: ↑Mon Aug 19, 2019 12:21 pm
Simple.
$label1.Text = (Get-CimInstance Win32_OperatingSystem).version
That worked perfect! thanks a million man
One more for you
Hi guys,
Is there a way to exclude the 169.254 addresses? Also how do I get the actual Windows Version no the build number? Like this
Here is my script
$formComputerSupportInfor_Load = {
#TODO: Initialize Form Controls here
$env:computername
$label1.Text = "$env:COMPUTERNAME"
$label2.Text = 'Your Computer name is:'
$info = Get-NetIPAddress -AddressFamily ipv4
$label3.Text = "$($info.IPAddress)"
$label4.Text = 'IPV4 Information'
$os = (Get-CimInstance Win32_OperatingSystem).version
$label6.Text = (Get-CimInstance Win32_OperatingSystem).version
$label5.Text = 'Your Windows 10 Build is:'
Get-CimInstance
}
$label1_Click = {
#TODO: Place custom script here
}
$label3_Click={
#TODO: Place custom script here
}
[/img]img]