Skip to content

Commit 302ac23

Browse files
Merge pull request #305 from sid351/main
Added a script to move agents based on the logged in user's domain name.
2 parents 3160e96 + 85471d7 commit 302ac23

8 files changed

Lines changed: 172 additions & 328 deletions

scripts_wip/Win_Battery_Capacity_Check.ps1

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ if ($absoluteValues) {
4343
$label = "mWh"
4444
}
4545

46-
If($available -le $minimumBatteryCapacity)
47-
{
48-
Write-Output "The battery needs investigating. Full charge capacity is below the threshold of $minimumBatteryCapacity $label ($available $label available of design capacity $designCapacity mWh."
49-
Exit 1
50-
} else {
51-
Write-Output "The battery is reporting ok. Full charge capacity is above the threshold of $minimumBatteryCapacity $label ($available $label available of design capacity $designCapacity mWh."
52-
Exit 0
53-
}
46+
"Full charge capacity $available$label of $designCapacity mWh."
47+
48+
If($available -le $minimumBatteryCapacity){ Exit 1 }
49+
Exit 0

scripts_wip/Win_CPU_Uptime_Check.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Param(
1717
$uptime = (get-Date) - (Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -ExpandProperty LastBootUpTime)
1818
#v7 introduces Get-Uptime, but using WMI is backwards compatiable with v5
1919

20-
If($uptime.TotalHours -ge $maximumUptimeHoursWarningLimit){
21-
"Uptime is over threshold ($($uptime.TotalHours)/$maximumUptimeHoursWarningLimit)"
22-
Exit 1
23-
}
20+
$hiberbootEnabled = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power' -Name 'HiberbootEnabled' -ErrorAction Stop).HiberbootEnabled
21+
[bool]$FastStartupEnabled = ($hiberbootEnabled -eq 1)
2422

25-
"Uptime is below threshold ($($uptime.TotalHours)/$maximumUptimeHoursWarningLimit)"
23+
"CPU Uptime $([math]::Round($uptime.TotalHours,2)) hours. Fast Startup enabled: $FastStartupEnabled"
24+
25+
If($uptime.TotalHours -ge $maximumUptimeHoursWarningLimit){ Exit 1 }
2626
Exit 0

scripts_wip/Win_Disk_HealthCheck.ps1

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@
1818
Param(
1919
[Parameter(Mandatory = $false)]
2020
[int]#Warn if the temperature (in degrees C) is over this limit
21-
$TemperatureWarningLimit = 55,
21+
$TemperatureWarningLimit = 60,
2222

2323
[Parameter(Mandatory = $false)]
2424
[int]#Warn if the "wear" of the drive (as a percentage) is above this
25-
$maximumWearAllowance = 20,
26-
27-
[Parameter(Mandatory = $false)]
28-
[switch]#Outputs a full report, instead of warnings only
29-
$fullReport
25+
$maximumWearAllowance = 20
3026
)
3127

3228
BEGIN {
@@ -41,7 +37,6 @@ PROCESS {
4137
Try{
4238
#Using Windows Storage Reliabilty Counters first (the information behind Settings - Storage - Disks & Volumes - %DiskID% - Drive health)
4339
$physicalDisks = Get-PhysicalDisk -ErrorAction Stop
44-
$storageResults = @()
4540
foreach ($disk in $physicalDisks) {
4641
$reliabilityCounter = $null
4742
try {
@@ -50,43 +45,40 @@ PROCESS {
5045
catch {
5146
Write-Error "No Storage Reliability Counter for '$($disk.FriendlyName)'. This usually means the driver/controller isn't exposing it."
5247
}
48+
$driveLetters = (get-disk -FriendlyName $Disk.FriendlyName | Get-Partition | Where-Object -FilterScript {$_.DriveLetter} | Select-Object -Expand DriveLetter) -join ", "
5349

54-
$storageResults += [pscustomobject]@{
50+
<#
51+
DriveLetters = $driveLetters
52+
HealthStatus = $disk.HealthStatus
5553
FriendlyName = $disk.FriendlyName
5654
SerialNumber = $disk.SerialNumber
5755
BusType = $disk.BusType
58-
HealthStatus = $disk.HealthStatus
5956
OperationalStatus = ($disk.OperationalStatus -join ", ")
6057
Temperature = $reliabilityCounter.Temperature
6158
Wear = $reliabilityCounter.Wear
6259
ReadErrorsTotal = $reliabilityCounter.ReadErrorsTotal
6360
WriteErrorsTotal = $reliabilityCounter.WriteErrorsTotal
6461
ReallocatedSectors = $reliabilityCounter.ReallocatedSectors
6562
PowerOnHours = $reliabilityCounter.PowerOnHours
66-
}
67-
63+
#>
6864
If(
6965
$disk.HealthStatus.ToLower() -ne "healthy" -or
7066
($disk.OperationalStatus | Where-Object -FilterScript { $_.ToLower() -ne "ok" }) -or
71-
$reliabilityCounter.Wear -ge $maximumWearAllowance -or
72-
$reliabilityCounter.Temperature -ge $TemperatureWarningLimit
67+
$reliabilityCounter.Wear -gt $maximumWearAllowance -or
68+
$reliabilityCounter.Temperature -gt $TemperatureWarningLimit
7369
){
74-
Write-Error -Message "$($disk.FriendlyName) has conditions that require investigation. $storageResults"
70+
"Disk issue: $DriveLetters $($disk.HealthStatus) Status:$(($disk.OperationalStatus -join ", ")) $($reliabilityCounter.Temperature)*C $($reliabilityCounter.Wear)% wear"
71+
Write-Error -Message "Disk issues need investigating"
72+
} else {
73+
"$DriveLetters $($disk.HealthStatus) Status:$(($disk.OperationalStatus -join ", ")) $($reliabilityCounter.Temperature)*C $($reliabilityCounter.Wear)% wear"
7574
}
7675
}
77-
78-
If($fullReport) { $storageResults }
79-
8076
} catch {
8177
Write-Error -Message "Get-PhysicalDisk failed. This can happen on older OS builds or restricted environments."
8278
}
8379
}
8480

8581
END{
86-
if ($error) {
87-
Write-Output $error
88-
exit 1
89-
}
90-
Write-Output "All drives report as healthy"
82+
if ($error) { Exit 1 }
9183
Exit 0
9284
}

scripts_wip/Win_Disk_SMART.ps1

Lines changed: 0 additions & 215 deletions
This file was deleted.

0 commit comments

Comments
 (0)