Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Powershell - 1-4 are already answered to show clarification to expert # Leave all comments and instructions # Put your PowerShell code below the problem

Powershell - 1-4 are already answered to show clarification to expert

# Leave all comments and instructions # Put your PowerShell code below the problem description.

# Run the following code to set variables #Note that $hosts is a single FileInfo object $hosts = Get-ChildItem C:\Windows\System32\drivers\etc\hosts $creator = "Bill Finger" $friends = @("Aquaman", "Batman", "Robin", "Superman", "Wonder Woman") $worldend = Get-Date -Year 2038 -Month 01 -Day 19 -Hour 3 -Minute 14 -Second 7

# In the following problems, use the above objects and their properties # whever possible. For example, to output the date and time the world will end, # write: Write-Host "The world will end on $worldend" # instead of Write-Host "The world will end on 01/19/2038 03:14:07."

#1) Use $creator to output: Bill Finger created Batman Write-Host "$creator created $($friends[1])"

#2) Use $friends to output: These are the superfriends: Aquaman Batman Robin Superman Wonder Woman Write-Host "These are the superfriends: $friends"

#3) Use $friends to output: Aquaman swims in the ocean. # Hint: Use Aquaman's index in the $friends array Write-Host "$($friends[0]) swims in the ocean."

#4) Use $hosts to output: My hosts file is 898 bytes long # The name of the file and the number of bytes should be pulled # from properties of the $hosts object. Write-Host "My $($hosts.Name) file is $($hosts.length)"

#5) Use $hosts to output: "Do not delete C:\Windows\System32\drivers\etc\hosts" # Do NOT use any properties of the $hosts file. (Try using the entire object in write-host.)

#6) Create the string "Hello Batmand and Robin." in a variable called greeting. # The values Batman and Robin should come from the $friends variable.

#7) Output the value of the $greeting variable from the previous problem.

#8) Output: The world will end on a ____ # Replace ____ with the day of the week (e.g. "Monday") from $worldend. # Use the appropriate $worldend property in the Write-Host statement rather # than hardcoding the day of the week. # Complete this problem in a single Write-Host statement.

#9) Output: The day after the world's end is a ____ . # Replace ____ with the day of the week. # Hint: Usee the AddDays function on the $worldend object to get the following day. # Complete this problem in a single Write-Host statement. # Sub-hint: It might be helpful to write some test code that gets the date of the # week, then once that works, write the Write-Host statement.

#10) List the friends on a new line using the #pipe ("|") and Write-Host

#11) Write "Hello [friend]" for each of the friends. # Use the ForEach cmdlet to loop through the $friends array.

#12) Use the pipe and foreach to check the length of # the names in $friends. # If the name is longer than 6, output: "Long name: [name]" # Otherwise, output: "Short name: [name]"

#13) Store the contents of all files in C:\Windows\System32\drivers\etc # in a variable called $files

#14) In a single line of code, compute the MD5 hashes of all files # in $files. # Hint: Use piping and the Get-FileHash cmdlet.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

Find the exact value of cos 90.

Answered: 1 week ago