Skip to content

Commit fb92993

Browse files
Publish supplemental scripts
1 parent ac38407 commit fb92993

3 files changed

Lines changed: 183 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<#
2+
.SYNOPSIS
3+
Enables the location setting and turns on the "Set the timezone automatically" switch in Time & Language > Date & Time.
4+
5+
.NOTES
6+
Author: James Robinson | SkipToTheEndpoint | https://skiptotheendpoint.co.uk
7+
Version: v1
8+
Release Date: 2024-08-31
9+
10+
Intune Info:
11+
Script type - Platform Script
12+
Assign to - Devices
13+
Script Settings:
14+
Run this script using the logged on credentials - No
15+
Enforce script signature check - No
16+
Run script in 64-bit PowerShell Host - Yes
17+
#>
18+
19+
#### Logging Variables ####
20+
$Script:ScriptName = "OIB-AutoTimezone"
21+
$Script:LogFile = "$ScriptName.log"
22+
$Script:LogsFolder = "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs"
23+
24+
#### Script Variables ####
25+
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue
26+
$Host.UI.RawUI.WindowTitle = '$ScriptName'
27+
28+
$LocationValue = "Allow"
29+
$AutoTZValue = "3"
30+
$LFSVCValue = "1"
31+
$SensorValue = "1"
32+
33+
#### Functions ####
34+
function Start-Logging {
35+
Start-Transcript -Path $LogsFolder\$LogFile -Append
36+
Write-Host "Current script timestamp: $(Get-Date -f yyyy-MM-dd_HH-mm)"
37+
}
38+
39+
function Set-RegistryValue {
40+
param (
41+
[string]$Path,
42+
[string]$Name,
43+
[string]$Value
44+
)
45+
try {
46+
$currentValue = (Get-ItemProperty -Path $Path -Name $Name).$Name
47+
if ($currentValue -ne $Value) {
48+
Write-Host "Setting $Name to $Value at $Path"
49+
Set-ItemProperty -Path $Path -Name $Name -Value $Value
50+
}
51+
else {
52+
Write-Host "$Name is already set to $Value at $Path"
53+
}
54+
}
55+
catch {
56+
Write-Error "$($_.Exception.Message)"
57+
}
58+
}
59+
60+
#### Script ####
61+
Start-Logging
62+
63+
try {
64+
# Set the location value
65+
Set-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -Name "Value" -Value $LocationValue
66+
67+
# Enable Auto Timezone value and (re)start service
68+
Set-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate" -Name "Start" -Value $AutoTZValue
69+
Set-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" -Name "Status" -Value $LFSVCValue
70+
Write-Host "(Re)Starting geolocation service"
71+
$lfsvc = Get-Service -Name lfsvc
72+
if ($lfsvc.Status -ne "Running") {
73+
Start-Service -Name lfsvc
74+
}
75+
else {
76+
Restart-Service -Name lfsvc -Force
77+
}
78+
79+
# Set sensor value
80+
Set-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" -Name "SensorPermissionState" -Value $SensorValue
81+
Exit 0
82+
}
83+
catch {
84+
Write-Error "$($_.Exception.Message)"
85+
Exit 1
86+
}

WINDOWS/Scripts/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Scripts
2+
3+
This folder contains a few scripts that suppliment the OIB, but are not requirements for the OIB to function.
4+
5+
All scripts create logs that can be found in the `$ProgramData\Microsoft\IntuneManagementExtension\Logs` folder.
6+
7+
## Enable-AutoTimezone
8+
### Purpose
9+
I have tried to utilise available settings to make this work as part of the Timezone and Privacy policies, however it seems that the only way to get this to work is to run a script. This script will enable the "Set time zone automatically" switch in Settings > Time & Language > Date & Time.
10+
11+
### Usage
12+
**Script type** - Platform Script
13+
**Assign to** - Users
14+
**Script Settings:**
15+
- Run this script using the logged on credentials - No
16+
- Enforce script signature check - No
17+
- Run script in 64-bit PowerShell Host - Yes
18+
19+
## Trigger-PostOOBEUpdates
20+
### Purpose
21+
One big security concern with OOBE is that it doesn't ([currently](https://techcommunity.microsoft.com/blog/windows-itpro-blog/coming-soon-quality-updates-during-the-out-of-box-experience/4374291)) install updates. This means that most devices will be at least a month out of date when they are first used.
22+
This script automatically triggers the following to update once a device gets to the desktop:
23+
- Defender
24+
- Microsoft Store
25+
- Windows Update
26+
27+
The end result of this is that pretty shortly after, any pending updates will be installed, and the user notified a reboot is required, reducing the time between OOBE and the device being secure.
28+
29+
### Usage
30+
**Script type** - Platform Script
31+
**Assign to** - Users
32+
**Script Settings:**
33+
- Run this script using the logged on credentials - No
34+
- Enforce script signature check - No
35+
- Run script in 64-bit PowerShell Host - Yes
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<#
2+
.SYNOPSIS
3+
Script to trigger updates following an Autopilot deployment.
4+
5+
.NOTES
6+
Author: James Robinson | SkipToTheEndpoint | https://skiptotheendpoint.co.uk
7+
Version: v1
8+
Release Date: 2024-08-31
9+
10+
Intune Info:
11+
Script type - Platform Script
12+
Assign to - Users
13+
Script Settings:
14+
Run this script using the logged on credentials - No
15+
Enforce script signature check - No
16+
Run script in 64-bit PowerShell Host - Yes
17+
#>
18+
19+
#### Logging Variables ####
20+
$Script:ScriptName = "OIB-PostOOBEUpdates.log"
21+
$Script:LogFile = "$ScriptName.log"
22+
$Script:LogsFolder = "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs"
23+
24+
25+
#### Script Variables ####
26+
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue
27+
$Host.UI.RawUI.WindowTitle = '$ScriptName'
28+
29+
#### Functions ####
30+
function Start-Logging {
31+
Start-Transcript -Path $LogsFolder\$LogFile -Append
32+
Write-Host "Current script timestamp: $(Get-Date -f yyyy-MM-dd_HH-mm)"
33+
}
34+
35+
#### Script ####
36+
Start-Logging
37+
38+
try {
39+
# Update MDE
40+
Write-Host "Triggering MDE Update..."
41+
Update-MpSignature
42+
Start-Sleep 10
43+
44+
# Update Store Apps
45+
Write-Host "Triggering Store App Updates..."
46+
Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod
47+
Start-Sleep 10
48+
49+
# Start WU Check
50+
Write-Host "Triggering Windows Update Check..."
51+
Start-Process USOClient.exe -ArgumentList "StartInteractiveScan" -NoNewWindow -Wait
52+
Start-Sleep 10
53+
54+
# Stop Logging and Exit
55+
Write-Host "Script complete."
56+
Stop-Transcript
57+
Exit 0
58+
}
59+
catch {
60+
Write-Error "$($_.Exception.Message)"
61+
Exit 1
62+
}

0 commit comments

Comments
 (0)