您好我正在尝试使用脚本和Windows任务调度程序将我的域控制器自动备份到网络共享 - 我们的域控制器是Windows Server 2008r2
这是我编写的脚本的代码,如下所示,但是当我运行脚本时,它确实在网络共享上创建了文件夹,但无法启动系统状态备份电源shell在运行脚本时返回此错误。
有关我可以采取哪些措施来解决此问题?我也是PowerShell的新手,因此很多人都可以更轻松地实现它。
非常感谢戈登
wbadmin 1.0 - Backup command-line tool
(C) Copyright 2004 Microsoft Corp.
ERROR - One of the parameters or options specified is invalid: [quiet].
See the syntax below.
Syntax: WBADMIN START SYSTEMSTATEBACKUP
-backupTarget:<VolumeName>
[-quiet]
Description: Creates a system state backup of the local computer and stores
it on the location specified.
To use this command, you must be a member of the Backup Operators group
or Administrators group.
Parameters:
-backupTarget Specifies the location where you want to store the backup.
The storage location requires a drive letter or a GUID-based
volume of the format: \\?\Volume{GUID}.
-quiet Runs the command with no prompts to the user.
Example:
WBADMIN START SYSTEMSTATEBACKUP -backupTarget:f:
#adds windows server backup powershell snapin
Add-Pssnapin windows.serverbackup
#gets date
$date = Get-Date -Format dd.MM.yyyy
#declares backup location and adds date
$backdir = ("\\backupserver\bpdbackups\DC\$date")
#makes backup directory on network share
mkdir $backdir | out-null
#runs system statebackup
wbadmin start systemstatebackup -backupTarget:$backdir -[quiet]
#sends and email at the nd of the process
$smtp = "192.168.xxx.xxx"
$from = "Domain Controller <support@domain.com>"
$to = "Network Admin <network.helpxxx@xxx.com>"
$body = "The backup operation has been successfully done! Date: $date"
$subject = "Backup on $date"
#Send an Email to User
send-MailMessage -SmtpServer $smtp -From $from -To $to -Subject $subject -Body $body - BodyAsHtml
write-host "Backup Successful"
答案 0 :(得分:0)
好的,所以你在这里遇到了一些问题。首先,命令行开关周围的方括号表示它是可选,不应包括在内。其次,我认为您需要包含字符串变量,因为您没有调用PowerShell小程序。
尝试更改:
wbadmin start systemstatebackup -backupTarget:$backdir -[quiet]
到
wbadmin start systemstatebackup -backupTarget:"$backdir" -quiet