-
Notifications
You must be signed in to change notification settings - Fork 12
/
Call-GPOExport.ps1
83 lines (66 loc) · 6.81 KB
/
Call-GPOExport.ps1
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
<##############################################################################
Ashley McGlone
Microsoft Premier Field Engineer
April 2014
http://aka.ms/GoateePFE
Module for Group Policy migration.
Requirements / Setup
-Windows 7/2008 R2 (or above) RSAT with AD PowerShell cmdlets installed.
-GPMC with GroupPolicy module installed.
-Import-Module GroupPolicy
-Import-Module ActiveDirectory
These are the default permissions required unless specific permission
delegations have been created:
Domain Admins to create policies and link them.
Enterprise Admins if linking policies to sites.
LEGAL DISCLAIMER
This Sample Code is provided for the purpose of illustration only and is not
intended to be used in a production environment. THIS SAMPLE CODE AND ANY
RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. We grant You a
nonexclusive, royalty-free right to use and modify the Sample Code and to
reproduce and distribute the object code form of the Sample Code, provided
that You agree: (i) to not use Our name, logo, or trademarks to market Your
software product in which the Sample Code is embedded; (ii) to include a valid
copyright notice on Your software product in which the Sample Code is embedded;
and (iii) to indemnify, hold harmless, and defend Us and Our suppliers from and
against any claims or lawsuits, including attorneys’ fees, that arise or result
from the use or distribution of the Sample Code.
This posting is provided "AS IS" with no warranties, and confers no rights. Use
of included script samples are subject to the terms specified
at http://www.microsoft.com/info/cpyright.htm.
##########################################################################sdg#>
<##############################################################################
Setup
Your working folder path should include a copy of this script, and a copy of
the GPOMigration.psm1 module file.
This example assumes that a backup will run under a source credential and server,
and the import will run under a destination credential and server. Between these
two operations you will need to copy your working folder from one environment to
the other.
Modify the following to your needs:
working folder path
source domain and server
destination domain and server
the GPO DisplayName Where criteria to target your policies for migration
##############################################################################>
Set-Location C:\Users\Administrator\Documents\GPOMigrationWorkingFolder
Import-Module GroupPolicy
Import-Module ActiveDirectory
Import-Module ".\GPOMigration" -Force
# This path must be absolute, not relative
$Path = $PWD # Current folder specified in Set-Location above
$SrceDomain = 'wingtiptoys.local'
$SrceServer = 'dca.wingtiptoys.local'
$DisplayName = Get-GPO -All -Domain $SrceDomain -Server $SrceServer |
Where-Object {$_.DisplayName -like '*test*'} |
Select-Object -ExpandProperty DisplayName
Start-GPOExport `
-SrceDomain $SrceDomain `
-SrceServer $SrceServer `
-DisplayName $DisplayName `
-Path $Path
###############################################################################
# END
###############################################################################