# PCS Toolkit - Service Manager # View and manage common Windows services $timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss" $logFile = "$env:USERPROFILE\Desktop\ServiceManager_$timestamp.txt" function Log($msg) { Write-Host $msg Add-Content $logFile $msg } function LogColor($msg, $color) { Write-Host $msg -ForegroundColor $color Add-Content $logFile $msg } # Common services to manage $services = @( @{Name="Spooler"; Display="Print Spooler"; Desc="Manages print jobs"}, @{Name="wuauserv"; Display="Windows Update"; Desc="Downloads and installs updates"}, @{Name="BITS"; Display="Background Intelligent Transfer"; Desc="Transfers files in background"}, @{Name="Dnscache"; Display="DNS Client"; Desc="Caches DNS lookups"}, @{Name="W32Time"; Display="Windows Time"; Desc="Time synchronization"}, @{Name="TermService"; Display="Remote Desktop Services"; Desc="Allows remote connections"}, @{Name="WinRM"; Display="Windows Remote Management"; Desc="Remote management protocol"}, @{Name="LanmanServer"; Display="Server (File Sharing)"; Desc="SMB file sharing"}, @{Name="LanmanWorkstation"; Display="Workstation"; Desc="SMB client"}, @{Name="WSearch"; Display="Windows Search"; Desc="Content indexing"}, @{Name="SysMain"; Display="SysMain (Superfetch)"; Desc="Maintains system performance"}, @{Name="DiagTrack"; Display="Connected User Experiences"; Desc="Telemetry service"}, @{Name="RemoteRegistry"; Display="Remote Registry"; Desc="Remote registry access"}, @{Name="Schedule"; Display="Task Scheduler"; Desc="Scheduled tasks"}, @{Name="EventLog"; Display="Windows Event Log"; Desc="Event logging"}, @{Name="MpsSvc"; Display="Windows Firewall"; Desc="Windows Defender Firewall"} ) Log "========================================" Log " PCS Toolkit - Service Manager" Log "========================================" Log "Generated: $(Get-Date)" Log "Computer: $env:COMPUTERNAME" Log "" function Show-ServiceStatus { Log "=== SERVICE STATUS ===" Log "" Log ("{0,-35} {1,-12} {2,-10}" -f "Service", "Status", "StartType") Log ("-" * 60) foreach ($svc in $services) { $s = Get-Service -Name $svc.Name -EA SilentlyContinue if ($s) { $status = $s.Status.ToString() $startType = $s.StartType.ToString() $color = if ($s.Status -eq 'Running') { 'Green' } elseif ($s.Status -eq 'Stopped') { 'Yellow' } else { 'White' } $line = "{0,-35} {1,-12} {2,-10}" -f $svc.Display, $status, $startType LogColor $line $color } } Log "" } function Show-Menu { Write-Host "" Write-Host "=== SERVICE MANAGER MENU ===" -ForegroundColor Cyan Write-Host "" Write-Host " 1. Refresh service status" Write-Host " 2. Start a service" Write-Host " 3. Stop a service" Write-Host " 4. Restart a service" Write-Host " 5. Set service to Automatic" Write-Host " 6. Set service to Manual" Write-Host " 7. Set service to Disabled" Write-Host " 8. Quick Actions submenu" Write-Host " 9. Exit" Write-Host "" } function Show-QuickActions { Write-Host "" Write-Host "=== QUICK ACTIONS ===" -ForegroundColor Cyan Write-Host "" Write-Host " 1. Restart Print Spooler (fix printing issues)" Write-Host " 2. Restart Windows Update services" Write-Host " 3. Restart DNS Client (flush DNS)" Write-Host " 4. Stop telemetry services" Write-Host " 5. Enable Remote Desktop" Write-Host " 6. Disable Remote Desktop" Write-Host " 7. Back to main menu" Write-Host "" $choice = Read-Host "Select action" switch ($choice) { "1" { Log "Restarting Print Spooler..." Stop-Service Spooler -Force -EA SilentlyContinue Start-Sleep -Seconds 2 Start-Service Spooler -EA SilentlyContinue Log "Print Spooler restarted" } "2" { Log "Restarting Windows Update services..." Stop-Service wuauserv, BITS, cryptsvc -Force -EA SilentlyContinue Start-Sleep -Seconds 2 Start-Service cryptsvc, BITS, wuauserv -EA SilentlyContinue Log "Windows Update services restarted" } "3" { Log "Restarting DNS Client..." Restart-Service Dnscache -Force -EA SilentlyContinue ipconfig /flushdns | Out-Null Log "DNS Client restarted and cache flushed" } "4" { Log "Stopping telemetry services..." Stop-Service DiagTrack -Force -EA SilentlyContinue Set-Service DiagTrack -StartupType Disabled -EA SilentlyContinue Log "Telemetry service stopped and disabled" } "5" { Log "Enabling Remote Desktop..." Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0 Enable-NetFirewallRule -DisplayGroup "Remote Desktop" -EA SilentlyContinue Set-Service TermService -StartupType Automatic -EA SilentlyContinue Start-Service TermService -EA SilentlyContinue Log "Remote Desktop enabled" } "6" { Log "Disabling Remote Desktop..." Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 1 Disable-NetFirewallRule -DisplayGroup "Remote Desktop" -EA SilentlyContinue Log "Remote Desktop disabled" } } } function Select-Service { Write-Host "" Write-Host "Available services:" -ForegroundColor Yellow for ($i = 0; $i -lt $services.Count; $i++) { $s = Get-Service -Name $services[$i].Name -EA SilentlyContinue $status = if ($s) { "[$($s.Status)]" } else { "[Not Found]" } Write-Host (" {0,2}. {1,-30} {2}" -f ($i+1), $services[$i].Display, $status) } Write-Host "" $num = Read-Host "Enter service number (or 0 to cancel)" if ($num -match '^\d+$' -and [int]$num -gt 0 -and [int]$num -le $services.Count) { return $services[[int]$num - 1].Name } return $null } # Initial status display Show-ServiceStatus # Interactive menu do { Show-Menu $choice = Read-Host "Select option" switch ($choice) { "1" { Show-ServiceStatus } "2" { $svcName = Select-Service if ($svcName) { Log "Starting $svcName..." Start-Service $svcName -EA SilentlyContinue Start-Sleep -Seconds 2 $s = Get-Service $svcName Log " Status: $($s.Status)" } } "3" { $svcName = Select-Service if ($svcName) { Log "Stopping $svcName..." Stop-Service $svcName -Force -EA SilentlyContinue Start-Sleep -Seconds 2 $s = Get-Service $svcName Log " Status: $($s.Status)" } } "4" { $svcName = Select-Service if ($svcName) { Log "Restarting $svcName..." Restart-Service $svcName -Force -EA SilentlyContinue Start-Sleep -Seconds 2 $s = Get-Service $svcName Log " Status: $($s.Status)" } } "5" { $svcName = Select-Service if ($svcName) { Log "Setting $svcName to Automatic..." Set-Service $svcName -StartupType Automatic -EA SilentlyContinue Log " Done" } } "6" { $svcName = Select-Service if ($svcName) { Log "Setting $svcName to Manual..." Set-Service $svcName -StartupType Manual -EA SilentlyContinue Log " Done" } } "7" { $svcName = Select-Service if ($svcName) { Log "Setting $svcName to Disabled..." Set-Service $svcName -StartupType Disabled -EA SilentlyContinue Log " Done" } } "8" { Show-QuickActions } } } while ($choice -ne "9") Log "" Log "========================================" Log "SESSION COMPLETE" Log "========================================" explorer.exe "/select,$logFile"