Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 running powershell command

Author  Topic 

avipenina
Starting Member

44 Posts

Posted - 2014-09-05 : 17:21:28
Hi,
i run this powershell command EXEC xp_cmdshell 'powershell "Get-WmiObject -class win32_processor"'
and i get some of the results in two lines instead of one line when i run it in a real powershell command
example: Name : Intel(R) Xeon(R) CPU E5-2620 v2 @
2.10GHz
the 2.10GHZ in this example go into second line...
why is that and how it can be resolved to one line like real powershell command

THX

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-05 : 17:31:50
How are you using the results? If you are storing it in a table, you can remove the extra line (maybe it's CHAR(10) or CHAR(13), or both).

I would not advise running powershell commands in T-SQL though. xp_cmdshell should really be disabled, especially if this is a production instance. Instead, run powershell commands from command line. If you need to store it in a table, then do that through powershell too.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -