Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

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 15889

Trending Articles



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