Update windows_time_sync
This commit is contained in:
parent
0fa2855e23
commit
9b469c36cf
@ -1,6 +1,5 @@
|
||||
# Invoke-Expression (Invoke-WebRequest -Uri "https://git.technozone.com.au/vijay/Scripts/raw/branch/main/windows_time_sync" -UseBasicP | Select-Object -ExpandProperty Content)
|
||||
|
||||
|
||||
function Show-Menu {
|
||||
Clear-Host
|
||||
Write-Host "=============================="
|
||||
@ -9,7 +8,8 @@ function Show-Menu {
|
||||
Write-Host "1. Check NTP Server Configuration"
|
||||
Write-Host "2. Sync Time with Domain Controller"
|
||||
Write-Host "3. Set to Nearest NTP Server"
|
||||
Write-Host "4. Exit"
|
||||
Write-Host "4. Check Windows Time Service"
|
||||
Write-Host "5. Exit"
|
||||
}
|
||||
|
||||
function Check-NTPConfiguration {
|
||||
@ -38,15 +38,30 @@ function Set-ToNearestNTP {
|
||||
Pause
|
||||
}
|
||||
|
||||
function Check-WindowsTimeService {
|
||||
$service = Get-Service w32time
|
||||
if ($service.Status -ne 'Running') {
|
||||
Write-Host "Windows Time service is not running. Starting the service..."
|
||||
Start-Service w32time
|
||||
Write-Host "Windows Time service started."
|
||||
} else {
|
||||
Write-Host "Windows Time service is already running."
|
||||
}
|
||||
|
||||
# Ensure it's syncing to the nearest time server
|
||||
Set-ToNearestNTP
|
||||
}
|
||||
|
||||
do {
|
||||
Show-Menu
|
||||
$choice = Read-Host "Please enter your choice (1-4)"
|
||||
$choice = Read-Host "Please enter your choice (1-5)"
|
||||
|
||||
switch ($choice) {
|
||||
1 { Check-NTPConfiguration }
|
||||
2 { Sync-TimeWithDC }
|
||||
3 { Set-ToNearestNTP }
|
||||
4 { Write-Host "Exiting..."; break }
|
||||
4 { Check-WindowsTimeService }
|
||||
5 { Write-Host "Exiting..."; break }
|
||||
default { Write-Host "Invalid choice. Please select again." }
|
||||
}
|
||||
} while ($true)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user