In the past, we used to use some nice tools like bginfo to display info about user, computer, etc. on the desktop. And there are still places using them.
Powershell module “Pode” allows us, even nonadministrative users, to create a Web site on the computer, without installing Windows’ own Web server features.
And we can use that Web site to display such diagnostic info as a web site too. Every computer can be a web server, displaying info about itself.
If we configue the following powershell script as a logon script, then a Web server starts providing the related web site after the user logs on and this web site will disappear when the user signs out.
Helpd desk people should instruct the user to open a web page like http://127.0.0.1:6645 , so, they can learn the info about the user’s computer.
WebInfo.ps1
# Create the Web page, accumulate it with the relevant info
"<html>" > index.html
"<head>" >> index.html
"</head>" >> index.html
"<body>" >> index.html
"Computer Name: "+ [System.Net.Dns]::GetHostName() >> index.html
"<p>" >> index.html
"Operating System: "+(Get-CimInstance -ClassName Win32_OperatingSystem).caption >> index.html
"<p>" >> index.html
"User Name: "+(whoami)+" <p>" >> index.html
#IP address collection will be tricky
$VIPAddress=(Get-CimInstance -Class Win32_NetworkAdapterConfiguration -Filter ("IPEnabled=TRUE") | Select-Object @{label="IPAddress";expression={$_.ipaddress[0]}},@{label="IPSubnet";expression={$_.IPSubnet[0]}},MACAddress,@{label="DefaultIPGateway";expression={$_.DefaultIPGateway[0]}},DHCPServer,DHCPEnabled,DNSDomain,DNSServerSearchOrder)
$length=$VIPAddress.length
#Now, display IP addresses for all enabled adapters
for($i=0;$i -lt $length;$i++){
"IP Address: "+$vipAddress[$i].ipaddress+" <p>" >> index.html
}
"</body>" >> index.html
"</html>" >> index.html
#Create “views” subfolder and copy index.html to it
md views
copy index.html views
#Install pode module for the current user. User may be a standard user.
Install-Module -Name ‘Pode’ -Scope ‘CurrentUser’ -force
#Start the Pode web server. IP address will be 127.0.0.1 because other ("real") addresses require the user to be an administrator
#Web site port should be between 1024-65535 so it will not meddle in other web sites on the computer, if any.
Start-PodeServer {
Add-PodeEndpoint -Address 127.0.0.1 -Port 6645 -Protocol Http
Add-PodeRoute -Method Get -Path ‘/’ -ScriptBlock {
Write-PodeViewResponse -Path ‘index.html’
}
}