omegaprime13
omegaprime13

Reputation: 1

create a txt file in PowerShell list of all running services

I am trying to create a txt file in PowerShell that provides a list of services that are running. This what I came up with but it keeps on giving me an error message that says its not valid.

Get-Service | Export-txt -path "C:\Windows\Temp\services.txt"

Get-Service | where {$_.Status -eq "Running"} | Export-txt -path "C:\Windows\Temp\services.txt"

Upvotes: 0

Views: 1696

Answers (2)

Abraham Zinala
Abraham Zinala

Reputation: 4694

There is no cmdlet by the name of Export-txt. To get a list of cmdlets you can use, you can think logically and apply that to Get-Command. Running Get-Command will get you a list of all available cmdlets you may use in accordance with your Posh version.

Get-Command *out* returns a list of cmdlets you can send out to something. Same logic applies to Get-Command "Export*".

#This gets you all services
Get-Service | Out-File "C:\Windows\Temp\services.txt"

#This gets you only running services
Get-Service | where {$_.Status -eq "Running"} | Out-File "C:\Tmp.txt"

Use Get-Help Out-File to see how the cmdlet is used and what parameters it accepts. It also lists examples you can use.

Upvotes: 1

gunr2171
gunr2171

Reputation: 17502

There is no commandlet called Export-txt.

One option is to use Out-File. It uses -FilePath as a parameter (or no named flag).

Get-Service | Out-File -FilePath "C:\Windows\Temp\services.txt"

Upvotes: 1

Related Questions