Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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’
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement