Day 3 of learning PowerShell
I’m sharing my PowerShell learning journey for all to follow along. Some of you might already know this information so this might be a refresher course or you can see how I went about it; for those that are new to PowerShell hopefully these snippets help you along your PowerShell journey as well.
Update help files
Update-Help
How to find a cmdlet that output/convert to html
Get-Command *html* -CommandType Cmdlet
Result= ConvertTo-Html
How to find a cmdlet that can output by either file or printer.
Get-Command *file*,*printer* -CommandType Cmdlet
Result= Out-File or Out-Printer
How to find a cmdlet that you can use to write to event log.
Get-Command *log*,*event*
Result= Write-EventLog
How to find the cmdlets to create, modify, export, or import aliases?
Get-Command *alias*
Results= New-Alias, Set-Alias, Export-Alias, and Import-Alias
Is there a way to keep a transcript of everything you do in the shell?
Get-Command *transcript*
Results= Start-Transcript and Stop-Transcript
How can you get only the most recent 100 entries in the Security event log?
Get-Command *event*,*log*
Result= Get-EventLog
Get-EventLog -LogName Security -Newest 100
Is there a way to retrieve a list of services on a remote computer?
Get-Service -ComputerName "Computer02"
Is there a way to find what processes are running on a remote computer?
Get-Service -Computername "Computer02" | Where-Object {$_.Status -eq "Running"}
Width setting for Out-File.
Out-file -Width
Added to a File
Out-File -Append
Get a list of all aliases
Get-Command * -CommandType Alias
shortest command line to get running processes from a computer named server1
gsv -c server1 | Where-Object {$_.Status -eq "Running"}