Link to home
Start Free TrialLog in
Avatar of hcds
hcdsFlag for Austria

asked on

Get-Service Log on as

Hi,

looking for a powershell script to accomplish the following task:
- list services of a remote computer
- get information about the "log on as" attribute such as local system or else

my actual script is:
#list services of a remote computer
"Computer:"
$serviceComputer = [Console]::ReadLine()
$serviceComputer = $serviceComputer.Trim()
$now = get-date -uformat %d.%m.%y
$outputfile = "services_" + $strComputer + "_" + $now + ".txt"
Get-Service -Computername $serviceComputer |Sort-Object -property ServiceType | format-Table name, status, CanStop, -auto | out-file -filepath $outputfile

ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hcds

ASKER

Hi Chris,

with WMI i got it done!
One single question remaining: how can i pipe this into a text-file?

Christoph

If you go for CSV then all you need is:


Get-WmiObject Win32_Service -Computer $serviceComputer | `
  Sort-Object ServiceType | `
  Select-Object Name, Status, StartName | `
  Export-CSV "SomeFile.csv"


If you want simple text then:


Get-WmiObject Win32_Service -Computer $serviceComputer | `
  Sort-Object ServiceType | `
  Select-Object Name, Status, StartName | `
  Format-Table -Auto > "SomeFile.txt


Or you can convert it to HTML or something else entirely depending on your goals :)

Chris