0
我已经创建了一个PowerShell脚本,用于将文件复制到目录,脚本,首先创建文件夹或强制新文件夹事件(如果存在)。然后从另一个位置复制一个目录。复制完成后,我需要根据用户给出的值执行脚本来复制正确的Web配置文件。我遇到的问题是我可以复制这些文件,但是当我尝试复制正确的web.config时,所有文件都设置为只读,因为访问被拒绝,脚本失败。创建和复制目录时的权限问题
这是一个简化版脚本的简化版。
$WebApp_Root = 'C:\Documents and Settings\user\Desktop\Dummy.Website'
$Preview_WebApp_Root = 'c:\applications\Preview\'
$Choice = read-host("enter 'preview' to deploy to preview, enter Dummy to deploy to Dummy, or enter test to deploy to the test environment")
if (($Choice -eq 'Preview') -or ($Choice -eq 'preview'))
{
$Choice = 'Preview'
$Final_WebApp_Root = $Preview_WebApp_Root
}
write-host("Releasing Build to " + $Choice +'...')
write-host("Emptying web folders or creating them if they don't exist... ")
New-Item $Final_WebApp_Root -type directory -force
write-host("Copying Files... ")
Copy-Item $WebApp_Root $Final_WebApp_Root -recurse
write-host("Copy the correct config file over the top of the dev web config...")
Copy-Item $Final_WebApp_Root\Config\$Choice\Web.configX $Final_WebApp_Root\web.config
write-host("Copying correct nhibernate config over")
Copy-Item $Final_WebApp_Root\Config\$Choice\NHibernate.config $Final_WebApp_Root\NHibernate.config
write-host("Deployed full application to environment")