I'm trying to run WBADMIN via a PS script. I'm generating the commandline with variables. The script is designed to perform a backup (obviously as a scheduled task every night) to a different location which is created depending on the date and time that the script is called. Code below.
When I run this as a script "powershell -command .\backup.ps1" I get the following error from WBADMIN:
"ERROR - The value for option: backuptarget is missing. See usage below."
The problem I'm having is that the parameters for WBADMIN require "-" which it seems to me is throwing the call to WBADMIN from powershell.
I've tried a lot of things to ascerrtain what exactly is causing the problem. I'm certain it's the hyphens (obviously because they form a vital part of PS syntax). Is there a built in way around this or can anybody recommeny anything or is it something really stupid I'm doing wrong.
$date=$(Get-Date f o)
$date=$date -replace "/", "-"
$date=$date -replace "T", " "
$date=$date -replace ":", "."
$destpath = "Full Backup On $date"
$storagepath=new-item -path \\nas\backups -name $destpath -type directory
$params="start backup -backuptarget:""$storagepath"" -include:C:,D: -VSSFull"
$exec = "$commandline $params"