Copy-Item: How to copy files to inetpub\wwwroot from PowerShell
I need to copy template folders over to inetpub\wwwroot via powershell. I have access and users of the tool should have access.
When I manually copy files I have to confirm via the admin confirm dialog. What's a workaround in powershell to do this?
$sourceroot = "C:\Users\a_user\Desktop\Projects\IIS Scripting\Templates\"
$sourcepath = Join-Path $sourceroot "Template"
$inetroot = "C:\inetpub\ww开发者_如何学运维wroot"
$destination = Join-Path $inetroot "NewApp"
if(Test-Path $destination){ Remove-Item $destination -recurse }
Write-Host $destination
Copy-Item $sourcepath -destination $destination -recurse
I ended up wrapping it in a bat file:
cd %SystemRoot%\system32\WindowsPowerShell\v1.0
powershell -ExecutionPolicy RemoteSigned -File "C:\Users\a_users\Desktop\Projects\IIS Scripting\Scripts\testxml.ps1"
then I right-click the bat file and run as administrator and I'm set
精彩评论