#$Computers = (Get-ADComputer -Filter { OperatingSystem -Like 'Windows 7 Professional'}).Name $Computers = @("DDARLING-7D", "DGODFREY-7D") ForEach ($Computer in $Computers) { Try { Invoke-Command -Computername $Computer -ScriptBlock { $Path = 'C:\Windows\CSC\v2.0.6\namespace\fh-file1\user$\adminstrodej' IF(Test-Path -Path $Path) { RMDIR -Path $Path -Recurse -Force } Get-ChildItem -Path 'C:\'-Recurse -Filter *.pst | Select-Object -Property Length, Name, DirectoryName, PSComputerName } -ErrorAction Stop } Catch { Add-Content C:\users\strodej\Unavailable-Computers.txt $Computer } }
I was asked to search all the computers in our domain for the presence of user generated PST files. I can do this with PowerShell using Get-ChildItem and PS Remoting however my output was not easily imported into a spreadsheet for my supervisor to interpret. The script above gives me a list of the PST files which is good but I would prefer a table. When try to pipe the output through Format-Table but I lose my PSComputerName. When I try to export to a comma separated file I get nothing.
I also tried to add the results of each iteration to a array but my array is empty. I could use some help.
Length : 312886272 Name : Old Email 2015.pst DirectoryName : C:\Email PSComputerName : DGODFREY-7D RunspaceId : 897d911b-1380-4d8d-9ec0-35b56fa77250
- Edited by John Strode Tuesday, August 25, 2015 12:43 PM edit title