Gerade als Entwickler hat man ab und an das Problem, dass man an einem Rechner temporär die Gruppenrichtlinien außer Kraft setzen muss, damit gewisse Tests oder Funktionen ausgeführt werden können. Damit hierzu keine neue Gruppenrichtlinie im Active Directory benötigt wird nutzt man ein kleines PowerShell Skript.
Voraussetzung ist natürlich, dass man auf dem Computer auch lokale Administratorrechte hat, ansonsten darf man die Änderungen in der Registry nicht machen. Zudem werden die Änderungen nach einem Neustart wieder durch die bestehende Gruppenrichtlinie (Policy) ersetzt.
Hier ein kleines Beispiel, wie man es angehen kann:
#-------------------------------------------------------------
#
# Make life/work a little bit easier with GPO-modifications
#
# requires local admin account/rights
#
#-------------------------------------------------------------
Write-Host "Disable some GPOs to make your life/work a little bit easier..." -ForegroundColor Yellow
Write-Host "You need local admin rights and the permission to do this!" -ForegroundColor DarkYellow
#region Confirm
$title = "Perform changes?"
$message = "Do you really change the setings in the registry and disable some GPOs?"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", `
"Change the keys."
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", `
"Leave everything as it is."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
switch ($result)
{
0 {$doit = $true}
1 {$doit = $false}
}
#endregion
if ($doit) {
# check if admin
#region AdminCheck
$admin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
#endregion
if ($admin) {
# gain access to internet content in office
#region OnlineContent
$registryPath = "HKCU:\Software\Policies\Microsoft\office\15.0\common\internet"
$Name = "useonlinecontent"
$value = "2"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
ELSE {
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
#endregion
# let me sign in with live-id
#region LiveID-SignIn
$registryPath = "HKCU:\Software\Policies\Microsoft\office\15.0\common\signin"
$Name = "signinoptions"
$value = "0"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
ELSE {
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
#endregion
# add sharepoint calendar or other accounts to Outlook
#region Add-PST-Files
$registryPath = "HKCU:\Software\Policies\Microsoft\office\15.0\outlook"
$Name = "disablepst"
$value = "0"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
ELSE {
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
#endregion
# enable sharepoint rss feeds in Outlook
#region RSS-Feeds
$registryPath = "HKCU:\Software\Policies\Microsoft\office\15.0\outlook\options\rss"
$Name = "disable"
$value = "0"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
ELSE {
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
#endregion
# do not ask to empty bin in Outlook
#region EmptyBin
$registryPath = "HKCU:\Software\Policies\Microsoft\office\15.0\outlook\preferences"
$Name = "emptytrash"
$value = "0"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
ELSE {
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
}
#endregion
Write-Host "Done making life/work a little bit easier..." -ForegroundColor Green
}
else
{
Write-Host "Sorry, you are not member of local admin group, cannot modify registry settings." -ForegroundColor White -BackgroundColor Red
}
}
Innerhalb der New-ItemProperty Befehle steht immer der zu ändernde Registry-Eintrag und der dazu gehörige Wert und Datentyp.
Eine kleine Auswahl an Einstellungen werde ich bei Gelegenheit noch ergänzen.