简体   繁体   中英

IIS backup using powershell

I am trying to take a backup of my IIS websites using msdeploy. Following is the command I use manually: .\\msdeploy.exe '-verb:sync' '-source:metakey=lm/w3svc/2' '-dest:package=C:\\iis_backups\\site2.zip,encryptPassword=xyz' > C:\\iis_ba.\\ckups\\site2.log

But how can I use the for\\foreach to get it done for all sites in one go?

I would use double quotes and put the Id within it:

get-website|foreach-object $_.ID { 
$p=$_id;
.\msdeploy.exe '-verb:sync' "-source:metakey=lm/w3svc/$p" "-dest:package=C:\iis_backups\$p.zip,encryptPassword=xyz" > "C:\iis_backups\$p.log"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM