Let me start this off by saying that I'm an intern with no Powershell experience at all. I've put together this script as best I could and have hit a wall.
Basically, I've got a Powershell script that will query an XML list of servers & files to see if one of the files has been modified. I have no problem iterating through the farms and servers, but I get nothing when accessing attributes of the file.
$foreach($Farm in $serverList.Environment.Farm) {
Write-Host .FARM: $Farm.Name
foreach($Server in $serverList.Environment.Farm.Server) {
Write-Host ..SERVER: $Server.Name
foreach($File in $serverList.Environment.Farm.Server.File) {
$fullPath = "\\"+$Server.Name+"\"+($File.Path).Replace(":","$")+$File.Version+"\CONFIG\"+$File.Name
$lastModified = (Get-Item $fullPath).LastWriteTime.toString()
write-host ...FILEPATH: $fullPath $lastModified
... processing if/thens ...
} } }
If I'm going through 1 server's files, everything works perfectly. But, once I add another server to the XML file, I get null values when I try to build $fullPath with $File attributes.
Any help would be greatly appreciated.