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

$FormatEnumerationLimit Not Working When Powershell Script Run Through Scheduled Task

$
0
0

Hello!

I have a powershell script that runs everyday based on a windows scheduled task (Win2008 R2 Server).

When the scheduled task runs, my script produces a text file but it truncates some of the data even though I have set $FormatEnumerationLimit = -1 (unlimited). I have also tried $FormatEnumerationLimit = 80. Still didn't work. I even tried $global:FormatEnumerationLimit = 80 because I saw another thread where there is a bug with declaring this variable and it needs to be declared globally (not in a function) in order for it to work.

One thing I noticed however is that when I run the script manually (logged into the server as my service user), the text does NOT get truncated. It's only when the script runs through the scheduled task (using the same service user who has admin rights) that some of the data is truncated.

Can someone help me to understand why it works when run manually but not through the scheduled task? My service user is an admin user on the domain that has access to network drives.

My scheduled task is set to run with highest privileges.

I hope I am making sense.

My code is below:

The code I am not showing is that I connect to an Oracle database to run a select statement to get the data I need to write to a file.

# In order to output to a file we need to fill a dataset table
$DataSet = New-Object System.Data.DataSet
$nRecords = $OracleAdapter.Fill($DataSet)
$oracleConnection.Close();

#Export Dataset Table to a text file
$rcvrFileName = "RCVR_BTAX_" + $todaysDate + "_01.txt"
$FormatEnumerationLimit = 80
$DataSet.Tables[0] | Out-File $rcvrFileName

# Remove header and lines 2 and 3 from file and re-save it
$file = Get-Content $rcvrFileName | Select-Object -Skip 3
Set-Content $rcvrFileName -Value $file

----------------------------------------------------------------------------

Here is the output of my file (just an excerpt because it is long):

<sf:ReceiverSet documentTypes="BILL" organization="orgName" totalNo...

----------------------------------------------------------------------------

As you can see, the " totalNo..." is what is getting truncated. It should look like this:

<sf:ReceiverSet documentTypes="BILL" organization="orgName" totalNo="123456">

----------------------------------------------------------------------------

Is this an issue with scheduled tasks more than powershell?

Thanks.
Eva











Viewing all articles
Browse latest Browse all 21975

Trending Articles



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