Is there a way to read or get or fetch automatically the setting values from [Control Panel > Security and Maintenance] & [Change Security and Maintenance settings] using Batch Script or PowerShell?
I've been looking for 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.
- How to read or get or fetch automatically the setting values from [Control Panel > Security and Maintenance > Change Security and Maintenance settings] using Batch Script or PowerShell?
I already tried this batch script but I found it inaccurate (Everything is inaccurate, it does not get the correct value from the settings). 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
- How to read or get or fetch automatically the setting values from [Control Panel > Security and Maintenance] using Batch Script or PowerShell?
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.
よろしくお願いいたします。
Windows 10 Security
1 answer
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more