Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Include 'extra' properties in output

$
0
0

Hi,

I'm looking to get a list of log on as service accounts on remote computers. I can output the service names and accounts but is there any way to output the server name etc ($SQLInstance.SQLInst and $SQLInstance.SQLNamed in the code below) so I can differentiate between them?

Here is my work in progress:

# Import list of Servers

$SIList=IMPORT-CSV 'C:\PSH Scripts\SQL Related\SQL_Instances.csv' # Step through Each Item in the List foreach ($SQLInstance in $SIList) { write-host $SQLInstance.SQLInst $SQLInstance.SQLNamed # Get Service Acounts Info $report += Get-WMIObject Win32_Service -ComputerName $SQLInstance.SQLInst | Where-Object{$_.name -like '*SQL*'} | Sort-Object -Property StartName | select Name, StartName } $report | convertto-html | out-file 'C:\PSH Scripts\SQL Related\SQL_Instances.html'

Thanks.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>