Skip to content

Commit 0c7174b

Browse files
committed
initialie-machine stuff
1 parent 37790c7 commit 0c7174b

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

Initialize-Machine.ps1

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@ Invoke a single command from this script; default is to run all
77
88
.PARAMETER ListCommands
99
Show a list of all available commands
10-
11-
.PARAMETER DisableCortana
12-
Disable Cortana advanced search support which uses excessive CPU.
13-
14-
.PARAMETER DisableOneDrive
15-
Remove OneDrive support; default is to keep OneDrive.
1610
#>
1711

1812
# CmdletBinding adds -Verbose functionality, SupportsShouldProcess adds -WhatIf
1913
[CmdletBinding(SupportsShouldProcess=$true)]
2014

2115
param (
2216
[parameter(Position=0)] $command,
23-
[switch] $DisableOneDrive,
24-
[switch] $DisableCortana,
2517
[switch] $ListCommands
2618
)
2719

@@ -610,8 +602,8 @@ Begin
610602
if (Test-Path $0) { Set-ItemProperty $0 -Name 'TaskbarDa' -Type DWord -Value 0 }
611603
}
612604

613-
# DisableCortana
614-
Write-Verbose "Disabling Cortana..."
605+
# Limit Cortana
606+
Write-Verbose "Limiting Cortana..."
615607
$0 = 'HKCU:\SOFTWARE\Microsoft\Personalization\Settings'
616608
If (!(Test-Path $0)) { New-Item -Path $0 -Force | Out-Null }
617609
Set-ItemProperty $0 -Name 'AcceptedPrivacyPolicy' -Type DWord -Value 0
@@ -622,25 +614,31 @@ Begin
622614
$0 = 'HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore'
623615
if (!(Test-Path $0)) { New-Item -Path $0 -Force | Out-Null }
624616
Set-ItemProperty $0 -Name 'HarvestContacts' -Type DWord -Value 0
617+
618+
# enable Hibernate option
619+
Write-Verbose 'enabling hibernate option'
620+
powercfg /h on
621+
}
622+
623+
624+
function DisableCortana
625+
{
626+
[System.ComponentModel.Description('Disable Cortana search preserving excessive CPU')]
627+
[CmdletBinding(HelpURI='cmd')] param()
628+
629+
Write-Verbose "Disabling Cortana..."
625630
$0 = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
626631
if (!(Test-Path $0)) { New-Item -Path $0 -Force | Out-Null }
627632
Set-ItemProperty $0 -Name 'AllowCortana' -Type DWord -Value 0
628633

629634
# Block Cortana SearchUI (uses excessive CPU)
630-
if ($DisableCortana)
635+
$0 = 'C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy'
636+
if (Test-Path "$0\SearchUI.exe")
631637
{
632-
$0 = 'C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy'
633-
if (Test-Path "$0\SearchUI.exe")
634-
{
635-
Stop-Process -Name 'SearchUI';
636-
Set-ItemOwner "$0\SearchUI.exe"
637-
Rename-Item "$0\SearchUI.exe" "$0\SearchUI.exe_BLOCK"
638-
}
638+
Stop-Process -Name 'SearchUI';
639+
Set-ItemOwner "$0\SearchUI.exe"
640+
Rename-Item "$0\SearchUI.exe" "$0\SearchUI.exe_BLOCK"
639641
}
640-
641-
# enable Hibernate option
642-
Write-Verbose 'enabling hibernate option'
643-
powercfg /h on
644642
}
645643

646644

@@ -733,10 +731,6 @@ Process
733731
SecurePagefile
734732
ScheduleTempCleanup
735733

736-
if ($DisableOneDrive) {
737-
DisableOneDrive
738-
}
739-
740734
# requires powershell profile scripts
741735
DisableZipFolders
742736

readme.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ until the OS provides a stable heartbeat.
299299
Using the scripts below, a new machine can be configured and apps installed in under
300300
30 minutes.
301301

302+
Run `Set-ExecutionPolicy RemoteSigned` prior to running if this is the first use of PowerShell.
303+
302304
The recommended sequence to run:
303305

304306
1. Initialize-Machine.ps1
@@ -314,14 +316,10 @@ This is a top-level script meant to be downloaded independently from this repo a
314316
initialize new machines. This script will download this repo to the current user's Document folder,
315317
setting it up as the default PowerShell profile. Best to download it to and run from the root of C.
316318

317-
`Initialize-Machine.ps1 [-Command c] [-ListCommands] [-RemoveOneDrive] [-RemoveCortana]`
319+
`Initialize-Machine.ps1 [-Command c] [-ListCommands]
318320

319321
* _command_ - optional argument to run a single command, default is to run all commands
320322
* -ListCommands - display all available commands supported by this script
321-
* -RemoveOneDrive - disables OneDrive; useful for test machines that don't need personal profiles
322-
* -RemoveCortana - disable Cortana advanced search UI which often consumes high CPU
323-
324-
Run `Set-ExecutionPolicy RemoteSigned` prior to running if this is the first use of PowerShell.
325323

326324
The Initialize-Machine script will download this repo into the MyDocuments folder, but
327325
if you have OneDrive enabled then the MyDocuments folder may differ from $home\Documents.
@@ -330,7 +328,12 @@ So before initializing, you can create a junction point to MyDocuments using thi
330328
1. `cd $home\Documents`
331329
1. `cmd /c "mklink /j WindowsPowerShell $([Environment]::GetFolderPath('MyDocuments'))\WindowsPowerShell"`
332330

333-
Since this updates the PowerShell console colors, you can close and reopen the console to
331+
Note there are two Initialie-Machine commands that are not run by default: DisableCortana and
332+
DisableOneDrive. To disable either of these, use the -Command argument, e.g.
333+
334+
`.\Initialize-Machine.ps1 -Command DisableCortana`
335+
336+
And since this updates the PowerShell console colors, you can close and reopen the console to
334337
appreciate these fantastic new colors.
335338

336339
#### [`Install-HyperV.ps1`](Install-HyperV.ps1)

0 commit comments

Comments
 (0)