[英]PowerShell script to keep latest 10 images on azure container registry and remaining need to delete
[英]PowerShell script to keep latest 10 images on self-hosted agent and remaining need to delete
以下應該是腳本的基礎。 我假設您可以在其他地方查找如何在需要時將其轉換為正確的 cmdlet:
$path = "..."
$fileTypes = @('bmp', 'png', 'jpg') # * for all file
$filesToKeep = 10
Get-ChildItem ($fileTypes |% { join-path $path ('*.' + $_) }) | sort -Property LastWriteTime -Descending | select -skip $filesToKeep | Remove-Item -Force
如果您更喜歡 go 按創建日期而不是上次修改日期,請使用CreationTime
而不是LastWriteTime
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.