- <#
- .SYNOPSIS
- This script defines a function, Disable-Gui which
- disables the GUI on Windows Server 2012 Server Core
- .DESCRIPTION
- The Disable-GUI function enables the GUI in Server 2012
- Server Core by Removing two windows features. The
- script add a Shell setting to ensure that when
- Server 2012 restarts, it starts with PowerShell.
- .NOTES
- File Name : Disable-GUI.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 3.0 and Windows Server 2012.
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Psh> Disable-GUI -Verbose
- Removing Windows Feature: Server-GUI-Shell, Server-Gui-Mgmt-Infra
- Setting Shell Registry setting to PowerShell
- Restarting the computer - please be patient
- < after reboot, full GUI is added >
- #>
- Function Disable-GUI {
- # No parameters - but maybe later
- # Turn on CmdletBinding to enable -Verbose
- [Cmdletbinding()]
- Param()
- # Remove features from main Server core and downgrade GUI to Server Core
- Write-Verbose "Removing Windows Feature: Server-GUI-Shell, Server-Gui-Mgmt-Infra"
- Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
- # Add in PowerShell as the shell
- Write-Verbose "Setting Shell Registry setting to PowerShell"
- $RegPath = "Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
- Set-ItemProperty -Path $RegPath -Name Shell -Value 'PowerShell.exe -noExit -Command "$psversiontable"' -Force
- # Now restart the system
- Write-Verbose "Restarting the computer - please be patient"
- Restart-Computer
- }
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Tuesday, 18 September 2012
Disable-Gui.ps1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment