New
#1
Convert PS to CMD
Good afternoon,
I almost have this, butNOT
quite.
I doNOT
want alternative code etc, I want to try and crack this as a conversion from PowerShell to CMD Prompt. It's just my little Brain exercise [ little grey cells as Poirot would say ] for the day.
This works in PowerShell . . .
Code:Get-wmiObject Win32_Volume | Where-Object {$_.FileSystem -Match "NTFS"} | Sort {$_.Name} | ForEach-Object {echo "$(echo $_.Name) [$(echo $_.Label)]"} \\?\Volume{30cf9d4a-0000-0000-0000-100000000000}\ [System Reserved] C:\ [Win_10] D:\ [Data] S:\ [System_Image]
I have tried converting it into a CMD. Here are some of the things that I have tried, and they all produce the correct results except that EACH result is spread over TWO lines, as opposed to ONE line for each as per the PowerShell output . . .
Code:PowerShell "Get-wmiObject Win32_Volume | Where-Object {$_.FileSystem -Match 'NTFS'} | Sort {$_.Name} | ForEach-Object "{echo "$(echo $_.Name) [$(echo $_.Label)]"}"" PowerShell "Get-wmiObject Win32_Volume | Where-Object {$_.FileSystem -Match 'NTFS'} | Sort {$_.Name} | ForEach-Object {echo "$(echo $_.Name) [$(echo $_.Label)]"}" PowerShell "Get-wmiObject Win32_Volume | Where-Object {$_.FileSystem -Match 'NTFS'} | Sort {$_.Name} | ForEach-Object "{echo $(echo $_.Name), [$(echo $_.Label)]}" PowerShell "Get-wmiObject Win32_Volume | Where-Object {$_.FileSystem -Match 'NTFS'} | Sort {$_.Name} | ForEach-Object "{echo $(echo $_.Name) [$(echo $_.Label)]}"" PowerShell "Get-wmiObject Win32_Volume | Where-Object {$_.FileSystem -Match 'NTFS'} | Sort {$_.Name} | ForEach-Object {echo '$(echo $_.Name) [$(echo $_.Label)]'}" PowerShell "Get-wmiObject Win32_Volume | Where-Object {$_.FileSystem -Match 'NTFS'} | Sort {$_.Name} | ForEach-Object {echo "$^(echo $_.Name^) [$^(echo $_.Label^)]"}" PowerShell "Get-wmiObject Win32_Volume | Where-Object {$_.FileSystem -Match 'NTFS'} | Sort {$_.Name} | ForEach-Object {echo "$(echo $_.Name)" + "[$(echo $_.Label)]"}" PowerShell "Get-wmiObject Win32_Volume | Where-Object {$_.FileSystem -Match 'NTFS'} | Sort {$_.Name} | ForEach-Object {echo "$(echo $_.Name)": + "[$(echo $_.Label)]"}"
Output over TWO lines from my attempts above . . .
Code:\\?\Volume{30cf9d4a-0000-0000-0000-100000000000}\ [System Reserved] C:\ [Win_10] D:\ [Data] S:\ [System_Image]
I have often converted code without any problems, but the introduction ofecho
has got me stumped on this one. The TWO lines for EACH result output needs to be connected together somehow. I am sure that it has something to do with the doubling up of Parenthesis or something similar.
Thanks.
Last edited by Paul Black; 22 Feb 2022 at 11:38.