Hello,
I have the script below that provides me network shares on specific workstations using WMI, the thing is that for every single line it print a header on the result. I want the header only as first line and after that just result. Can someone help me?
$file= "C:\PowerShell\wklist.txt"
Get-Content $file |
ForEach-Object {
#ICMP test 4 packets
If(Test-Connection -ComputerName $_ -count 4 -Quiet ){
#Read network shares
Get-WmiObject -Class Win32_Share -ComputerName $_ | Select-Object Name,Path,PSComputerName | FT -AutoSize
}
#If ICMP fails
Else{echo "N/A OFFLINE $_"
}
}
Also, instead of "FT -Autosize" I'm going to use "ConvertTo-CSV".
The final script is way bigger than that since it has credential handling and other stuff.
Thanks in advance!


