Windows log-on problems are often caused by important background services being disabled or stuck. When this happens, users may not be able to sign in properly, profiles can fail to load, or Group Policy simply stops working.
This PowerShell script checks all critical Windows services required for user log-on, sets them back to Automatic, starts anything that is not running, and then forces a full Group Policy update.
It is a quick and safe way to recover broken machines without rebuilding them.
Why people need this script
This script is useful when:
-
Users cannot log in or get stuck on “Preparing Windows”
-
User profiles load slowly or fail
-
Group Policy settings stop applying
-
Network or domain features disappear
-
Machines behave as if they are no longer part of the domain
Script
<#
.SYNOPSIS
Repairs Windows services required for user log-on and forces Group Policy refresh.
.DESCRIPTION
This script:
- Sets critical log-on services to Automatic
- Starts any that are stopped
- Forces a full Group Policy refresh
.NOTES
Author: DIGITALGEEKERY
Version: 1.1
#>
$Services = @(
"ProfSvc",
"gpsvc",
"EventLog",
"RpcEptMapper",
"netprofm",
"nlasvc",
"WlanSvc",
"lanmanworkstation"
)
foreach ($Service in $Services) {
Set-Service -Name $Service -StartupType Automatic -ErrorAction SilentlyContinue
Start-Service -Name $Service -ErrorAction SilentlyContinue
}
Start-Process "gpupdate.exe" -ArgumentList "/force" -Wait
Write-Output "Critical services checked and Group Policy refresh completed."