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 8885199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:15:00+00:00 2026-06-14T21:15:00+00:00

I have created the below script, which has been tested and working successfully, to

  • 0

I have created the below script, which has been tested and working successfully, to amend the ‘Last Modified Date’ of all files contained in the selected folder.

$a = Get-Date "22/11/2012 10:00 AM"

$b = Get-ChildItem "C:\MyFiles"

foreach ($i in $b)
{
    $i.LastWriteTime = $a
    $a = $a.AddMinutes(1)    
}

$b

I am just looking for some help amending this script to include all subfolders/file within the selected folder, as I am currently having to amend this manually to change the date within the sub-folders of “C:\MyFiles”.. for e.g. “C:\MyFiles\A”, “C:\MyFiles\B”.. etc.

In addition.. I was also wondering how I can remove the line “$a = Get-Date “22/11/2012 10:00 AM” so that it automatically sets the date to todays, and I do not have to enter a date manually.

  • 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-14T21:15:01+00:00Added an answer on June 14, 2026 at 9:15 pm

    like this?

        $a = get-date
        $b = Get-ChildItem "C:\MyFiles" -recurse | ? { !$_.psiscontainer }
        foreach ($i in $b)
        {
            $i.LastWriteTime = $a 
            $a = $a.AddMinutes(1)    
        }
    
        $b
    

    or if you don’t need to add a minute after each file:

         $dir = read-host "Insert path"
         $b = Get-ChildItem $dir -recurse | ? { !$_.psiscontainer }
        foreach ($i in $b)
        {
            $i.LastWriteTime = get-date               
        }
    
        $b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the below SQL Script which is run from Excel VBA using ADO
Update: Please see below; I have removed all abstraction and created a plain PHP
I have the following code which has been passed on to me and creates
I have created below bat file to run my RMI server @echo Off set
//I have created below snippet to let the sensor to be detected. -(void)addProximitySensorControl {
I have created button 2 below: <input id=Button1 type=button value=Stop onclick=alert('hello world');/> <input id=Button2
I have created two imageViews promatically as shown below: public void createImageViews(Integer count){ ImageView[]
I have created a spring security Filter as below. <!-- Enables Spring Security -->
I have created table and inserted values as below. create table mytable (id INT,
I have created one table using the below command: create table Table1( Id int

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.