开发者

Copy-Item: How to copy files to inetpub\wwwroot from PowerShell

开发者 https://www.devze.com 2023-02-07 10:25 出处:网络
I need to copy template folders over to inetpub\\wwwroot via powershell.I have access and users of the tool should have access.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消