Good Morning Folks!
I have a powershell script that runs as part of a batch process. When I run the batch file manually, the code where I change the number format in one field to % works. However, when I run the batch file on a scheduled task, the PS file runs, however the part of the file that changes the number in the one field to % doesn’t seem to work. Below is the code that runs that part of the PS Script. Any ideas what adjustments I can make so that this part of the script completes on the scheduled task?
I have: run as administrator, user has all proper permissions to PS, verified that the batch file runs the PS and that the script does what it is supposed to do manually running the batch
$file1 = "D:\autoloader\Secure_Bulk\SES_Live.csv"
$xl = new-object -c excel.application
$xl.displayAlerts = $false
$wb1 = $xl.workbooks.open($file1)
$ws1 = $wb1.WorkSheets.item(1)
$ws1.activate()
$r=2
$n = $ws1.UsedRange.Rows.Count
while($r -lt $n) {
if ($ws1.Cells.Item($r, "AR").Text -eq "Company Name") {
$ws1.Cells.Item($r, "J").NumberFormat = "0.00%"
}
$r++
}
$wb1.Save()