Link to home
Start Free TrialLog in
Avatar of Mugiwara Yanko
Mugiwara YankoFlag for Japan

asked on

PS script to make changes to dsv file date/timestamps.

Hi Experts, 


I need help with a PowerShell script to perform the below requirement.


In a .dsv file, we have data like this in it, 


"Total Files"|"14"
"Filename_03192"|""
""|""
""|""
""|""
""|""
.
.


"Export Start Date Time"|"2022-03-18T00:00:00Z"
"Export End Date Time"|"2022-03-18T23:59:59Z"

Open in new window


I need the PS script to check if the export start and end date time are present as per requirement or else change them using the PowerShell script 


if suppose, we get data like this,

"Export Start Date Time"|"2022-03-18T00:00:00Z"
"Export End Date Time"|"2022-03-19T00:00:00Z"

Open in new window


Then this is not as per the standard requirement so we need to change that to this, using PS.

"Export Start Date Time"|"2022-03-18T00:00:00Z"
"Export End Date Time"|"2022-03-18T23:59:59Z"

Open in new window


Always the export start date and end date should be the same date. So whatever the export start date we need to change the end date by taking reference of the start date.

Start Timestamp should always be T00:00:00Z and the end timestamp  T23:59:59Z


we need to check the .dsv file and make changes using the PS script.


If everything is fine ignore else make changes as per standard.

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mugiwara Yanko

ASKER

oBdA san, I m trying to test it. I m getting an error saying set-content: access to the path is denied. any idea on how to resolve this? I have performed many PS scripts in those paths I don't know what the issue is. 

Avatar of oBdA
oBdA

Please download the script again from above; the old version would use a comma as separator when fixing was required; that's fixed above. In addition, Set-Content now uses -Force to overwrite files where the ReadOnly attribute is set.
If this still doesn't overwrite the original file, it's nothing related to the script; the user running the script doesn't have permissions to overwrite the script at its current location (maybe a share with Read-Only share access?).
The script could be changed to write to a different location, otherwise you need to fix this at your end.