$a = get-date
$BackUpTarget = “C:\ROCTeam\PowerShell\SQLDailyBackUp\ProdBackUp” + $a.DayOfWeek.tostring + “.BaK”
Backup -SqlDatabase -ServerInstance “.” -Database “Joedata” -BackupFile BackUpTarget
$BackUpTarget
Get-Variable BackUpTarget -ValueOnly
Joseph,
Welcome to the forum.
BTW: When you post code or sample data or console output please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance
You can get the week number with the following code
Get-Date -UFormat %V
This does not seem to work either
Backup -SqlDatabase -ServerInstance “.” -Database “Joedata” -BackupFile “C:\ROCTeam\PowerShell\SQLDailyBackUp\ProdBackUp.bak”
</
$a = get-date
Get-Date -UFormat %V
$BackUpTarget = “C:\ROCTeam\PowerShell\SQLDailyBackUp\ProdBackUp” + V + “.BaK”
Backup -SqlDatabase -ServerInstance “.” -Database “Joedata” -BackupFile “C:\ROCTeam\PowerShell\SQLDailyBackUp\ProdBackUp.bak”
this does not work?
Instead of
$a = get-date
you do
$a = Get-Date -UFormat %V