-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewDeviceConfig.ps1
More file actions
109 lines (84 loc) · 4.47 KB
/
NewDeviceConfig.ps1
File metadata and controls
109 lines (84 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
set-executionpolicy -executionpolicy remotesigned -force
<#
(New-Object System.Net.WebClient).DownloadFile("https://zinfandel.centrastage.net/csm/profile/downloadAgent/23b43566-f401-43c3-a09a-2135bfb66bf3", "$env:TEMP/AgentInstall.exe");start-process "$env:TEMP/AgentInstall.exe"
#>
# Ensure the script runs with administrative privileges
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Error "This script must be run as Administrator!"
exit
}
Add-AppxPackage https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
winget source update
if ((Get-CimInstance -ClassName Win32_ComputerSystem).Manufacturer -match 'Dell') { winget install dell.commandupdate --accept-source-agreements --accept-package-agreements --silent}
# 1. Configure power settings to "do nothing" when the display is closed
Write-Output "Configuring power settings..."
& powercfg /SETACVALUEINDEX SCHEME_CURRENT SUB_BUTTONS LIDACTION 0
& powercfg /SETDCVALUEINDEX SCHEME_CURRENT SUB_BUTTONS LIDACTION 0
& powercfg -SetActive SCHEME_CURRENT
Write-Output "Power settings configured to do nothing when the display is closed."
# 2. Disable USB power saving settings to prevent USB ports from being disabled
Write-Output "Disabling USB power-saving settings..."
Get-WmiObject -Namespace "root\cimv2\power" -Class Win32_PowerSettingDataIndex | Where-Object {
$_.InstanceID -like "*GUID*"
} | ForEach-Object {
& powercfg /SETACVALUEINDEX SCHEME_CURRENT $_.InstanceID 0
& powercfg /SETDCVALUEINDEX SCHEME_CURRENT $_.InstanceID 0
}
& powercfg -SetActive SCHEME_CURRENT
Write-Output "USB power-saving settings disabled."
# 3. Configure "Performance" power mode when plugged in
Write-Output "Configuring performance mode when plugged in..."
& powercfg /SETACVALUEINDEX SCHEME_CURRENT SUB_PROCESSOR PROCTHROTTLEMAX 100
& powercfg -SetActive SCHEME_CURRENT
Write-Output "Performance mode configured."
# 4. Disable Bing search in Windows Search for all users
Write-Output "Disabling Bing Search integration in Windows Search..."
$regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows"
$regSubKey = "Explorer"
$regValueName = "DisableSearchBoxSuggestions"
if (-not (Test-Path "$regPath\$regSubKey")) {
New-Item -Path "$regPath" -Name $regSubKey -Force | Out-Null
}
Set-ItemProperty -Path "$regPath\$regSubKey" -Name $regValueName -Value 1 -Type DWord
Write-Output "Bing search integration disabled in Windows Search for all users."
# 5. Set system time zone to MST (Mountain Standard Time)
Write-Output "Configuring system time zone to MST..."
tzutil /s "Mountain Standard Time"
Write-Output "System time zone set to MST."
winget install microsoft.office --accept-source-agreements --accept-package-agreements
# 6. disable new outlook
function Set-RegistryValue {
param(
[string]$Path,
[string]$Name,
[string]$Type = "DWORD",
[string]$Value
)
New-Item -Path $Path -Force | Out-Null
New-ItemProperty -Path $Path -Name $Name -PropertyType $Type -Value $Value -Force | Out-Null
}
# Step 7: Block the New Outlook Toggle
Set-RegistryValue -Path "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\General" -Name "HideNewOutlookToggle" -Value 0
# Step 8: Restart explorer.exe to apply all changes
get-process explorer | foreach-object {stop-process $_}
Write-Output "All configurations applied successfully!"
# Step 9: Check if Dell Command Update is installed and run
# Define the path to the Dell Command Update executable
$dcuPath = "C:\Program Files (x86)\Dell\CommandUpdate\dcu-cli.exe"
if (Test-Path $dcuPath) {
Write-Output "Dell Command Update found. Running updates..."
# Run Dell Command Update to apply updates and allow reboot if necessary
Start-Process -FilePath $dcuPath -ArgumentList "/applyUpdates -autoSuspendBitLocker=enable -reboot=enable" -Wait
Write-Output "Updates applied. System may reboot if necessary."
} else {
Write-Output "Dell Command Update not found. Please install it first."
}# Define the path to the Dell Command Update executable
$dcuPath = "C:\Program Files (x86)\Dell\CommandUpdate\dcu-cli.exe"
# 10: Remove local temp account if it exists
if (Get-LocalUser -Name "temp" -ErrorAction SilentlyContinue) {
# Delete the user
Remove-LocalUser -Name "temp"
Write-Output "User 'temp' has been deleted."
} else {
Write-Output "User 'temp' does not exist."
}