I'll tried it, but that's not (exactly) the solution. But with a little testing, I found the problem: It's the use of single and double quotes. The following is working:

code:
	$dir1 = '\\server\share' ;replced these quotes with single ones
$dir2 = '%userprofile%\dir' ;replced these quotes with single ones
Run '%comspec% /c xcopy "$dir1" "$dir2" /e /d /q /y'

Thanks for your help!