I'm trying to run the following powershell code as a powershell task to find empty folders in a directory structure. It works fine when I run it from the powershell command window, but nothing seems to happen when running it from VC. I'm using the same credentials in both cases.
(Get-ChildItem \\Server\Fileshare\Backups -recurse | Where-Object {$_.PSIsContainer -eq $True}) |
Where-Object {$_.GetFiles().Count -eq 0} | Select-Object FullName
After looking on the forum, I tried: Write-Output "Hello World" as the powershell code instead and it worked fine so I don't think it's that VC can't run the powershell code, but I'm not getting any kind of error. The task comes back with no output. Is there anything I can check in VC to figure out what might be going wrong?
The ultimate goal will be to delete all the empty folders like:
(Get-ChildItem \\Server\Fileshare\Backups -recurse | Where-Object {$_.PSIsContainer -eq $True}) |
Where-Object {$_.GetFiles().Count -eq 0} | Remove-Item