I am using Get-WmiObject Win32_service and piping the output to CSV.
My script is collecting services running, but I would like to display osname, ip and domain for the object on the same line in my csv (so I can easily sort with Excel).
Is there a way I can combine the two?
Get-WmiObject Win32_Computersystem
Get-WmiObject Win32_service
Or maybe I could sneak in some variables from my Get-QADComputer into this line:
Get-WmiObject Win32_service -Computername $server.name -Filter "State='Running'" | select -Property SystemName,Name,Status,State,Startmode,DisplayName | Export-Csv -Append -NoClobber -NoTypeInformation -Path $reportfile
?
Use the
New-Objectcmdlet to create new object for each service object and add the properties you want (osname) from theWin32_OperatingSystemWMI class (os caption is not avaiable in theWin32_ComputerSystemclass).