Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print variable

Status
Not open for further replies.

smcc12

Programmer
Jan 8, 2009
17
US
Below is the code I am using. It works fine for the first Write-Host, and the folder name prints. In the second Write-Host, for both $item.Folder and $item.File it prints System.Xml.XmlElement instead of the variable. What am I doing wrong?

if (Test-Path "D:\Desktop\integrityCheck.xml"){
[xml]$list = Get-Content "D:\Desktop\integrityCheck.xml"
foreach ($item in $list.Programs.Program){
Write-Host $item.Folder
Write-Host "\\appsrv1\$item.Folder\$item.File"

}
}
 
<Programs>
<Program>
<Folder>00000</Folder>
<File>keyAcc.vbs</File>
</Program>
</Programs>
 
It's an evaluation issue. I don't have the full answer, but try this:
Code:
 Write-Host "\\appsrv1\$($item.Folder)\$($item.File)"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top