You will create a script using PowerShell that meets the following requirements:
ID: 3646289 • Letter: Y
Question
You will create a script using PowerShell that meets the following requirements:a. contains appropriate comments (see Role of comment which is also located in the course materials and resources in the moodle course).
b. queries WMI and creates the following output suitable for the system information section of an engineering journal.
-OS-{Title of OS here} - ex:XP Professional
-Service Pack - {Service Pack Level here} - ex:2
-CPU - {CPU type and Speed here} - ex:Pentium 4 2.66 GHz
-HD Freespace -{Hard drive free space on the C:drive} - ex 22 GB
c. the script should be able to perform queries locally or remotely
d. name the script systeminfo.ps1
Execute the script, and then save the output as computername.txt where computername is the name of the computer the information is obtained from (ensure this syntax is documented appropriately).
Explanation / Answer
Following is the code which meets all requirement you want. " $title = "System Utilities" $message = "Select which utility you would like to view." $A = New-Object System.Management.Automation.Host.ChoiceDescription "&A", ` "Show Services." $B = New-Object System.Management.Automation.Host.ChoiceDescription "&B", ` "Show Processes." $C = New-Object System.Management.Automation.Host.ChoiceDescription "&C", ' "Displays systeminfo.ps1" $options = [System.Management.Automation.Host.ChoiceDescription[]]($A, $B, $C) $result = $host.ui.PromptForChoice($title, $message, $options, 0) switch ($result) { 0 {"You selected A." Get-Service} 1 {"You selected B." Get-Process} 2 {"You selected C." h:ist321systeminfo.ps1} } switch ($result) { 0 { "** Option A **"; Get-Service } 1 { "** Option B **"; Get-Process } 2 { "** Option C **"; } } "
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.