-excludeproperty RRS feed

  • Question

  • I am reading a list of machines and running this command against each.

    Get-WmiObject -Class win32_computersystem -PSComputerName $pcname | Select-Object name, model -ExcludeProperty PSComputerName, PSSourceJobInstanceId 

    I then use Out-File to create an output file.  My data is there but it looks like this:

    Name                  : PC1234
    Model                 : OptiPlex 7020                 
    PSComputerName : localhost
    PSSourceJobInstanceId : e766eee7-5dcb-4b88-8181-5276ae8b053c

    I used the -ExcludeProperty switch yet it did not exclude the data.  Why?
    Tuesday, June 27, 2017 3:25 PM

All replies

  • If you just want Name and Model you should just Select Name and Model:  ;-)
    Get-WmiObject -Class win32_computersystem -ComputerName $pcname | Select-Object name, model
    BTW: Please format your code as code here in the forum. It will be much easier to read and to understand.

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    • Edited by BOfH-666 Tuesday, June 27, 2017 3:35 PM
    • Proposed as answer by Hello_2018 Wednesday, June 28, 2017 7:45 AM
    Tuesday, June 27, 2017 3:34 PM
  • You cannot exclude the added job parameters from inside the job.  They are only added when you receive the job. 


    Tuesday, June 27, 2017 5:34 PM