locked
Use CimInstance to obtain make and model for systems across a domain RRS feed

  • Question

  • Right now i have all of the systems managed in a text file. I run :

    gc c:\allcomputers.txt | %{get-ciminstance -classname win32_computersystem}

    I receive a list of my local computers information. Is there anyway to get all systems across my domain.

    Thursday, October 31, 2019 9:14 PM

All replies

  • Start by reading the help for you cmdlet.

    help Foreach-Object -online


    \_(ツ)_/

    Thursday, October 31, 2019 9:20 PM
  • Try Get-ADComputer.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Friday, November 1, 2019 2:14 AM
  • Try Get-ADComputer.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Doesn't get make and model.


    \_(ツ)_/

    Friday, November 1, 2019 2:40 AM
  • This is a simple method but not very robust:

    get-ciminstance -classname win32_computersystem -computerName (gc c:\allcomputers.txt)


    \_(ツ)_/


    Friday, November 1, 2019 2:42 AM
  • Right now i have all of the systems managed in a text file. I run :

    gc c:\allcomputers.txt | %{get-ciminstance -classname win32_computersystem}

    I receive a list of my local computers information. Is there anyway to get all systems across my domain.

    We cannot run this command because this (get-ciminstance) does not accept computername from the pipeline.

    So you have to convert the computer name in something like accepted format.

    What JRV has given can run and fulfill your requirement as this uses parenthesis so when you run this command first it will run the command written inside and () and then the output of this will be passed as input to your remaining command.  

    get-ciminstance -classname win32_computersystem -computerName (gc c:\allcomputers.txt)

    Hope this helps :)


    Cheers, Gourav Please remember to mark the replies as answers if it helped.

    Friday, November 1, 2019 1:34 PM
  • Your answer to "start by reading..." help for the Foreach-Object doesn't do that either.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Friday, November 1, 2019 3:49 PM
  • I interpreted his question to be about how to get the names of all the computers in the domain, not about how to use the list of "local computers" from a file he already had.

    Using Get-ADComputer and piping the result into a Foreach-Object block is the answer I *think* he was after.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Friday, November 1, 2019 3:53 PM
  • I interpreted his question to be about how to get the names of all the computers in the domain, not about how to use the list of "local computers" from a file he already had.

    Using Get-ADComputer and piping the result into a Foreach-Object block is the answer I *think* he was after.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    In all cases reading the help for the ForEach-Object command will help in learning how to use the code. Either a file or Get-AdComputer requies understanding the command. All new users need to be able to read and understand technical documentation. "GUI" people almost never know how to read docs or use help. This is a prerequisite for scripting.


    \_(ツ)_/

    Friday, November 1, 2019 5:42 PM
  • So far nobody's referred you to the way to get the "make" and "model" you asked about in the subject of this post.

    See https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-computersystem

    PCSystemType, PCSystemTypeEx, Manufacturer, Model, SystemType, etc. are all properties of the Win32_ComputerSystem class object returned by the query for Win32_ComputerSystem.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Friday, November 1, 2019 9:32 PM
  • Have you done this, 

    PS C:\Temp> Get-help Get-CimInstance -full
    and check the Example 10.

    Example 10: Get the CIM instance using CIM session

    PS C:\>$s = New-CimSession –ComputerName Server01,Server02
    PS C:\>Get-CimInstance -ClassName Win32_ComputerSystem -CimSession $s

    So you can do this

    $s = New-CimSession –ComputerName (Get-content c:\allcomputers.txt)
    Get-CimInstance -ClassName Win32_ComputerSystem -CimSession $s

    It worked for me, here we could see the output,

    PS C:\Temp> Start-Service -Name WinRM
    PS C:\Temp> $s = New-CimSession –ComputerName (Get-content C:\Users\kumar_g\Desktop\localhost_text.txt)
    PS C:\Temp> Get-CimInstance -ClassName Win32_ComputerSystem -CimSession $s | Select Manufacturer, Model

    Manufacturer Model
    ------------ -----
    HP           HP ProBook 440 G4
    HP           HP ProBook 440 G4
    HP           HP ProBook 440 G4


    PS C:\Temp>

    Note: - We have to make sure WinRM service should be running on servers. Or Cim session must be established.

    This is my two cents, sir :)


    Cheers, Gourav Please remember to mark the replies as answers if it helped.

    Saturday, November 2, 2019 7:42 AM
  • Are you explain what others have already posted? Curious.


    \_(ツ)_/

    Saturday, November 2, 2019 7:53 AM