If you know how to use xp_CmdShell properly and safely, here's how I do such things. Since you're not using SQL Server 2022, the STRING_SPLIT() function isn't guaranteed by MS to return things in proper ordinal order of the split elements. Instead, you can use the DelimitedSplit8K function found at the following link. It returns the enumerated ordinal for the line position of each split out element.
Here's the code I use to do similar things. You can adapt it to suit your needs for whatever CMD you need.
--===== Drop the temp tables just to make reruns in SSMS easier.
-- Comment this line out for "production"
DROP TABLE IF EXISTS #CmdResult, #ProcessList
--===== Create the table to receive the CSV output from xp_CmdShell.
CREATE TABLE #CmdResult
Line# INT IDENTITY(0,1) PRIMARY KEY CLUSTERED
,CmdResult VARCHAR(500) --Stores the original command result
,Cleaned AS (REPLACE(REPLACE(CmdResult,CHAR(13),''),CHAR(10),'')) PERSISTED --Removes Cr/Lf
--===== Execute the WMIC command through xp_CmdShell and store the results for splitting.
INSERT INTO #CmdResult WITH (TABLOCK)
EXEC xp_CmdShell 'wmic process list brief /format:CSV'
--===== In the following, uncomment the "Node" attribute if you want to see the machine name.
-- I just didn't want to publish mine.
--Node = CONVERT(VARCHAR(100),MAX(IIF(split.ItemNumber = 1,split.Item,''))),
HandleCount = CONVERT(INT ,MAX(IIF(split.ItemNumber = 2,split.Item,0))),
Name = CONVERT(VARCHAR(100),MAX(IIF(split.ItemNumber = 3,split.Item,''))),
Priority = CONVERT(INT ,MAX(IIF(split.ItemNumber = 4,split.Item,0))),
ProcessId = CONVERT(INT ,MAX(IIF(split.ItemNumber = 5,split.Item,0))),
ThreadCount = CONVERT(INT ,MAX(IIF(split.ItemNumber = 6,split.Item,0))),
WorkingSetSize = CONVERT(BIGINT ,MAX(IIF(split.ItemNumber = 7,split.Item,0)))
CROSS APPLY dbo.DelimitedSplit8k(Cleaned,',') split
WHERE Line# >= 3
AND CmdResult > ''
GROUP BY Line#
--===== Display the final results.
SELECT * FROM #ProcessList
And, here are the results...
If you need it, I have a PowerPoint presentation for how to use xp_CmdShell safely, why it's NOT the security risk everyone claims it is, and how to set it up for safe use (not need if only your trusted DBAs are going to use it).
Now, duck... here comes all the naysayers on that particular subject. 😉