3

I have something I have put together to scan computers on my network and look for certain chrome extensions.

It works and displays the information in the PowerShell console. But if it finds the extension in multiple user profiles on a machine it creates a giant blob of information instead of separating it into multiple lines and I would like to have this output to a txt or csv file:

$hostnamestxt = "Server with list of computers"
$computers = get-content “$hostnamestxt”

write-host Scanning........


foreach($computer in $computers){
$BetterNet = "\\$computer\c$\users\*\AppData\Local\Google\Chrome\User Data\Default\Extensions\gjknjjomckknofjidppipffbpoekiipm"

 if (Test-Path $BetterNet) {
    $a = Get-ChildItem $BetterNet
    write-host BetterNet found on: 
    Write-Host "     "$a 
    write-host 
   }

1 Answer 1

2

You probably want to enumerate the return value of the Get-ChildItem cmdlet:

Get-ChildItem $BetterNet | ForEach-Object {
    write-host BetterNet found on: 
    Write-Host "     "$_ 
    write-host 
}
Sign up to request clarification or add additional context in comments.

2 Comments

This works great at breaking up the blobs of data. Thank you very much. how about outputting it to a file?
Instead of using the Write-Host cmdlet, take a look at Set-Content and the Add-Content cmdlet. Be carefull about the encoding (-Encodign parameter)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.