exam questions

Exam CS0-002 All Questions

View all questions & answers for the CS0-002 exam

Exam CS0-002 topic 1 question 100 discussion

Actual exam question from CompTIA's CS0-002
Question #: 100
Topic #: 1
[All CS0-002 Questions]

Massivelog.log has grown to 40GB on a Windows server. At this size, local tools are unable to read the file, and it cannot be moved off the virtual server where it is located. Which of the following lines of PowerShell script will allow a user to extract the last 10,000 lines of the log for review?

  • A. tail -10000 Massivelog.log > extract.txt
  • B. info tail n -10000 Massivelog.log | extract.txt;
  • C. get content './Massivelog.log' -Last 10000 | extract.txt
  • D. get-content './Massivelog.log' -Last 10000 > extract.txt;
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
VinciTheTechnic1an
Highly Voted 3 years, 3 months ago
I use powershell, so this is 100% sure. D. is the answer.
upvoted 11 times
2Fish
2 years, 1 month ago
Agree, > is sending that output to a file.
upvoted 1 times
...
...
Lilik
Most Recent 9 months ago
D.Use redirection operators (>, >>, 2>, 2>>, and 2>&1) to send the output of a command or expression to a text file.
upvoted 1 times
...
AbdallaAM
1 year, 7 months ago
Selected Answer: D
Options A, B, and C are incorrect for the following reasons: A. tail is not a PowerShell command (it's a Unix/Linux command). B. info is not a recognized command or parameter and the syntax is incorrect. C. The syntax is incorrect because it uses | (pipe) followed by extract.txt, which is not a command. Also, get content should be get-content.
upvoted 1 times
...
Lorello2023
1 year, 9 months ago
Selected Answer: D
D I mean get content is wrong get-content is correct
upvoted 1 times
...
heinzelrumpel
1 year, 9 months ago
Selected Answer: D
Why do people destroy this site with useless answers? C is crap . Cmdlets are always noun-verb so D is the only correct answer
upvoted 3 times
...
OK97
1 year, 9 months ago
how have people learnt to interpret these commands, i am struggling to understand. Where can i learn this commands and make it easier to understand?
upvoted 3 times
...
kill_chain
1 year, 10 months ago
Selected Answer: C
Doesn't powershell use a pipeline to the the output file instead of a > ?
upvoted 2 times
cbrow
1 year, 7 months ago
Using the pipe '|' is to send an object through to the next command (i.e., "Get-Content myfile.txt -Last 10000 | Select -First 1" would first get the last 10,000 lines of the file, and then you are selecting the first object of the 10,000 with "Select -First 1"). Using '>' sends text to a file (overwrites current file if the name already exists). If you use '>>', it appends the text you are sending to the file instead of overwrites.
upvoted 1 times
...
...
NerdAlert
2 years ago
Selected Answer: D
well "tail" is linux, and Powershell hyphenates commands like get-content. So, not knowing the right command, the bottom one is the only one that looks like a real Powershell command anyway
upvoted 1 times
...
kiduuu
2 years ago
Selected Answer: D
This script uses the get-content cmdlet to read the contents of the Massivelog.log file and then selects the last 10,000 lines using the -Last parameter. The output is then redirected to a new file called extract.txt using the > operator.
upvoted 1 times
...
tatianna
2 years, 1 month ago
D. get-content './Massivelog.log' -Last 10000 > extract.txt;
upvoted 2 times
...
Stiobhan
2 years, 1 month ago
Selected Answer: D
The closest answer is D. The actual command should be: get-content './Massivelog.log' -Last 10000 > extract.txt
upvoted 1 times
...
diomastik88
2 years, 3 months ago
The answer is C
upvoted 1 times
mhop321
2 years, 3 months ago
Why? Least someone else has said "I use powershell so know it is D".....
upvoted 1 times
...
...
HouseOfMouse
2 years, 5 months ago
The cmdlet feels like a giveaway to me. I thought tails was exclusive to Linux.
upvoted 1 times
...
MrRobotJ
2 years, 5 months ago
what is the with (;) at the end of C?
upvoted 1 times
diomastik88
2 years, 3 months ago
There’s no (;) at the end of C but at the end of D So the right answer for this question is C
upvoted 1 times
...
...
Average_Joe
2 years, 6 months ago
PowerShell uses Verb-Noun syntax for cmdlets. D ( Get-Content ) is correcto. https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands?view=powershell-7.2
upvoted 2 times
...
ryanzou
2 years, 7 months ago
Selected Answer: D
D is the answer
upvoted 2 times
...
miabe
2 years, 9 months ago
Selected Answer: D
looks good to me
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago