Friday, May 8, 2015

SQL Server is cutting off the result-output running a powershell script

Hi forum,
I hope, it's the right place for my question:
I want to run a powershell script using xp_cmdshell, put the results into a temp table and do some additional stuff.
I'm using:

CREATE TABLE #DrvLetter (
iid int identity(1,1) primary key
,Laufwerk char(500),
)
INSERT INTO #DrvLetter          
EXEC xp_cmdshell 'powershell.exe -noprofile -command "gwmi -Class win32_volume | ft capacity, freespace, caption -a"'
select * from #DrvLetter

SQL server is cutting off the output, what I get is (consider the 3 dots at the end of a line):
  11817447424   8872448000 C:\ProgramFiles\MicrosoftDPM\DPM\Volumes\Replic...                  
Running the script on the powershell console: "gwmi -Class win32_volume | ft capacity, freespace, caption -a" I get the rigth output:

11817447424   8872448000 C:\Program Files\Microsoft DPM\DPM\Volumes\Replica\BR1A.be009.xxxxx.yyy\SqlServerWriter\PROD\XXX_XXX_XXX_OLAP\   
Using: gwmi -Class win32_volume | ft capacity, freespace, caption -a | out-string -width 200
doesn't help...
Am I doing something wrong?
Thanks for your help

Purclot

No comments:

Post a Comment