Question: A colleague has written a script that runs every month on a server with sensitive data. Evaluate the script and explain in 150 words or
A colleague has written a script that runs every month on a server with sensitive data. Evaluate the script and explain in 150 words or less what the script does? You are not expected to execute the script, just interpret it the best you can. If the code below is difficult to read in D2L, copy and paste the code into Visual Studio Code or notepad.
### Begin Script ###
$username = "Administrator" $sendEmail = $True $to="nigel@ung.edu" $from="loginAlerts@ung.edu" $last2MonthsFromToday = (get-date).AddDays(-60) $signInLogs = Get-Eventlog -LogName Security -after $last2MonthsFromToday | where {$_.eventID -eq 4624 -and $_.message -like "*$username*" } $signInDates = @() foreach($signIn in $signInLogs) { $signInDates += $signIn.TimeGenerated } $signInCount = $signInLogs.count $emailBody = "$username has signed in $signInCount times into $env:computername. Below are the sign in dates. $signInDates)" if($sendEmail -eq $True) { Send-MailMessage -From $from -To $to -Subject 'SignIn Alert' -Body $emailBody } else { Write-Output "To: $to" Write-Output "From: $from" Write-Output "Subject: SignIn Alert" Write-Output "Body: $emailBody" } |
### End of Script ###
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
