Powershell, Scripting

Learn PowerShell in a month of Lunches–Chapter 3 answers

1 Can you find any cmdlets capable of converting other cmdlets’ output into HTML?

ConvertTo-Html

2 Are there any cmdlets that can redirect output into a file, or to a printer?

Out-File  & Out-Printer

3 How many cmdlets are available for working with processes?

Get-Process                       Cmdlet    Gets the processes that are running on the local computer or a remote co…
Stop-Process                      Cmdlet    Stops one or more running processes.
Wait-Process                      Cmdlet    Waits for the processes to be stopped before accepting more input.
Debug-Process                     Cmdlet    Debugs one or more processes running on the local computer.
Start-Process                     Cmdlet    Starts one or more processes on the local computer.

4 What cmdlet might you use to write to an event log?

New-Event

5 You’ve learned that aliases are nicknames for cmdlets; what cmdlets are available to create, modify, export, or import aliases?

New-Alias
Set-Alias
Export-Alias
Import-Alias

6 Is there a way to keep a transcript of everything you type in the shell, and savethat transcript to a text file?

Start-Transcript

7 It can take a long time to retrieve all of the entries from the Security event log. How can you get just the 100 most recent entries?

get-eventlog -newest 5 -logname security

8 Is there a way to retrieve a list of the services that are installed on a remote computer?

get-service -computername Server02

9 Is there a way to see what processes are running on a remote computer?

Get-Process -COMPUTERNAME Server02

10 Examine the help file for the Out-File cmdlet. The files created by this cmdlet default to a width of how many characters? Is there a parameter that would enable you to change that width?

Default has a width of 80 characters and the parameter to change is -width

11 By default, Out-File will overwrite any existing file that has the same filename as what you specify. Is there a parameter that would prevent the cmdlet from overwriting an existing file?

-NoClubber

12 How could you see a list of all aliases defined in PowerShell?

Get-Alias

13 Using both an alias and abbreviated parameter names, what is the shortest command line you could type to retrieve a list of running processes from a computer named Server1?

gps -c server1

14 How many cmdlets are available that can deal with generic objects? (Hint: Remember to use a singular noun like “object” rather than a plural one like “objects”).

15 This chapter briefly mentioned arrays. What help topic could tell you more about them?

help *arrays*

Be Sociable, Share!

2 Comments on “Learn PowerShell in a month of Lunches–Chapter 3 answers

  1. Thanks for this article it goes a lot deeper than the official answers on the book site.

  2. #4 To create an event log entry, use Write-EventLog. New-Event creates a new event and has nothing to do with the logs.

    Answer #7 is get-eventlog -newest 100 -logname security, not -newest 5, probably a typo.

    Answer #14 is 9

Comments are closed.