【发布时间】:2014-03-04 21:52:32
【问题描述】:
我的域控制器正在运行 Windows Server 2008。
我已经能够将以下批处理命令与任务计划程序结合使用来编写 AD 快照创建脚本。
@echo off
ntdsutil snapshot "activate instance ntds" create quit quit
exit
现在我想使用批处理文件删除超过 30 天的 AD 快照。 ntdsutil 中有一个删除命令,但我无法将删除操作放入 for 循环中。有没有办法访问“删除”引用的索引变量?
我想:
- 打开 ntdsutil 并进入快照上下文
- 在 %s 大于 60 的循环中运行 delete %s
- 退出循环和 ntdsutil
这是 ntds 快照命令行屏幕的截图:
ntdsutil: snapshot
snapshot: ?
? - Show this help information
Activate Instance %s - Set "NTDS" or a specific AD LDS instance
as the active instance.
Create - Create a snapshot
Delete %s - Delete snapshot with index or guid %s. Specify
* to delete all snapshots
Help - Show this help information
List All - List snapshots
List Mounted - List mounted snapshots
Mount %s - Mount snapshot with index or guid %s
Quit - Return to the prior menu
Unmount %s - Unmount snapshot with index or guid %s. Specify
* to unmount all mounted snapshots
snapshot: list all
1: 2014/02/06:15:58 {052e85ae-7379-4164-8b7c-1be14fea1754}
2: C: {bdfe5953-3d4f-4195-b94b-593f66c2bc1e}
3: 2014/02/07:07:12 {82daa70b-ac7e-438c-80f5-78de8a4500f7}
4: C: {0a05a0ab-4faa-442f-a65a-88579c037e1a}
5: 2014/02/07:07:27 {e761dded-b13c-4fac-b050-5b9d042cec73}
6: C: {2af92c27-765c-43e8-a384-1bf41b0634b9}
snapshot: delete 5
Snapshot {2af92c27-765c-43e8-a384-1bf41b0634b9} deleted.
snapshot: list all
1: 2014/02/06:15:58 {052e85ae-7379-4164-8b7c-1be14fea1754}
2: C: {bdfe5953-3d4f-4195-b94b-593f66c2bc1e}
3: 2014/02/07:07:12 {82daa70b-ac7e-438c-80f5-78de8a4500f7}
4: C: {0a05a0ab-4faa-442f-a65a-88579c037e1a}
【问题讨论】:
标签: batch-file active-directory windows-server-2008 snapshot