Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6163425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:49:22+00:00 2026-05-23T21:49:22+00:00

Let me start this off by saying that I’m an intern with no Powershell

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:49:23+00:00Added an answer on May 23, 2026 at 9:49 pm

    Without sample data I can’t test it, but try something like this:

    foreach ($Farm in $serverList.Environment.Farm) {
        Write-Host ('.FARM: ' + $Farm.Name)
        foreach ($Server in $Farm.Server) {
            Write-Host ('..SERVER: ' + $Server.Name)
            foreach($File in $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 ...
            }
        }
    } 
    

    The basic problem with your first attempt is that in the $Server loop, you need to iterate over children of $Farm and in the $File loop you need to iterate over children of $Server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me start off by saying that I am completely new with WPF (this
Let me start off by saying that this is my first real Cocoa app.
Let me start by saying that I do not advocate this approach, but I
Let me start out by saying that I'm not a JavaScript developer so this
Preface Let me start off by saying that I'm a relatively new programmer and
Ok, let me start off by saying that I'm don't have the slightest clue
First off, let me start by saying, I know this exact question has been
Let me start off by clarifying that(before you guys dismiss me), this is not
Let me start off by saying that I'm pretty new to flex and action
Ok, let me first start off by saying that I've only ever dealt with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.