Microsoft Word XXXXXXXXXXPowershell1.docx Lab 09 – PowerShell 1 Overview In this lab, you’ll be writing a number of scripts. These should each be separate files, all uploaded to the same Git...

1 answer below »
See attached. Must be done in PowerShell


Microsoft Word - 09 - Powershell1.docx Lab 09 – PowerShell 1 Overview In this lab, you’ll be writing a number of scripts. These should each be separate files, all uploaded to the same Git repository. Script 1 – Backup • Will back up the given file by making a copy with the .backup extension • Takes the file name as a script argument • Make a copy of that file and add “.backup” to the name o i.e. the backup of “file.txt” would be “file.txt.backup” o .\backup.ps1 .\file.txt Script 2 – Enhanced Backup • Will back up all given files in the current directory with a given extension into a separate folder • Takes an extension as a script argument • Within the current directory, copy all files matching the argument to a folder called backup o Create the folder backup if necessary • Tell the user which files were backed up o .\ebackup.ps1 txt Backed up file.txt Script 3 – Process Checker • Takes a process ID as a script argument o Also takes sleep time (X) as an optional argument (provide a default value) • Watch the process and check every X seconds to see if it is still running • Set the output accordingly with the status of the process o Hint: use Get-Process and sleep o .\processcheck.ps1 4044 Script 4 – Archiver • Zip up any file in the current directory that hasn’t been modified in X days o Take the numbers of days as a parameter o Hint: use Get-Date cmdlet and .AddDays() method • Name the new zip file with the current date o Hint: Compress-Archive o .\archive.ps1 2 Severin Carlson Cross-Out Script 5 – Create Local User Accounts Note: Since this is creating users you probably will want to run this on a VM instead of your personal system unless you plan to carefully remove all new users. • Takes a filename as a parameter o The file contains usernames, one on each line • Take the password from the user using Read-host, not as a parameter o Use the same default password for each account o You’ll need to use -AsSecureString • Create a local user account for each user in the text file o .\users.ps1 .\users.txt Microsoft Word - 09 - Powershell1.docx Lab 09 – PowerShell 1 Overview In this lab, you’ll be writing a number of scripts. These should each be separate files, all uploaded to the same Git repository. Script 1 – Backup • Will back up the given file by making a copy with the .backup extension • Takes the file name as a script argument • Make a copy of that file and add “.backup” to the name o i.e. the backup of “file.txt” would be “file.txt.backup” o .\backup.ps1 .\file.txt Script 2 – Enhanced Backup • Will back up all given files in the current directory with a given extension into a separate folder • Takes an extension as a script argument • Within the current directory, copy all files matching the argument to a folder called backup o Create the folder backup if necessary • Tell the user which files were backed up o .\ebackup.ps1 txt Backed up file.txt Script 3 – Process Checker • Takes a process ID as a script argument o Also takes sleep time (X) as an optional argument (provide a default value) • Watch the process and check every X seconds to see if it is still running • Set the output accordingly with the status of the process o Hint: use Get-Process and sleep o .\processcheck.ps1 4044 Script 4 – Archiver • Zip up any file in the current directory that hasn’t been modified in X days o Take the numbers of days as a parameter o Hint: use Get-Date cmdlet and .AddDays() method • Name the new zip file with the current date o Hint: Compress-Archive o .\archive.ps1 2 Severin Carlson Cross-Out Script 5 – Create Local User Accounts Note: Since this is creating users you probably will want to run this on a VM instead of your personal system unless you plan to carefully remove all new users. • Takes a filename as a parameter o The file contains usernames, one on each line • Take the password from the user using Read-host, not as a parameter o Use the same default password for each account o You’ll need to use -AsSecureString • Create a local user account for each user in the text file o .\users.ps1 .\users.txt
Answered Same DayApr 06, 2021

Answer To: Microsoft Word XXXXXXXXXXPowershell1.docx Lab 09 – PowerShell 1 Overview In this lab, you’ll be...

Abr Writing answered on Apr 12 2021
159 Votes
ABR3031/archive.ps1
if ($args.length -eq 1) {
    $days = $args[0]
    $files = (Get-ChildItem -Path ""
| ? {
     $_.LastWriteTime -gt (Get-Date).AddDays($days)
    })
    $compress = @{
                 Path = $files
                 CompressionLevel = "Fastest"
                 DestinationPath = "compressed.zip"
                }
    try {
        Compress-Archive @compress
    } catch {}
} else {
    Write-Host "Usage: ./archive.ps1 "
}
ABR3031/processcheck.ps1
if ($args.length -eq 1) {
    $time = 5
    $id = $args[0]
} elseif...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here