Hi All,
Working on a script to report the local user account information from a system and display them in a HTML report or CSV.
I’m studying For-Each loops and want to loop through my Various Commands and append them to a table.
Command 1) Hostname
Command 2) (net localgroup administrators).where({$_ -match ‘-{79}’},‘skipuntil’) -notmatch ‘-{79}|The command completed’
Command 3) Get-WmiObject -Class Win32_UserAccount -Filter “LocalAccount=‘True’” | Select name -expandproperty name
Command 4) Get-ChildItem -Path C:\Users\ | select-object Name
As my script stands, I can Enter-PSSession and manually RUN the script against a remote PC, but I want to do this against ALL my computers.
$A = hostname$B = (net localgroup administrators).where({$_ -match ‘-{79}’},‘skipuntil’) -notmatch ‘-{79}|The command completed’
$C = Get-WmiObject -Class Win32_UserAccount -Filter “LocalAccount=‘True’” | Select name -expandproperty name
$D = Get-ChildItem -Path C:\Users\ | select-object Name
$out = new-object psobject
$out | add-member noteproperty Node $a
$out | add-member noteproperty Administrators $b
$out | add-member noteproperty LocalAccounts $c
$out | add-member noteproperty Profiles $d
write-output $out
Output: