converting powershell

Arne25

New member
Joined
Jun 5, 2012
Messages
1
Programming Experience
1-3
Hi guys,

I have a problem. I need to convert this PowerShell program to vb.net or VbScript.
But i can't find the solution..
Could anyone help me with this?

function Remove-EmptyFolders {
[CmdletBinding()]
param ()

$delDirs = @()
$dirs = Get-ChildItem -Recurse | Where-Object { ($_.PsIsContainer) }
foreach ($dir in $dirs) {
$l = 0
$files = Get-ChildItem $dir.PSPath -Recurse | Where-Object { (!($_.PsIsContainer)) }
foreach ($file in $files) {
$l += $file.length
} # end foreach $file
if ($l -eq 0) {
Write-Verbose "$($dir.pspath | split-path -noqualifier) has no files"
$delDirs += $dir.PSPath
} # end if
else {Write-Verbose "$($dir.pspath | split-path -noqualifier) has $l bytes in files"}
} # end foreach $dir

Write-Host "The following empty directories will be removed."
Write-Host "Press 'y' to continue, any other key to stop:"
$delDirs | ForEach-Object { Split-Path $_ -NoQualifier }
if ($host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown").Character -eq 'y') {
$delDirs | Remove-Item -Recurse -ErrorAction SilentlyContinue
Write-Host "$($delDirs.count) directories deleted"
} # end if
} # end function

greetings
 
Back
Top