Find files on all workstations with powershell
You can find files on all workstations with powershell with a short code.
First make a list off computernames and put them into a variable
1 |
$computers = Get-ADComputer -Filter {OperatingSystem -Like "Windows 7*"} |
Next use Invoke-Command to send the Get-ChildItem to those computers.
1 2 3 |
Invoke-Command $computers.Name { Get-ChildItem *.ost -Recurse -path "c:\users" | Select-Object Directory, Name,@{Name='ComputerName';Expression={ $env:COMPUTERNAME }} |ft -AutoSize } |
Notice that I create a new table entry for the computername in this line. It uses the computername environment variable:
1 |
@{Name='ComputerName';Expression={ $env:COMPUTERNAME } |