I've been looking answers on the Internet and even used AI prompt to make these implementations happen. I'm inexperience in Batch Script and PowerShell so your advice and assistance would be greatly appreciated.
I already tried this batch script but I found it inaccurate. Is there anyway to improve this?
@echo off
echo Checking Security and Maintenance Settings...
echo --------------------------------------------
:: Windows Update Status
echo Checking Windows Update...
PowerShell -Command "$status = (Get-Service wuauserv).Status; if ($status -eq 'Running') {Write-Host 'Windows Update: ON'} else {Write-Host 'Windows Update: OFF'}"
:: Internet Security Settings (SmartScreen)
echo Checking Internet Security Settings...
PowerShell -Command "$status = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer' -Name SmartScreenEnabled -ErrorAction SilentlyContinue).SmartScreenEnabled; if ($status -eq 'RequireAdmin' -or $status -eq 'Warn') {Write-Host 'SmartScreen: ON'} else {Write-Host 'SmartScreen: OFF'}"
:: Network Firewall Status
echo Checking Network Firewall...
PowerShell -Command "$status = (Get-NetFirewallProfile | Where-Object { $_.Enabled -eq 'True' }); if ($status) {Write-Host 'Firewall: ON'} else {Write-Host 'Firewall: OFF'}"
:: Microsoft Account Sign-in
echo Checking Microsoft Account...
PowerShell -Command "$status = (Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\AccountPicture\Users' -ErrorAction SilentlyContinue); if ($status) {Write-Host 'Microsoft Account: ON'} else {Write-Host 'Microsoft Account: OFF'}"
:: Windows Activation
echo Checking Windows Activation...
PowerShell -Command "$status = (Get-CimInstance -ClassName SoftwareLicensingProduct | Where-Object { $_.Name -like 'Windows' }).LicenseStatus; if ($status -eq 1) {Write-Host 'Windows Activated: YES'} else {Write-Host 'Windows Activated: NO'}"
:: Spyware and Unwanted Software Protection
echo Checking Spyware Protection...
PowerShell -Command "$status = (Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiSpywareProduct); if ($status) {Write-Host 'Spyware Protection: ON'} else {Write-Host 'Spyware Protection: OFF'}"
:: User Account Control (UAC)
echo Checking User Account Control...
PowerShell -Command "$status = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name EnableLUA).EnableLUA; if ($status -eq 1) {Write-Host 'UAC: ON'} else {Write-Host 'UAC: OFF'}"
:: Virus Protection
echo Checking Virus Protection...
PowerShell -Command "$status = (Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct); if ($status) {Write-Host 'Antivirus: ON'} else {Write-Host 'Antivirus: OFF'}"
:: Windows Backup
echo Checking Windows Backup...
PowerShell -Command "$status = (wbadmin get status 2>&1 | Out-String); if ($status -match 'The backup operation has completed successfully') {Write-Host 'Windows Backup: ON'} else {Write-Host 'Windows Backup: OFF'}"
:: Automatic Maintenance
echo Checking Automatic Maintenance...
PowerShell -Command "$status = (Get-ScheduledTask | Where-Object { $_.TaskName -like 'Maintenance*' }).State; if ($status -eq 'Ready') {Write-Host 'Automatic Maintenance: ON'} else {Write-Host 'Automatic Maintenance: OFF'}"
:: Drive Status
echo Checking Drive Health...
PowerShell -Command "$status = (Get-PhysicalDisk | Where-Object { $_.OperationalStatus -eq 'OK' }); if ($status) {Write-Host 'Drive Status: OK'} else {Write-Host 'Drive Status: Issues Detected'}"
:: Device Software (Drivers)
echo Checking Device Drivers...
PowerShell -Command "$status = (Get-PnpDevice | Where-Object { $_.Status -eq 'OK' }); if ($status) {Write-Host 'Device Software: OK'} else {Write-Host 'Device Software: Issues Found'}"
:: Startup Apps
echo Checking Startup Applications...
PowerShell -Command "$status = (Get-CimInstance Win32_StartupCommand); if ($status) {Write-Host 'Startup Apps: Enabled'} else {Write-Host 'Startup Apps: Disabled'}"
:: Windows Troubleshooting
echo Checking Troubleshooting Settings...
PowerShell -Command "$status = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics' -ErrorAction SilentlyContinue); if ($status) {Write-Host 'Windows Troubleshooting: ON'} else {Write-Host 'Windows Troubleshooting: OFF'}"
:: File History
echo Checking File History...
PowerShell -Command "$status = (fhmanagew.exe -getconfig 2>&1 | Out-String); if ($status -match 'File History is on') {Write-Host 'File History: ON'} else {Write-Host 'File History: OFF'}"
:: Storage Spaces
echo Checking Storage Spaces...
PowerShell -Command "$status = (Get-StoragePool | Where-Object { $_.HealthStatus -eq 'Healthy' }); if ($status) {Write-Host 'Storage Spaces: OK'} else {Write-Host 'Storage Spaces: Issues Found'}"
:: Work Folders
echo Checking Work Folders...
PowerShell -Command "$status = (Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\WorkFolders' -ErrorAction SilentlyContinue); if ($status) {Write-Host 'Work Folders: Configured'} else {Write-Host 'Work Folders: Not Configured'}"
echo --------------------------------------------
pause
But unfortunately I'm unable to find the exact solutions I need to solve these problems.
I also want to know if the implementations I requested are currently not possible to implement, for documentation purposes only.
Thank you very much.
よろしくお願いいたします。
I understand that you are looking for whether notification is enabled or not for each item.
Write-Output -InputObject 'Checking Security and Maintenance Notifications…'
Write-Output -InputObject ( '-' * 60 )
$Mapping = [Ordered]@{
'{01979c6a-42fa-414c-b8aa-eee2c8202018}.check.100' = 'Windows Backup'
'{34A3697E-0F10-4E48-AF3C-F869B5BABEBB}.check.9001' = 'Work Folders'
'{3FF37A1C-A68D-4D6E-8C9B-F79E8B16C482}.check.100' = 'Drive Status'
'{A5268B8E-7DB5-465b-BAB7-BDCDA39A394A}.check.100' = 'Windows Troubleshooting'
'{AA4C798D-D91B-4B07-A013-787F5803D6FC}.check.100' = 'Storage Spaces'
'{B447B4DB-7780-11E0-ADA3-18A90531A85A}.check.100' = 'File History'
'{C8E6F269-B90A-4053-A3BE-499AFCEC98C4}.check.0' = 'User Account Control'
'{DE7B24EA-73C8-4A09-985D-5BDADCFA9017}.check.800' = 'Automatic Maintenance'
'{E8433B72-5842-4d43-8645-BC2C35960837}.check.100' = 'Virus Protection'
'{E8433B72-5842-4d43-8645-BC2C35960837}.check.101' = 'Network Firewall'
'{E8433B72-5842-4d43-8645-BC2C35960837}.check.104' = 'Internet Security Settings'
}
$Root = 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Security and Maintenance\Checks'
$Property = 'CheckSetting'
$Mapping.Keys |
ForEach-Object -Process {
$CurrentKey = $PSItem
$CurrentFeature = $Mapping[ $CurrentKey ]
$Status = Get-ItemPropertyValue -LiteralPath "$Root\$CurrentKey" -Name $Property
$Status = @( 'disabled', 'enabled' )[ $Status[ 0 ] -eq 35 ]
"$CurrentFeature ==> Notification $Status"
}
I used an online translator. I apologize for not being fluent in the language.
どういたしまして 🙏