PowerShell Script to Check the CMOS Battery Level for All Computer Objects in the Domain

 Here is an PowerShell script that checks the CMOS battery of all computer objects in the domain:


# Define the domain name
$domain = "yourdomain.com"

# Get a list of all computer objects in the domain
$computers = Get-ADComputer -Filter {OperatingSystem -Like "*Windows*"} -Properties Name | Select-Object -ExpandProperty Name

# Loop through each computer and check the CMOS battery
foreach ($computer in $computers) {
    Write-Host "Checking CMOS battery of computer $computer..."
    $session = New-PSSession -ComputerName $computer
    $wmi = Invoke-Command -Session $session -ScriptBlock { Get-WmiObject win32_battery | Where-Object {$_.Name -match "CMOS"} }
    $wmi | Select-Object PSComputerName, EstimatedChargeRemaining
    Remove-PSSession $session
}

Comments

Popular posts from this blog

Unveiling the Power of PowerShell Regions: A Comprehensive Guide

PowerShell Script to Remotely Update Firmware on Brother Printers Microsoft

PowerShell Script to Reset Permissions on all Documents in a Document Library in SharePoint Online.