Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Powershell script cooperates with task scheduler to realize automatic backup of group policy

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Also today, I encountered a problem requiring automatic backup of Group Policy (GPO) every five minutes. I racked my brains to find that the graphical interface could not solve this problem, so I began to wonder if Powershell could solve it, and finally I really solved it. Here's what I did.

First put the script:

Explain:

Import the grouppolicy module and use its method later

Define a time variable in which daily backups are recorded in a folder named after the date

Specify a new folder in a directory under disk C.

Then specify to back up all group policies to this folder

Save and run:

Successful backup, happy

And then there's the big story:

Open the Task Scheduler and click create Task (note that you create a task instead of a basic task)

Naturally, the name goes without saying.

Create a new trigger according to your own needs

Click the action again (here you need to pay attention to "ω" =)

The program should choose Powershell instead of script, because the default execution of ps1 script is to edit rather than run

Parameter. That's the script path.

Start with the folder where the script is written

Then the rest depends on the configuration you need.

Complete

The automatic backup will begin in five minutes, and then we'll try to restore it.

Right-click in Group Policy Management to select Group Policy object to manage backup

Then select your backup directory

This is the strategy for all backups. Watch the timestamp for on-demand recovery.

Xiaobai opens a blog. Comments are welcome.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report