Powershell & Windows Backup NetworkPath/Target Problem


hi,

i've got simple script backs correctly, path backup written 1 folder high up:

--
$policy=new-wbpolicy

$path = "\\server\backups$\"
$date =(get-date -format yyyy.mm.dd)
[io.directory]::createdirectory($path +"\"+ $date)

$networktarget = ($path+"\"+$date)
 
$listoffilespecs=new-wbfilespec –filespec c:\*.*, d:\*.*, e:\*.*

add-wbfilespec –policy $policy –filespec $listoffilespecs

$exclusionfilespec=new-wbfilespec –filespec c:\*.tmp -exclude

add-wbfilespec –policy $policy –filespec $exclusionfilespec

$backuptargetnetwork=new-wbbackuptarget –networkpath $networktarget
 
add-wbbackuptarget -policy $policy -target $backuptargetnetwork
--

the folder "\\server\backups$\2012.07.06" writes correctly, backup writes to: \\server\backups$\windowsimagebackup
rather intended:  \\server\backups$\2012.07.06\windowsimagebackup ..

if echo out variable of intended backup path, echo's correctly (\\server\backups$\2012.07.06)

i must missing obvious can't see it.  have ideas please?

thanks.


maybe try adding \ end of $networktarget $networktarget = ($path+"\"+$date+"\")

also tip, in powershell can put variables directly in double quotes, , powershell automatically expand them write line , should work same

$networktarget = "$path\$date\"



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file