AIU Windows PowerShell Script for Registry Check Questions
ANSWER
To accomplish the tasks described in your assignment, you can create a PowerShell script. Here’s a sample script that performs the required actions:
# Define the registry paths
$currentUserPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
$localMachinePath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run"
# Load the list of acceptable entries from a text file
$acceptableEntries = Get-Content -Path "Acceptable_Reg.txt"
# Get the computer name
$computerName = $env:COMPUTERNAME
# Initialize a list to store unacceptable entries
$unacceptableEntries = @()
# Function to compare registry entries
function Compare-Entries {
param (
[string]$registryPath,
[string]$registryKey
)
$entry = Get-ItemProperty -Path $registryPath -Name $registryKey -ErrorAction SilentlyContinue
if ($entry -ne $null) {
$value = $entry.$registryKey
if ($value -notin $acceptableEntries) {
$unacceptableEntries += "$registryPath\$registryKey = $value"
}
}
}
# Check and compare entries in both registry locations
Compare-Entries -registryPath $currentUserPath -registryKey $_
Compare-Entries -registryPath $localMachinePath -registryKey $_
# Generate a report file
if ($unacceptableEntries.Count -gt 0) {
$reportFileName = "$computerName_Report.txt"
$unacceptableEntries | Out-File -FilePath $reportFileName
# Transmit the report file to the intranet address (replace with your actual address)
Copy-Item -Path $reportFileName -Destination "\\intranet-address\$reportFileName"
}
# Display a message indicating the script has completed
Write-Host "Registry check completed. Unacceptable entries have been logged."
Make sure to replace "Acceptable_Reg.txt"
with the actual path to your list of acceptable registry entries. Also, replace "\\intranet-address\"
with the actual intranet address where you want to transmit the report file.
To use this script, you can save it as a .ps1
file and make it available for download on your company intranet. Users can then download and run the script on their Windows machines. It will check the specified registry locations for unacceptable entries, log them to a report file, and transmit the report to the intranet address.
QUESTION
Description
Assignment Description
One of the major causes of system performance issues is programs that run in the background and are started when the system starts. These programs are usually installed, so they are started from one of two entries in the system registry:
HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run
HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Run
As a network administrator, you would like to gather information about these registry entries for all the computers in the network. You have selected Windows PowerShell to write a script for this task. Your plan will result in a document with a script for the tasks involved. Because there are security issues that prevent executing the scripts on remote computers, the script will be distributed to all users on the network as a download link on the company intranet. For purposes of this exercise, security issues can be ignored, so the script is not required to take security issues into account.
Prepare a document to submit your work:
Use Word.
- Title Page
- Course number and name
Project name
Student name
- Date
Provide well-documented source code for a Windows PowerShell script that will perform the following tasks:
- Read the registry entries from both of the locations named in the project description.
- Compare each entry to a list of acceptable entries. The acceptable entry list is from a text file named “Acceptable_Reg.txt” that will accompany the script when the script is downloaded.
Produce a text file report that lists all unacceptable registry entries. Save the report using the computer name as the file name.
- Transmit the report file to the following intranet address:
![Place Your Order Here](http://scholarywriters.com/wp-content/uploads/2023/08/Bottom-of-every-post.png)