If you need to know the name of the computer of a user or the IP address, then this tiny PowerShell script can become handy. For example, that information might be required for remote assistance software.
There are some tools out there that show this info, e.g. BgInfo, but they don’t always work. Moreover, some users insist on seeing an unobstructed photo of their puppy they just got from a shelter. That’s a big one!
1) Create a PowerShell script file with this content:
Add-Type -AssemblyName System.Windows.Forms $ip=get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1} $ipaddress = $ip.ipaddress[0] $pcname = [System.Net.Dns]::GetHostName() [System.Windows.Forms.MessageBox]::Show("My PC name - $pcname `n`nMy IP address - $ipaddress",'About my PC','OK','Information')
This script is a modified combination of scripts out there that other people made, so by no means I’m trying to take any credits for it.
2) Put this script to a network location that every user has Read access to.
3) Create a Shortcut that runs PowerShell and points to that location:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -ExecutionPolicy Bypass -File "\\networklocation\software$\info.ps1"
4) Optionally change its icon.
5) Distribute that Shortcut to all users’ computers through a policy.
RESULT
When users open that Shortcut, a window will pop up, then they can pass all that info to you as an admin:
Just what I needed . Thank you very much.
Awesome, Rob!
Hi Pavel, How can the script show all IP addresses? Say you have a PC with a WiFi connection & an Ethernet connection and then connecting in via VPN?
Rob,
Replace this:
$ipaddress = $ip.ipaddress[0]
With this:
$ipaddress = $ip.ipaddress -join “; “
Not the best looking and you might want to do more filtering and digging but that’s how you show them all.
hey Pavel
how can i add my company logo to the script ?
and how to make bold text /
tnx 🙂
Hi Sapiro,
As far as I know there is no way to perform either of the tasks you mentioned.
Hi i just tested this script on my non domain laptop its work normally,but when tested this on domain joined laptop i got error and ip address doesnt display.
there is showed cannot index into a null array ..
Hi Mutu,
The only array within that script is the array of IP addresses. So I would suggest you dig into that by checking the script in PowerShell line by line to see what those lines return.
Cannot index into a null array.
At C:\Users\…….\Desktop\systeminfo.ps1:3 char:28
+ $ipaddress = $ip.ipaddress[ <<<< 0]
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
I not good on scripting…
I’ve got a domain joined PC and it’s working fine. Like I said for some reason you are getting an empty array of IP addresses, none.
Give Google a shot and try to find different ways of getting IP addresses through PowerShell.
change this string
$ip=get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1}
to this
$ip=Get-NetIPAddress -AddressFamily IPv4|Where {$_.Ipaddress.length -gt 1}
works for me
What would I need to add if I wanted to drop a link to a site?
Hi Frank,
I don’t think it’s possible to do that as those pop-up windows are very basic.
Hi,
How can this start automatically with this script clicking on it? If i try (as .ps1 saved) just open the script don t execute it…
Hello,
If your company has an RMM system, then usually it can be done through those. IF you are trying to make it work for yourself, then here is a link that should help: https://stackoverflow.com/questions/20575257/how-do-i-run-a-powershell-script-when-the-computer-starts
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command “C:\scripts\script.ps1”