Try adding the -Force parameter:
$myDocs = (Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\').Personal
$Desktop = (Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\').Desktop
if (Test-Path -Path 'c:\testscripts\config\initdate.txt')
{
$sdate = Get-Content -Path 'c:\testscripts\config\initdate.txt'
$initdate = Get-Date -Date $sdate
}
else
{
$initdate = Get-Date
Set-Content -Path 'c:\testscripts\config\initdate.txt' -Value $initdate
}
$backday = Get-Date
$diff = ($backday - $initdate).Days
if ($diff -eq 0)
{
if (Test-Path -Path 'c:\testscripts\config\fullbackuppath.txt')
{
$fbPath = Get-Content -Path 'c:\testscripts\config\fullbackuppath.txt'
}
else
{
$fbPath = 'c:\testscripts\full1'
Set-Content -Path 'c:\testscripts\config\fullbackuppath.txt' -Value $fbPath
}
if (Test-Path -Path $fbPath)
{
if (!(Test-Path -Path "$fbPath\Desktop"))
{
New-Item -Path "$fbPath\Desktop" -ItemType Directory -Force
}
if (!(Test-Path -Path "$fbPath\MyDocs"))
{
New-Item -Path "$fbPath\MyDocs" -ItemType Directory -Force
}
}
else
{
New-Item -Path $fbPath -ItemType Directory -Force
}
Set-Content -Path 'c:\testscripts\config\desktop.txt' -Value 'log normal "c:\testscripts\config\synlog.txt"'
Add-Content -Path 'c:\testscripts\config\desktop.txt' -Value "option confirm:yes-to-all"
Add-Content -Path 'c:\testscripts\config\desktop.txt' -Value "criteria timestamp:2sec"
Add-Content -Path 'c:\testscripts\config\desktop.txt' -Value "Load "
Add-Content -Path 'c:\testscripts\config\desktop.txt' -Value "Load `"$Desktop`" `"$fbpath\Desktop`""
Add-Content -Path 'c:\testscripts\config\desktop.txt' -Value "Sync Mirror:left->right"
Invoke-Expression "c:\testscripts\config\desktop.bat"
Set-Content -Path 'c:\testscripts\config\mydocs.txt' -Value 'log normal "c:\testscripts\config\synlog.txt"'
Add-Content -Path 'c:\testscripts\config\mydocs.txt' -Value "option confirm:yes-to-all"
Add-Content -Path 'c:\testscripts\config\mydocs.txt' -Value "criteria timestamp:2sec"
Add-Content -Path 'c:\testscripts\config\mydocs.txt' -Value "Load "
Add-Content -Path 'c:\testscripts\config\mydocs.txt' -Value "Load `"$myDocs`" `"$fbpath\mydocs`""
Add-Content -Path 'c:\testscripts\config\desktop.txt' -Value "Sync Mirror:left->right"
Invoke-Expression "c:\testscripts\config\mydocs.bat"
}