Running mutiple functions in powershell script

Viewed 41

I have multiple files in multiple locations on our network where I want to delete 0 record files. When I run my script I don't get any errors but the 0 record files aren't getting deleted. When I run them as individual scripts they work. I'm new to power shell script and these are my first experience with them. My code is as follows. (I'm not including the actual file path in my code)

Function DeleteFile1
{
  $Dir = "\\File1path"
  Get-ChildItem -Path $Dir -Recurse | Where { $_.Length -eq 0 } | Remove-Item -Force
}


Function DeleteFile2
{
   $Dir = "\\File2path"
   Get-ChildItem -Path $Dir -Recurse | Where { $_.Length -eq 0 } | Remove-Item -Force
}
0 Answers
Related