I am trying to obtain a PowerShell query, where I get back the free space in all the disks of my linked servers, this by means of a distributed query, nevertheless when executing this query with the xp_cmdshell I get an error, I will leave the query that I am trying to make and the error that returns me. I hope you can help me. Thank you very much.
The query is as follows:
declare @cmd varchar(200)
set @cmd = 'xp_cmdshell ''powershell $discos = Get-WmiObject -Class
win32_logicaldisk -Filter "VolumeName = ''Respaldos''"'''
print @cmd
exec (@cmd).
And the error returned is as follows:
Mens. 102, Nivel 15, Estado 1, Línea 1
Sintaxis incorrecta cerca de 'Respaldos'.
Thank you very much for your answers