Reputation: 1
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
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