Reputation: 11
I am running a script to change the creation date of files/folders however although it changes the folders and files within a folder it does not change the date of the actual parent folder. the script is below, could anyone advise what needs changed.
# Get the files
$gFiles = Get-ChildItem -recurse G:\
# Loop through them all
$gFiles | ForEach-Object {
# Set the creation date without returning any output
($_.CreationTime = '10/08/2014 1:00') |Out-Null
# Test if the previous operation was successful:
if($?)
{
# Success, create an object containing the Path and status
New-Object PSObject -Property @{
"FilePath" = $_.FullName
"Result" = "Success"
}
}
else
{
# Success, create an object containing the Path and status
New-Object PSObject -Property @{
"FilePath" = $_.FullName
"Result" = "Failed"
}
}
# Export the objects containing the result to a .CSV file
} |Export-Csv -LiteralPath "C:\pslog.csv" -Delimiter ";" -NoTypeInformation -Force
Upvotes: 0
Views: 219
Reputation: 52639
You'll need to include as Get-ChildItem
only enums the child filesysteminfos.
Something like this -
$gFiles = (Get-ChildItem -recurse G:\) + (Get-Item G:\)
Upvotes: 1