Day 20 - PowershELlF to the rescue
Date: 20, December, 2020
Author: Dhilip Sanjay S
Powershell
PowerShell is built on top of the .NET Common Language Runtime (CLR), and accepts and returns .NET objects
Powershell cmdlets are case-insensitive.
Set-Location (cd)
Get-ChildItem (ls)
Some options that can be used:
-Path
-File / -Directory
-Filter
-Recurse
-Hidden
-ErrorAction SilentlyContinue
Get-Content (cat)
Measure-Object -Word (wc)
Can be piped:
Get-Content -Path file.txt | Measure-Object -Word
To get the exact position of a string within a file:
(Get-Content -Path file.txt)[index]
To search a particular file for a pattern:
Select-String
Solutions
Search for the first hidden elf file within the Documents folder. Read the contents of this file. What does Elf 1 want?
Answer: 2 front teeth
Steps to Reproduce:
Search on the desktop for a hidden folder that contains the file for Elf 2. Read the contents of this file. What is the name of that movie that Elf 2 wants?
Answer: Scrooged
Steps to Reproduce:
Search the Windows directory for a hidden folder that contains files for Elf 3. What is the name of the hidden folder? (This command will take a while)
Answer: 3lfthr3e
Steps to Reproduce:
How many words does the first file contain?
Answer: 9999
Steps to Reproduce:
What 2 words are at index 551 and 6991 in the first file?
Answer: Red Ryder
Steps to Reproduce:
This is only half the answer. Search in the 2nd file for the phrase from the previous question to get the full answer. What does Elf 3 want? (use spaces when submitting the answer)
Answer: red ryder bb gun
Steps to Reproduce:
Last updated