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.
Dialog Form not displaying IP Address information in Label
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Dialog Form not displaying IP Address information in Label
- Attachments
-
- 2.png (8.37 KiB) Viewed 4883 times
-
- 1.png (7.37 KiB) Viewed 4883 times
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Dialog Form not displaying IP Address information in Label
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!
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
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.
$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
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
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
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.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!
$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
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]
- Attachments
-
- 3.png (7.97 KiB) Viewed 4600 times
Last edited by dca2rr on Fri Aug 23, 2019 6:31 am, edited 1 time in total.