sql server tsql run powershell script -


i have created powershell script opens excel file, formats column, , resaves excel file. script works powershell , commandline, when run in stored procedure (tsql) nothing. no errors either. i've tried run powershell script job agent , ran nothing happens. have enable powershell scripts in sql server?

here code stored procedure:

declare @sqlpowershell varchar(1000) set @sqlpowershell = 'powershell.exe -executionpolicy bypass -file "c:\temp\script.ps1"'  exec xp_cmdshell @sqlpowershell 

here powershell script:

# # script.ps1 # #param([string]$today="0") #must first statement in script $today=get-date -format mddyyyy $file="c:\temp\teamcurrentstockinventory_" + $today + ".xlsx" $xl=new-object -comobject "excel.application" $xl.displayalerts = $false #$xl.visible = $true  $wb=$xl.workbooks.open($file)  # open/edit first sheet $excelworksheet = $xl.worksheets.item(1) #select entire column $excelworksheet.range("f:f").horizontalalignment = -4152 #right justified value  $wb.saveas("c:\temp\teamcurrentstockinventory_" + $today + "_v1.xlsx") $wb.close() $xl.quit()  #remove-item $file  # need release two. while([system.runtime.interopservices.marshal]::releasecomobject($wb)){} while([system.runtime.interopservices.marshal]::releasecomobject($xl)){} 


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -