Blowfelt82
asked on
Seach for folder on multiple computers powershell.
I have the following powershell...
And need to do three things, I would ideally like to do this in the one statement as I want to pipe the output of the command to a graph generator cmdlet - but I will take what I can get!...
1) For each 'Result' value found (will be a folder name) I want to search 4 remote machine paths ('MAC1','MAC2','MAC3','MAC 4') to see if the folder exists on these machines - it will exist on one of them and return the appropriate machine name to the piped output of the cmdlet.
2) The 'RunTime' is being output I guess as a formatted number i.e. 20,000. I would like to have this as a straight integer with no comma delimeter. I have tried...
to no avail.
3) At the moment the code searches for 'initiated.txt' files, but I can see the requirements changing to include files of type '*.alo'. Is there a way I can add this as a search option in the statement and populate a new column with something like ALO/TXT to differentiate? This is the least important option at the moment.
Any help greatly appreciated.
Get-ChildItem -path "C:\Test\Hub" -filter "initiated.txt" -recurse | Select-Object CreationTime, LastWriteTime, @{Name="Result";Expression={($_.Directory -Replace ([regex]::Escape("C:\Test\Hub"),""))}}, @{Name="RunTime";Expression={"{0:N0}" -f ($_.LastWriteTime - $_.CreationTime).TotalSeconds}}| Where-Object {$_.RunTime -gt 0} | Sort-Object "CreationTime"
And need to do three things, I would ideally like to do this in the one statement as I want to pipe the output of the command to a graph generator cmdlet - but I will take what I can get!...
1) For each 'Result' value found (will be a folder name) I want to search 4 remote machine paths ('MAC1','MAC2','MAC3','MAC
2) The 'RunTime' is being output I guess as a formatted number i.e. 20,000. I would like to have this as a straight integer with no comma delimeter. I have tried...
@{Name="RunTime";Expression={"{0:N0}" -f [integer]::($_.LastWriteTime - $_.CreationTime).TotalSeconds}}
to no avail.
3) At the moment the code searches for 'initiated.txt' files, but I can see the requirements changing to include files of type '*.alo'. Is there a way I can add this as a search option in the statement and populate a new column with something like ALO/TXT to differentiate? This is the least important option at the moment.
Any help greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER