Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

No changes to CSV file using Scheduled Task

$
0
0

Hi, I have a very simple script that changes a CSV file. When I run this via a Powershell console it works fine but if I try to run it in a Scheduled Task no changes are made, though the task said it ran successfully. I've tried running the task with highest privileges, a different account and running whether the user is logged on or not but nothing helps.

Code (c:\scripts\test.ps1):

$csv_info = Import-Csv c:\scripts\test.csv

foreach ($line in $csv_info) {

	$log_drink = $line.Drink

	if ($log_drink -eq "Water")
	{
		$line.drink = $line.drink.replace("Water","Coke")
	}

}

$csv_info | Export-Csv test.csv -Delimiter ',' -NoType


The CSV file looks like so:

"Name","Drink"
"John","Water"

I also granted full permissions to 'Users' to the directory and files but it makes no difference. Does anyone have any tips?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>