Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started