Upload files to "/"

This commit is contained in:
aaron 2023-12-18 18:01:44 +00:00
parent 595813d05e
commit 508d41a1d4
5 changed files with 109 additions and 0 deletions

View File

@ -0,0 +1,12 @@
# Monitors whether the local Administrator account's password has changed
$version = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").CurrentVersion
if($Version -lt "6.3") {write-host "Unsupported OS. Only Server 2012R2 or 8.1 and up are supported."; exit 0}
$LastDay = (Get-Date).addhours(-24)
$AdminGroup = Get-LocalGroupMember -SID "S-1-5-32-544"
$ChangedAdmins = foreach($Admin in $AdminGroup){get-localuser -ErrorAction SilentlyContinue -sid $admin.sid | Where-Object {$_.PasswordLastSet -gt $LastDay}}
if (!$ChangedAdmins){write-host "Healthy"}
else {write-host "Unhealthy. Please check diagnostics"; write-host ($ChangedAdmins | fl *); exit 1}

View File

@ -0,0 +1,20 @@
# Monitors if any new active directory users are created
$When = ((Get-Date).AddDays(-1)).Date
$GetUsers = Get-ADUser -Filter { whenCreated -ge $When } -Properties whenCreated
$UserChanges = foreach ($User in $GetUsers) {
[PSCustomObject]@{
Name = $user.name
CreatedOn = $user.whencreated
UPN = $user.userprincipalname
}
}
if (!$GetUsers) {Write-Host "Healthy - No new users found"}
else {
Write-Host "New Users Found"
if (($UserChanges | Measure-Object).Count -ne 1){foreach ($User in $UserChanges) { $User }}
else{$UserChanges[0]}
exit 1
}

19
Monitor-OldComputers.ps1 Normal file
View File

@ -0,0 +1,19 @@
# Monitors Active directory Computers that have not been logged into for a given amount of days.
$threashold = -180 # Negative Integer, the age threshold of accounts that any older will be disabled.
$age = (Get-Date).AddDays($threashold)
$DomainCheck = Get-CimInstance -ClassName Win32_OperatingSystem
if ($DomainCheck.ProductType -ne "2") { Write-Host "Not a domain controller. Soft exiting." ; exit 0 }
$OldComputers = Get-ADComputer -Filter * -properties Name,DNSHostName,SamAccountName,Enabled,WhenCreated,LastLogonDate,operatingsystem,isCriticalSystemObject | Select-Object Name,DNSHostName,SamAccountName,Enabled,WhenCreated,LastLogonDate,operatingsystem,isCriticalSystemObject | Where-Object {$_.LastLogonDate -lt $age} | Where-Object { $_.Enabled -eq $True} | Where-Object {$_.operatingsystem -notlike "*server*"} | Where-Object {$_.isCriticalSystemObject -eq $false} | Where-Object { $_.WhenCreated -lt ((Get-Date).AddDays(-14))}
if (!$OldComputers) {Write-Host "Healthy"; exit 0}
else {
Write-Host "Not Healthy - Computer accounts found that have not logged on for 180 days"
if ($Host.Version.Major -gt 4){foreach ($message in $OldComputers){Write-Host $message}}
elseif ($Host.Version.Major -lt 5){foreach ($message in $OldComputers){$message}}
else {foreach ($message in $OldComputers){Write-Host $message}}
exit 1
}

23
Monitor-OldUsers.ps1 Normal file
View File

@ -0,0 +1,23 @@
# Monitors Active directory Users that have not been logged into for a given amount of days.
$threashold = -180 # Negative Integer, the age threshold of accounts that any older will be disabled.
$age = (Get-Date).AddDays($threashold)
$DomainCheck = Get-CimInstance -ClassName Win32_OperatingSystem
if ($DomainCheck.ProductType -ne "2") { Write-Host "Not a domain controller. Soft exiting." ; exit 0 }
$blacklistU = @(
"Administrator"
)
$OldUsers = Get-ADuser -Filter * -properties Name, UserPrincipalName, SamAccountName, Enabled, WhenCreated, LastLogonDate, msDS-LastSuccessfulInteractiveLogonTime | Select-Object Name, UserPrincipalName, SamAccountName, Enabled, WhenCreated, LastLogonDate, msDS-LastSuccessfulInteractiveLogonTime | Where-Object { $_.LastLogonDate -lt $age } | Where-Object { $_.Enabled -eq $True}| Where-Object { $_.UserPrincipalName -ne $null} | Where-Object { $_.Name -notin $blacklistU} | Where-Object { $_.SamAccountName -notin $blacklistU} | Where-Object { $_.WhenCreated -lt ((Get-Date).AddDays(-14))}
if (!$OldUsers) {Write-Host "Healthy"; exit 0}
else {
Write-Host "Not Healthy - User accounts found that have not logged on for 180 days:"
if ($Host.Version.Major -gt 4){foreach ($message in $OldUsers){Write-Host $message}}
elseif ($Host.Version.Major -lt 5){foreach ($message in $OldUsers){$message}}
else {foreach ($message in $OldUsers){Write-Host $message}}
exit 1
}

View File

@ -0,0 +1,35 @@
# Monitors whether an Orthotrac backup has run in the last day.
$oldAge = -1
$oldDate = (Get-Date).AddDays($oldAge)
Function Get-BackupDir
{
$Disks = (get-volume).driveletter | Where-Object {$_ -ne $null}
$BackupDisk = ForEach ($Disk in $Disks)
{
$Drive = "$Disk"+":\"
$Search = Get-ChildItem "$Drive" | Where-Object {$_.PSIsContainer -eq $true -and $_.Name -match "Orthotrac"}
if ($Search -ne $null){echo $Disk}
}
$BackupDir = "$BackupDisk"+":\Orthotrac\OMS\Backup\Most_Recent"
echo $BackupDir
}
Function Get-BackupDate
{
$BackupDir = Get-BackupDir
$Files = ForEach ($File in (Get-ChildItem -Path $BackupDir)){echo $File}
$EarliestFile = $Files | Sort-Object LastWriteTime | Select-Object -First 1
echo $EarliestFile.LastWriteTime
}
$BackupDate = Get-BackupDate
if ($BackupDate -lt $oldDate){echo "Backup not ran today"}
else {echo "backup ran today"}