$SqlConnection = New-Object System.Data.SqlClient.SqlConnection "Server=ocsql23;Database=master;Integrated Security=True" #"server=atthomas-pc\mssql2017,1434;database=mdb;user=XXXXX;Password=XXXXXXXX"
$SqlConnection.Open()


$sqlCmd=New-Object System.Data.SqlClient.SqlCommand
$sqlCmd.COmmandType = [System.Data.CommandType]::StoredProcedure
$sqlCmd.CommandText="DY2025.dbo.spGOVWIN_BATCH_MAIN "
$sqlCmd.CommandTimeout = 300
$sqlCmd.Connection = $SqlConnection

$sqlCmd.ExecuteNonQuery() | out-null 

$sqlCmd.CommandText="DY2025.dbo.spGOVWIN_BATCH_ENTITY "
$sqlCmd.ExecuteNonQuery() | out-null 

$SqlConnection.Close()

#we specify the directory where all files that we want to upload  
$Dir="d:/tco/gatcs/exports/dy2025/govwindow/"    

#ftp server 
    $ftp = "ftp://ftp.governmentwindow.com" 
    $user = "oconeecountyga" 
    $pass = "5be5a7c8"  
    $folder = 'taxes/in'

$webclient = New-Object System.Net.WebClient 

$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)  

#list every sql server trace file 
foreach($item in (dir $Dir "*.txt")){ 
    "Uploading $item..." 
    $uri = New-Object System.Uri($ftp+"/" +$folder +"/"+$item.Name) 
    $webclient.UploadFile($uri, $item.FullName) 
 } 