Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 15930

Run a powershell in sql server

$
0
0

Hi guys,

I am tring to run a powershell in sql server like below:

exec xp_cmdshell 'powershell "Get-ChildItem D:\DBBAK  -Recurse -Include "*.bak" | foreach-object {$_.Fullname}"'


i got the result:
D:\DBBAK\distribution\distribution_Full_bak_compressio
n_20120731_223004.bak
D:\DBBAK\distribution\distribution_Full_bak_compressio
n_20120731_230002.bak
D:\DBBAK\distribution\distribution_Full_bak_compressio
n_20120731_233001.bak


but I want the result like this:
D:\DBBAK\distribution\distribution_Full_bak_compression_20120731_223004.bak
D:\DBBAK\distribution\distribution_Full_bak_compression_20120731_230002.bak
D:\DBBAK\distribution\distribution_Full_bak_compression_20120731_233001.bak

how should i do ? Thanks

Best regards,
nicofer


Viewing all articles
Browse latest Browse all 15930

Trending Articles