[Solved] Powershell -command (Get-WmiObject Win32_ComputerSystem) .domain in .CMD

Discussion in 'Scripting' started by RemixPL1994, Jan 1, 2021.

  1. RemixPL1994

    RemixPL1994 MDL Junior Member

    Jul 16, 2017
    52
    6
    0
    #1 RemixPL1994, Jan 1, 2021
    Last edited: Jan 1, 2021
    Hello, I have a powershell command that can be used in .CMD that displays the name of our workgroup (in my case, e.g. WORKGROUP) Is there any way to get this command:

    Powershell -command (Get-WmiObject Win32_ComputerSystem) .domain in .CMD

    Before showing "WORKGROUP" as shown here:

    [​IMG]

    For example, it showed the name "Name of the Working Group" eg with ECHO ??? So instead of displaying "WORKGROUP" itself It was something like "Name of the Working Group - WORKGROUP"

    So something like this: (screen modified to show the effect)

    [​IMG]

    Maybe there is another command that does the same, but is typically under .CMD instead of powershell where you can use ECHO to display other characters before displaying the data from a specific command?

    @abbodi1406 Can I ask you for help again? ;)
     
  2. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,141
    84,322
    340
    cmd
    Code:
    for /f %# in ('Powershell -command "(Get-WmiObject Win32_ComputerSystem).domain"') do echo Name of the Working Group - %#
    batch script
    Code:
    for /f %%# in ('Powershell -command "(Get-WmiObject Win32_ComputerSystem).domain"') do echo Name of the Working Group - %%#
     
  3. RemixPL1994

    RemixPL1994 MDL Junior Member

    Jul 16, 2017
    52
    6
    0
    Thank you very much! This is what I meant. Happy New Year ;)