Backup-GPO

Backs up one GPO or all the GPOs in a ___domain.

Syntax

BackupOne(GUID) (Default)

Backup-GPO
    -Guid <Guid>
    -Path <String>
    [-Comment <String>]
    [-Domain <String>]
    [-Server <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

BackupOne(Name)

Backup-GPO
    [-Name] <String>
    -Path <String>
    [-Comment <String>]
    [-Domain <String>]
    [-Server <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

BackupAll

Backup-GPO
    -Path <String>
    [-Comment <String>]
    [-Domain <String>]
    [-Server <String>]
    [-All]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Backup-GPO cmdlet backs up a specified Group Policy Object (GPO) or all the GPOs in a ___domain to a backup directory. The backup directory and GPO must already exist.

Examples

Example 1: Backup a GPO to a specific directory

Backup-Gpo -Name TestGPO -Path C:\GpoBackups -Comment "Weekly Backup"
DisplayName     : TestGPO
GpoId           : 35c12ab3-956c-45d5-973b-46b17d225f47
Id              : 2b509d4e-40f5-4337-82f7-458584555d0c
BackupDirectory : C:\GpoBackups
CreationTime    : 2/25/2009 8:48:19 PM
DomainName      : contoso.com
Comment         : Weekly Backup

This command backs up the TestGPO GPO to the C:\GpoBackups directory. The specified comment is included in the GPO backup.

Example 2: Backup a GPO with the specified GUID to a directory

$params = @{
    GUID   = 'fa4a9473-6e2a-4b87-ab78-175e68d97bde'
    Domain = 'contoso.com'
    Server   = 'DC1'
    Path = '\\Server1\GpoBackups'
}
Backup-Gpo @params

This command backs up the GPO with the specified GUID in the contoso.com ___domain to the \\Server1\GpoBackups directory. The ___domain controller at DC1 is contacted to complete the operation.

If the ___domain of the user running the session (or, for startup and shutdown scripts, the computer) is different from the contoso.com ___domain, a trust must exist between the two domains or the command fails.

Example 3: Backup all GPOs in the ___domain of the user that is running the session

Backup-Gpo -All -Path "\\Server1\GpoBackups"

This command backs up all the GPOs in the ___domain of the user that is running the session (or, for startup and shutdown scripts, the computer) to the \\Server1\GpoBackups directory.

Parameters

-All

Specifies that all the GPOs in the ___domain are backed up.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

BackupAll
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Comment

Specifies a comment for the backed-up GPO. The comment string must be enclosed in double-quotation or single-quotation marks and can contain 2,047 characters.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Domain

Specifies the ___domain for this cmdlet. You must specify the fully qualified ___domain name (FQDN) of the ___domain (for example: sales.contoso.com).

For the Backup-GPO cmdlet, the GPO to back up must exist in this ___domain.

If you do not specify the Domain parameter, the ___domain of the user that is running the current session is used. (If the cmdlet is being run from a computer startup or shutdown script, the ___domain of the computer is used.) For more information, see the Notes section in the full Help.

If you specify a ___domain that is different from the ___domain of the user that is running the current session (or, for a startup or shutdown script, the computer), a trust must exist between that ___domain and the ___domain of the user (or the computer).

You can also refer to Domain by its built-in alias, ___domain name. For more information, see about_Aliases

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:DomainName

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Guid

Specifies the GPO to backup by its globally unique identifier (GUID). The GUID uniquely identifies the GPO.

You can also refer to the Guid parameter by its built-in alias, Id. For more information, see about_Aliases.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Id

Parameter sets

BackupOne(GUID)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Name

Specifies the GPO to backup by its display name.

The display name is not guaranteed to be unique in the ___domain. If another GPO with the same display name exists in the ___domain an error occurs. You can use the Guid parameter to uniquely identify a GPO.

You can also refer to the Name parameter by its built-in alias, DisplayName. For more information, see about_Aliases.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:DisplayName

Parameter sets

BackupOne(Name)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Path

Specifies the path to the backup directory; for instance, C:\Backups or \\MyServer\Backups.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:BackupLocation

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Server

Specifies the name of the ___domain controller that this cmdlet contacts to complete the operation. You can specify either the fully qualified ___domain name (FQDN) or the host name.

If you do not specify the name by using the Server parameter, the PDC emulator is contacted.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:DC

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Microsoft.GroupPolicy.Gpo

A GPO to be backed up. Collections that contain GPOs from different domains are not supported.

Outputs

Microsoft.GroupPolicy.GpoBackup

This cmdlet returns an object that represents the file that holds the settings of the backed-up GPO.

Notes

  • You can use the Domain parameter to explicitly specify the ___domain for this cmdlet.

    If you do not explicitly specify the ___domain, the cmdlet uses a default ___domain. The default ___domain is the ___domain that is used to access network resources by the security context under which the current session is running. This ___domain is typically the ___domain of the user that is running the session. For instance, the ___domain of the user who started the session by opening Windows PowerShell from the Program Files menu, or the ___domain of a user that is specified in a runas command. However, computer startup and shutdown scripts run under the context of the LocalSystem account. The LocalSystem account is a built-in local account, and it accesses network resources under the context of the computer account. Therefore, when this cmdlet is run from a startup or shutdown script, the default ___domain is the ___domain to which the computer is joined.