I am very new to PowerShell and I am getting stuck on this question.
- Read the registry entries from both of the locations named in the
project description.
HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Run - 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: intranet.xyzcompany.com/bad_reg.aspx
I have come up with this so far...but I don't think this is the right way to go about it. I know I will probably need to use the compare-object cmdlet but am unsure how to apply it.
$path1 ="HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
$path2 = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run
$destination = "(FileName.txt)"
$results = Get-ItemProperty $path1 $path2
Any help on this would be greatly appreciated because my professor is unable to provide me any type of help with the actual script.
Acceptable_Reg.txt? What results does your code produce? I can see that your first line should be$path ="HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"(note the colon and backslashes). - Lance U. MatthewsCompare-Object $(Get-Content "$location1\file1.reg") $(Get-Content "$location2\file2.reg") | Out-File "c:\temp\differences.txt"- derloopkat