How to exclude a folder with remove-item cmdlet
-
16-06-2021 - |
Pregunta
I have a git repository that I'm trying to delete all files and folders out of but not the .git
folder. I've tried various permutations of the -exclude
parameter but can't seem to get it.
$repoPath = "c:\myrepo"
Remove-Item $repoPath -Recurse -Force -Exclude .git
Remove-Item $repoPath -Recurse -Force -Exclude *.git*
Remove-Item $repoPath -Recurse -Force -Exclude *.git
No matter what I try the .git folder gets deleted. Any suggestions?
Solución
Remove-Item $repoPath
will remove the entire folder. Don't you mean do use Remove-Item $repoPath\*
?
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow