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

  • SEARCH
  • Home
  • 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 8755861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:56:17+00:00 2026-06-13T13:56:17+00:00

I have xml files stored in the current date folder as in here –

  • 0

I have xml files stored in the current date folder as in here – Refer this link
Now I want to read a specific part of the xml and print that in a csv file.
As in the link How can I use the $location as input to read the xml files based on the current date folder only?

I tried using:

$locatexml = -item -path $rptdir -itemtype Directory -Name ("XML_$(Get-Date -f yyyy_mm_dd)")

But I get an error – Missing expression after unary operator ‘-‘.
how can I assign the current folder to $locatexml? so that I can be able to refer to all the xml files that exist for the current date folder?

My code which is trying to read the xml files located in the date folder:

Removed -itemtype from the $locatexml, I am assigning the fullname to another variable $locatexml2.

$locatexml = get-item -path $reportdir -Name ("XML_$(Get-Date -f yyyy_MM_dd)")
**Do I need $locatexml2 here?**
$locatexml2 = "$($location.fullname)" 

Function DoRpt($locatexml2)
{
$rptOut="Asm"
Get-ChildItem  $locatexml2 | ForEach-Object {        
$file = Get-Content -path $locatexml2\$_ -totalcount 15
try {
$asm = [regex]::matches($file[5], 'asm=".*" ')[0].value -replace 'asm="(.*)" ','$1' 
      $rptOut=$rptOut+"`n$Asm,$locatexml2\$_"        
} catch {}   
}
Set-Content -path $testdir\test.csv -value $rptOut
}

The XML looks like below:

<?xml version="1.0" encoding="utf-8"?>
<Rpt Version="10.0">
<Targets>
<Target="\\Shared\Data\SB\app\bin\test.dll">
<Mods>
<Mod="test.dll" asm="1.0.0000.000">
</Mod>
</Mods>
</Target>
</Targets>
</Rpt>

I tried all the methods of assigning the $locatexml as metnioned below, but I am not getting through.. Is there something I am missing in the above code?

DO I really need $locatexml2 here?

Thanks!

  • 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-06-13T13:56:18+00:00Added an answer on June 13, 2026 at 1:56 pm

    Do a dir in the parent directory, indicating the folder name you are looking for. I am assuming $rptdir is a string indicating the parent directory where the date-named subdirectories reside.

    $locatexml = dir -Path $rptdir -Filter "XML_$(Get-Date -f yyyy_MM_dd)"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have XML files stored in a folder. I would create a table with
I have a set of records, stored as XML files, where the XML files
I have several xml files with different node structure. I want to extract xml
I have several xml files that are formated this way: <ROOT> <OBJECT> <identity> <id>123</id>
I have a directory with XML files. I quickly want to go through them
Scenario You have lots of XML files stored as UTF-16 in a Database or
We have about 1400 xml files which we use to store data around the
I have to read/write an XML file that stores its data as bit masked
I have some XML files that contain different function information. I am trying to
I have two XML files that are generated by another application I have no

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.