Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the -Path parameter with comma-separated paths to specify multiple paths, and then use the Select-Object cmdlet to only show the server name. Here is an example:

Get-ChildItem -Path "\\server1\c$\temp","\\server2\d$\files" -Recurse |
Select-Object @{Name="Server";Expression={$_.FullName.Split("\")[2]}}, Name, FullName

This will return all files in the specified paths and their subdirectories, along with their full paths. The Select-Object cmdlet uses a calculated property to extract the server name from the path and rename the property as "Server".