Upload files to "/"
This commit is contained in:
parent
508d41a1d4
commit
bbf0c867c7
41
Monitor-PrivilegedGroupChanges.ps1
Normal file
41
Monitor-PrivilegedGroupChanges.ps1
Normal file
@ -0,0 +1,41 @@
|
||||
# Monitors any changes to privileged groups
|
||||
|
||||
Function Get-PrivilegedGroupChanges {
|
||||
Param(
|
||||
$Server = "localhost",
|
||||
$Hour = 24
|
||||
)
|
||||
|
||||
$ProtectedGroups = Get-ADGroup -Filter 'AdminCount -eq 1' -Server $Server
|
||||
$Members = @()
|
||||
|
||||
ForEach ($Group in $ProtectedGroups) {
|
||||
$Members += Get-ADReplicationAttributeMetadata -Server $Server `
|
||||
-Object $Group.DistinguishedName -ShowAllLinkedValues |
|
||||
Where-Object {$_.IsLinkValue} |
|
||||
Select-Object @{name='GroupDN';expression={$Group.DistinguishedName}}, `
|
||||
@{name='GroupName';expression={$Group.Name}}, *
|
||||
}
|
||||
$Members |
|
||||
Where-Object {$_.LastOriginatingChangeTime -gt (Get-Date).AddHours(-1 * $Hour)}
|
||||
}
|
||||
|
||||
$ListOfChanges = Get-PrivilegedGroupChanges
|
||||
|
||||
foreach($Change in $ListOfChanges){
|
||||
if($Change.LastOriginatingDeleteTime -gt "1-1-1601 01:00:00"){ $ChangeType = "removed" }
|
||||
else { $ChangeType = "added"}
|
||||
write-host "$($Change.groupname) has been edited. $($Change.AttributeValue) has been $ChangeType"
|
||||
}
|
||||
|
||||
if($ListOfChanges -eq $Null){write-host "GroupChanges=Healthy"}
|
||||
elseif($ListOfChanges.count -gt 1){
|
||||
write-host "GroupChanges=Multiple groups have been changed. Please check diagnostic data"
|
||||
exit 1
|
||||
}
|
||||
else{
|
||||
if($listofchanges.LastOriginatingDeleteTime -gt "1-1-1601 01:00:00"){ $ChangeType = "removed" }
|
||||
else { $ChangeType = "added"}
|
||||
write-host "GroupChanges=$($ListOfChanges.groupname) has been edited. $($listofchanges.AttributeValue) has been $ChangeType"
|
||||
exit 1
|
||||
}
|
20
Monitor-R4Backup.ps1
Normal file
20
Monitor-R4Backup.ps1
Normal file
@ -0,0 +1,20 @@
|
||||
# Monitors wether an R4 Full backup has run in the last day or a database backup in the last 18 hours
|
||||
|
||||
try{
|
||||
$fullBackupLog = Get-EventLog -LogName Application -Source MSSQLSERVER -Message "*FullBackup*" -After (get-date).AddDays(-1)
|
||||
$filteredFullBackupLog = ForEach ($event in $fullBackupLog){if ($event.EventID -eq 18264){$event}}
|
||||
}
|
||||
catch{$filteredFullBackupLog = $null}
|
||||
|
||||
try {
|
||||
$dbBackupLog = Get-EventLog -LogName Application -Source MSSQLSERVER -Message "*DBBackup*" -After (get-date).AddHours(-18)
|
||||
$filteredDbBackupLog = ForEach ($event in $dbBackupLog){if ($event.EventID -eq 18264){$event}}
|
||||
}
|
||||
catch {$filteredDbBackupLog = $null}
|
||||
|
||||
|
||||
if (($filteredFullBackupLog -ne $null) -and ($filteredDbBackupLog -ne $null)){Write-Host "Both Backups have Run"; exit 0}
|
||||
elseif (($filteredFullBackupLog -eq $null) -and ($filteredDbBackupLog -ne $null)){Write-Host "Full Backup has NOT Run"; exit 1}
|
||||
elseif (($filteredFullBackupLog -ne $null) -and ($filteredDbBackupLog -eq $null)){Write-Host "Database Backup has NOT Run"; exit 1}
|
||||
elseif (($filteredFullBackupLog -eq $null) -and ($filteredDbBackupLog -eq $null)){Write-Host "Both Backups have NOT Run"; exit 1}
|
||||
else {Write-Host "Error"; exit 1}
|
22
Monitor-WindowsFirewallState.ps1
Normal file
22
Monitor-WindowsFirewallState.ps1
Normal file
@ -0,0 +1,22 @@
|
||||
# Monitors the state of windows firewall
|
||||
|
||||
function Write-Diag {
|
||||
foreach ($Message in $Messages) { $Message }
|
||||
}
|
||||
|
||||
$FirewallState = @()
|
||||
|
||||
$FirewallProfiles = Get-NetFirewallProfile | Where-Object {$_.Enabled -eq $false}
|
||||
|
||||
If($FirewallProfiles){$FirewallState += "$($FirewallProfiles.name) Profile is disabled"}
|
||||
|
||||
$FirewallAllowed = Get-NetFirewallProfile | Where-Object {$_.DefaultInboundAction -eq "Allow"}
|
||||
|
||||
If($FirewallAllowed){$FirewallState += "$($FirewallAllowed.name) Profile is set to $($FirewallAllowed.DefaultInboundAction) inbound traffic"}
|
||||
|
||||
if(!$FirewallState){Write-Host "healthy"}
|
||||
else {
|
||||
Write-Host $FirewallState
|
||||
Write-Diag @($FirewallProfiles,$FirewallAllowed)
|
||||
exit 1
|
||||
}
|
4
Remove-McAfee.ps1
Normal file
4
Remove-McAfee.ps1
Normal file
@ -0,0 +1,4 @@
|
||||
# Removes McAfee Apps
|
||||
|
||||
$McAfeeApps = Get-AppxPackage -Name "*McAfee*" -AllUsers | Select-Object *
|
||||
foreach ($app in $McAfeeApps){Remove-AppxPackage -Package $app.PackageFullName -AllUsers}
|
46
Run-OrthotracBackup.ps1
Normal file
46
Run-OrthotracBackup.ps1
Normal file
@ -0,0 +1,46 @@
|
||||
# Runs an Orthotrac Backup
|
||||
|
||||
function Write-Diag ($messages) {
|
||||
foreach ($Message in $Messages) { $Message }
|
||||
}
|
||||
Function Write-Alert ($message)
|
||||
{
|
||||
write-host "Alert=$message"
|
||||
}
|
||||
|
||||
Function Get-OMSDir
|
||||
{
|
||||
$Disks = (get-volume).driveletter | Where-Object {$_ -ne $null}
|
||||
|
||||
$OMSDisk = 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}
|
||||
}
|
||||
|
||||
$OMSDir = "$OMSDisk"+":\Orthotrac\OMS"
|
||||
echo $OMSDir
|
||||
}
|
||||
|
||||
Function Execute-OrthoBackup
|
||||
{
|
||||
$OMSDir = Get-OMSDir
|
||||
cd $OMSDir
|
||||
.\orthobac.exe
|
||||
}
|
||||
|
||||
Try
|
||||
{
|
||||
Execute-OrthoBackup
|
||||
Write-Alert "Orthotrac Backup Ran Correctly"
|
||||
Write-Diag @("Orthotrac Backup Ran Correctly" | out-string)
|
||||
exit 0
|
||||
}
|
||||
Catch
|
||||
{
|
||||
Write-Alert "Orthotrac Backup did NOT run Correctly"
|
||||
Write-Diag @("Orthotrac Backup did NOT run Correctly" | out-string)
|
||||
exit 1
|
||||
}
|
||||
exit 1
|
Loading…
x
Reference in New Issue
Block a user