我想在部署之前删除应用程序服务上的文件,以确保存在最新文件。但是,我需要排除一个文件夹。
我已将
-not -path
添加到正在尝试排除该文件夹的内容中。然而,webroot/uploads
中的文件仍在删除中,并未排除。
$bodyToPOST = @{
command = "find . -mindepth 1 -delete -not -path `"/home/site/wwwroot/webroot/uploads/*`""
dir = "/home/site/wwwroot"
}
# Splat all parameters together in $param
$param = @{
# command REST API url
Uri = "https://$WebAppName.scm.omited.appserviceenvironment.net/api/command"
Headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}
Method = "POST"
Body = (ConvertTo-Json $bodyToPOST)
ContentType = "application/json"
}
# Invoke REST call
Invoke-RestMethod @param
如何更改此脚本以从删除命令中排除文件夹
webroot/uploads
?
团队中的某人解决了这个问题,为了完整性而发布。
本质上,
-not -path
被替换为!
:
$bodyToPOST = @{
command = "find . -mindepth 1 -delete ! ""/home/site/wwwroot/webroot/uploads/*"""
dir = "/home/site/wwwroot"
}