gather some local data and convertto-html


hello,

i hope well.

i practicing powershell , trying create script gathers local user/pc information, converts html , opens html page.

so far have this:

$username = get-content env:username
$computername = get-content env:computername
$homeshare = get-content env:homeshare
$logonserver=get-content env:logonserver
$ipaddress=(gwmi win32_networkadapterconfiguration | ? { $_.ipaddress -ne $null }).ipaddress

{write-output "userid: $username"; "computername:  $computername";"ip address: $ipaddress"; "n: drive:  $homeshare"; "logon server:  $logonserver"} |convertto-html | out-file c:\temp\userinfo.html

invoke-expression c:\temp\userinfo.html

all way "|converto-html" works, "invoke-expression" appears work.  html page opens , presents debugging information on page shows script...but doesn't doesn't like.  without {}'s @ beginning , end of "write-output" line html result "*   24".

i want data shows in powershell cmd shell show in html page.  doesn't have fancy - phase 2.

thanks much,

try this. wrtingway many unneeded lines of code:

[pscustomobject]@{     username=$env:username     computername=$env:computername     homeshare=$env:homeshare     logonserver=$env:logonserver     ipaddress=(gwmi win32_networkadapterconfiguration -filter 'ipenabled=true').ipaddress[0] } |     convertto-html -as list|      out-file c:\temp\userinfo.html c:\temp\userinfo.html 


¯\_(ツ)_/¯



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607