Jake
Jake

Reputation: 183

Add extra properties to an object?

I want to get a list of files in a specific location from a list of remote computers. I want the output to have the File Name, Last Write Time and the Computer's Name that it's from.

The properties of the files don't include a computer name. So how could I build the file list including the computername in the output?

$serverlist = Get-Content c:\jasonbe\Serverlist.txt foreach ($server in $serverlist) {Get-ChildItem '\\server\c$\location\Ultimate\Retail\Bin\' | Select Name, LastWriteTime, Length Get-ChildItem '\\server\c$\location\Ultimate\Retail\Reports\*.rpt' | Select Name, LastWriteTime, Length }

Hope I make sense :)

Upvotes: 0

Views: 141

Answers (1)

CB.
CB.

Reputation: 60910

try changing the select like this:

Select Name, LastWriteTime, Length,  {$server}

Upvotes: 1

Related Questions