something exciting

Some information about the exciting thing

Table of contents generated with markdown-toc


#This should point to the root of a home folder/FR share. Subfolders in this folder match AD account usernames.
$Folders = Get-ChildItem \\SERVER\SHARE\FOLDER\
$NamesToIgnore = "Username"
$FoldersToBeRemoved = @()
foreach ($Folder in $Folders) {
    $Username = $Folder.Name
    if ($NamesToIgnore -notcontains $Username) {
        $UsernameCheck = Get-ADUser -Identity $Username  -Properties * -ErrorAction SilentlyContinue
        if ($? -eq $false -and $Username -notlike $NamesToIgnore) {
            $FoldersInformation = @{"Folder Name" = $Username; "Folder Path" = $Folder.FullName; "Last Write Time" = $Folder.LastWriteTime }
            $FoldersToBeRemoved += New-Object -TypeName psobject -Property $FoldersInformation
            Write-Host $Username
            Remove-Item $Folder.FullName -Recurse -Force -Verbose -WhatIf
$FoldersToBeRemoved | Out-GridView

Back to Top


Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.

Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.


Back to Top