added provisioning scripts
This commit is contained in:
parent
66110cf376
commit
a7fcad8708
27
Provisioning Scripts/Generic-Setup.ps1
Normal file
27
Provisioning Scripts/Generic-Setup.ps1
Normal file
@ -0,0 +1,27 @@
|
||||
# Set the time zone to Australia/Perth
|
||||
Set-TimeZone -Id "W. Australia Standard Time"
|
||||
|
||||
# Set the system locale to English (Australia)
|
||||
Set-WinSystemLocale -SystemLocale en-AU
|
||||
|
||||
# Set the user locale to English (Australia)
|
||||
Set-WinUserLanguageList -LanguageList en-AU -Force
|
||||
|
||||
# Set the short date, long date, short time, and long time formats to Australian standards
|
||||
Set-Culture -CultureInfo en-AU
|
||||
|
||||
# Set the region settings to Australia
|
||||
Set-WinHomeLocation -GeoId 12
|
||||
|
||||
# Synchronize the system clock with an NTP server (optional)
|
||||
w32tm /resync
|
||||
|
||||
Write-Host "Date, time, locale, and region settings have been set to Australia/Perth."
|
||||
|
||||
# Short Version.
|
||||
Set-TimeZone -Id "W. Australia Standard Time"
|
||||
Set-WinSystemLocale -SystemLocale en-AU
|
||||
Set-WinUserLanguageList -LanguageList en-AU -Force
|
||||
Set-Culture -CultureInfo en-AU
|
||||
Set-WinHomeLocation -GeoId 12
|
||||
w32tm /resync
|
||||
101
Provisioning Scripts/Generic-SetupV2.ps1
Normal file
101
Provisioning Scripts/Generic-SetupV2.ps1
Normal file
@ -0,0 +1,101 @@
|
||||
# Ensure the log directory exists
|
||||
$logDirectory = "C:\Logs"
|
||||
if (-not (Test-Path -Path $logDirectory)) {
|
||||
try {
|
||||
New-Item -ItemType Directory -Path $logDirectory -Force | Out-Null
|
||||
Write-Host "INFO: Created log directory at $logDirectory"
|
||||
} catch {
|
||||
Write-Host "ERROR: Failed to create log directory at $logDirectory - $_"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Define the log file path with a timestamp
|
||||
$logFile = Join-Path -Path $logDirectory -ChildPath "GeneralSetup_$(Get-Date -Format 'ddMMyyyy_HHmm').log"
|
||||
|
||||
# Function to write logs with different levels
|
||||
function Write-Log {
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Message,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[ValidateSet("INFO", "WARNING", "ERROR")]
|
||||
[string]$Level = "INFO"
|
||||
)
|
||||
|
||||
# Prefix the message based on the level
|
||||
switch ($Level) {
|
||||
"ERROR" { $logMessage = "ERROR: $Message" }
|
||||
"WARNING" { $logMessage = "WARNING: $Message" }
|
||||
default { $logMessage = "INFO: $Message" }
|
||||
}
|
||||
|
||||
# Add timestamp
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
$logEntry = "[$timestamp] $logMessage"
|
||||
|
||||
# Write to log file
|
||||
Add-Content -Path $logFile -Value $logEntry
|
||||
|
||||
# Also output to console for visibility
|
||||
Write-Output $logEntry
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Log -Message "Starting script to configure timezone, locale, and region settings." -Level "INFO"
|
||||
|
||||
# Set the time zone to Australia/Perth
|
||||
try {
|
||||
Set-TimeZone -Id "W. Australia Standard Time" -ErrorAction Stop
|
||||
Write-Log -Message "Successfully set timezone to 'W. Australia Standard Time'." -Level "INFO"
|
||||
} catch {
|
||||
Write-Log -Message "Failed to set timezone: $_" -Level "ERROR"
|
||||
}
|
||||
|
||||
# Set the system locale to English (Australia)
|
||||
try {
|
||||
Set-WinSystemLocale -SystemLocale en-AU -ErrorAction Stop
|
||||
Write-Log -Message "Successfully set system locale to 'en-AU'." -Level "INFO"
|
||||
} catch {
|
||||
Write-Log -Message "Failed to set system locale: $_" -Level "ERROR"
|
||||
}
|
||||
|
||||
# Set the user locale to English (Australia)
|
||||
try {
|
||||
Set-WinUserLanguageList -LanguageList en-AU -Force -ErrorAction Stop
|
||||
Write-Log -Message "Successfully set user language list to 'en-AU'." -Level "INFO"
|
||||
} catch {
|
||||
Write-Log -Message "Failed to set user language list: $_" -Level "ERROR"
|
||||
}
|
||||
|
||||
# Set the culture to English (Australia)
|
||||
try {
|
||||
Set-Culture -CultureInfo en-AU -ErrorAction Stop
|
||||
Write-Log -Message "Successfully set culture to 'en-AU'." -Level "INFO"
|
||||
} catch {
|
||||
Write-Log -Message "Failed to set culture: $_" -Level "ERROR"
|
||||
}
|
||||
|
||||
# Set the region settings to Australia (GeoId 12)
|
||||
try {
|
||||
Set-WinHomeLocation -GeoId 12 -ErrorAction Stop
|
||||
Write-Log -Message "Successfully set region settings to Australia (GeoId: 12)." -Level "INFO"
|
||||
} catch {
|
||||
Write-Log -Message "Failed to set region settings: $_" -Level "ERROR"
|
||||
}
|
||||
|
||||
# Synchronize the system clock with an NTP server (optional)
|
||||
try {
|
||||
w32tm /resync | Out-Null
|
||||
Write-Log -Message "Successfully synchronized system clock with NTP server." -Level "INFO"
|
||||
} catch {
|
||||
Write-Log -Message "Failed to synchronize system clock: $_" -Level "WARNING"
|
||||
}
|
||||
|
||||
Write-Log -Message "Date, time, locale, and region settings have been set to Australia/Perth." -Level "INFO"
|
||||
} catch {
|
||||
Write-Log -Message "An unexpected error occurred in the script: $_" -Level "ERROR"
|
||||
} finally {
|
||||
Write-Log -Message "Script execution completed." -Level "INFO"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user