SQLTeam.com | Weblogs | Forums

How can I do to execute it at tsql

tsql
sql2008r2

#1

I need this command created in sql server powershell to be executed through xp_cmshell.
PS SQLSERVER:\SQL\TESTE\DEFAULT> Get-ChildItem c:\dados | rename-item -NewName {$_.name -replace '.txt',((get-date).ToString("_yyyyMMdd_HHmmss")+'.txt')}

I tried (look below) but without success.

xp_cmdshell 'powershell "Get-ChildItem c:\dados\ecf | rename-item -NewName {$_.name -replace ''.txt'',((get-date).ToString("_yyyyMMdd_HHmmss")+''.txt'')}"'

I need it because I want to put it inside stored procedure.