Question
# Leave all comments and instructions # Put your PowerShell code below the problem description. #a) Create code to generate some small # text files.
# Leave all comments and instructions # Put your PowerShell code below the problem description.
#a) Create code to generate some small # text files. Some of the files should # have the same contents (e.g. "sample"). # The code should generate files and # folders in the current working directory. # Create at least 10 files. # At least 2 different files should match. # For example, "a.txt" and "b.txt" could both # have the contents "single letter." # Create at least 2 folders. # Each folder should have at least 1 file. # Loops can make your code shorter, but they # are not required.
#b) Write a function called FindExactMatches # that accepts a folder as an input. # # The function should find exact matches # in the input folder and subfolders. # # Matching should be based off of the # hash of the file. (I.e., a match exists # only if the two files have the same hash.) # # The function should output the following # for each match (without quotes): # "The following file are duplicates: # - c:\temp\cat.txt # - c:\temp\dog.txt" # # Bonus: Make the algorithm efficient by # only hashing files that have a potential # of generating the same hash rather than # hashing all files. (Hint: different sized # files cannot have the same hash [assuming # there are no hash collisions].)
#c) Test your FindExactMatches function # Use the files and folders you created in # part c to check your work.
# This next section asks you to be # creative and resourceful. Search # the internet as needed for inspiration, # but write your own code. If you find an # example online, tweak it to make it your # own. These problems are intentionally # vague. Part of being a professional is # being able to define your own problems.
#d) Write at least 3 lines of PowerShell code # that does something useful on your machine. # Describe what the lines of code do in comments.
#e) Write a PowerShell function that might help # analyze data, automate a task, or format # output in a certain way that is easier to read. # Describe the purpose of the function in a comment. # Demonstrate how it should be used.
#f) Find a cmdlet that you think would be helpful. # Use the cmdlet in a short script to demonstrate # how it can be used. Provide a brief description # of the cmdlet.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started