PowerShell输出和格式

时间:2017-01-26 13:37:52

标签: powershell

我有一些东西放在一起扫描网络上的计算机,并寻找某些Chrome扩展程序。

它可以在PowerShell控制台中显示和显示信息。但是,如果它在一台机器上找到多个用户配置文件中的扩展名,它会创建一大堆信息,而不是将其分成多行,我希望将此输出转换为txt或csv文件:< / p>

$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 个答案:

答案 0 :(得分:2)

您可能希望枚举 Get-ChildItem cmdlet的返回值:

Get-ChildItem $BetterNet | ForEach-Object {
    write-host BetterNet found on: 
    Write-Host "     "$_ 
    write-host 
}
相关问题