Author Archives: suneworld

Delete all empty subdirectories

(Get-ChildItem -recurse | Where-Object {$_.PSIsContainer -eq $True}) |
Where-Object {$_.GetFiles().Count -eq 0} | remove-item

UPDATE:
Chad Rexin has corrected this code:
(Get-ChildItem -recurse | Where-Object {$_.PSIsContainer -eq $True}) |
Where-Object {$_.GetFiles().Count -eq 0 -AND $_.GetDirectories().Count -eq 0} |
ForEach-Object {Write-Host “Deleting this empty directory $($_.FullName)”;
remove-item $_.FullName}

See below for discussion.

Import a list of users and export a list with more fields

# Make utf8 to include special characters
cat .list.csv > .list2.csv

# Import the file and process export as utf8
Import-Csv .list2.csv | foreach {
Get-QADUser -lastname $_.lastname -firstname $_.firstname | select firstname,lastname,mobile,primarysmtpaddress,logonname
} | Export-Csv .list3.csv -Encoding “UTF8”