forked from GoateePFE/GPOMigration
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Call-GPOImport.ps1
135 lines (105 loc) · 9.64 KB
/
Call-GPOImport.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<##############################################################################
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 your MigrationTableCSV files, a copy
of this script, a copy of the GPOMigration.psm1 module file, and the GPO
backup folder from the export.
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.
NOTE: Before running you will need at least one MigrationTableCSV file using
this format:
Source,Destination,Type
"OldDomain.FQDN","NewDomain.FQDN","Domain"
"OldDomainNETBIOSName","NewDomainNETBIOSName","Domain"
"\\foo\server","\\baz\server","UNC"
Modify the following to your needs:
working folder path
GPO backup folder path
destination domains and servers
MigTableCSV files
##############################################################################>
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
$BackupPath = "$PWD\GPO Backup wingtiptoys.local 2014-08-06-09-11-37"
###############################################################################
# IMPORT
###############################################################################
$DestDomain = 'cohovineyard.com'
$DestServer = 'cvdcr2.cohovineyard.com'
$MigTableCSVPath = '.\MigTable_sample.csv'
Start-GPOImport `
-DestDomain $DestDomain `
-DestServer $DestServer `
-Path $Path `
-BackupPath $BackupPath `
-MigTableCSVPath $MigTableCSVPath `
-CopyACL
<#
###############################################################################
# DEV to QA
###############################################################################
$DestDomain = 'qa.wingtiptoys.com'
$DestServer = 'dc1.qa.wingtiptoys.com'
$MigTableCSVPath = '.\MigTable_DEV_to_QA.csv'
Start-GPOImport `
-DestDomain $DestDomain `
-DestServer $DestServer `
-Path $Path `
-BackupPath $BackupPath `
-MigTableCSVPath $MigTableCSVPath `
-CopyACL
###############################################################################
# DEV to PROD
###############################################################################
$DestDomain = 'prod.wingtiptoys.com'
$DestServer = 'dc1.prod.wingtiptoys.com'
$MigTableCSVPath = '.\MigTable_DEV_to_PROD.csv'
Start-GPOImport `
-DestDomain $DestDomain `
-DestServer $DestServer `
-Path $Path `
-BackupPath $BackupPath `
-MigTableCSVPath $MigTableCSVPath `
-CopyACL
###############################################################################
# END
###############################################################################
#>