Skip to content

Commit c5f2e34

Browse files
committed
Feature: Update local GPO via ps script
1 parent c524380 commit c5f2e34

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Check for administrative privileges and rerun as administrator if needed
2+
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
3+
{
4+
Write-Host "Script is not running with administrative privileges. Restarting with elevated rights..."
5+
Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -NoExit -File `"$PSCommandPath`"" -Verb RunAs
6+
exit
7+
}
8+
9+
# Update local group policy files for NETworkManager
10+
[string]$GpoFolderPath = Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath "GPO"
11+
[string]$AdmxFilePath = Join-Path -Path $GpoFolderPath -ChildPath "NETworkManager.admx"
12+
[string]$AdmlFolderPath = Join-Path -Path $GpoFolderPath -ChildPath "en-US"
13+
[string]$AdmlFilePath = Join-Path -Path $AdmlFolderPath -ChildPath "NETworkManager.adml"
14+
15+
# Copy ADMX file to local policy store
16+
$LocalAdmxPath = Join-Path -Path "$env:SystemRoot\PolicyDefinitions" -ChildPath "NETworkManager.admx"
17+
Copy-Item -Path $AdmxFilePath -Destination $LocalAdmxPath -Force
18+
19+
# Copy ADML file to local policy store
20+
$LocalAdmlPath = Join-Path -Path "$env:SystemRoot\PolicyDefinitions\en-US" -ChildPath "NETworkManager.adml"
21+
Copy-Item -Path $AdmlFilePath -Destination $LocalAdmlPath -Force
22+
23+
# End of script
24+
Write-Host "Local Group Policy files for NETworkManager have been updated."

0 commit comments

Comments
 (0)