Exercise 1
Exercises on Get-Help usage
-
Verify if there are cmdlets that allow converting the output of another cmdlet to HTML format.
Click me for proposed solution
help *html*
-
Verify which cmdlets allow directing output to a printer or a file.
Click me for proposed solution
Out-Printer Out-File
-
Verify how many cmdlets are used to manage processes.
Click me for proposed solution
help *Process*
-
Which cmdlet can be used to write an entry to an event log?
Click me for proposed solution
Write-EventLog
-
Which cmdlets can be used to manage aliases?
Click me for proposed solution
help *alias*
-
Is there a way to keep a transcript of a PowerShell session and save it to a file?
Click me for proposed solution
Start-Transcript -Path "C:\transcripts\transcript0.txt" -NoClobber
-
How can you get the 100 most recent records from the SECURITY event log on a system?
Click me for proposed solution
Get-EventLog -LogName SECURITY -Newest 100
-
Is there a way to obtain the list of services that are running on a remote computer?
Click me for proposed solution
Answer: Yes, you can use the Get-Service cmdlet with the -ComputerName parameter followed by the name of the remote computer to obtain the list of services running on that computer. Example:Get-Service -ComputerName RemoteComputerName
-
Is there a way to obtain the list of services that are running on a remote computer?
Click me for proposed solution
Answer: Yes, you can use the Get-Process cmdlet with the -ComputerName parameter followed by the name of the remote computer to obtain the list of processes running on that computer. Example:Get-Process -ComputerName RemoteComputerName
-
Review the help of the Out-File cmdlet. What is the line size used by this cmdlet by default? Is there a parameter that allows you to change this size?
Click me for proposed solution
Answer: The line size used by default by the Out-File cmdlet is 80 characters. You can change this size using the -Width parameter followed by the desired width. Example:Get-Process | Out-File -FilePath C:\Processes.txt -Width 120
-
By default, Out-File overwrites the output file if it already exists. Is there a parameter that prevents the overwriting of an existing file?
Click me for proposed solution
Answer: Yes, the -NoClobber parameter can be used to prevent the overwriting of an existing file. If this parameter is used and the output file already exists, Out-File will not overwrite the file and will instead display an error message. Example:Get-Process | Out-File -FilePath C:\Processes.txt -NoClobber