Quantcast
Channel: File Services and Storage forum
Viewing all articles
Browse latest Browse all 13565

Find folders with no AD User account connected

$
0
0

Hello People.

Im currently looking for help to complete a script.

I want the script to look for folder (Personal drives) that are not connected to ADUsers anymore - because then we can save Space by deleting these folders.

So far ive came up with this:

cls


Import-ModuleActiveDirectory


$Folder=Get-ChildItem-PathC:\test\-Recurse


$Users=Get-ADUser-Filter* -SearchBase"OU=Administrators,OU=USers,OU=Home,DC=ksldom,DC=dk"-PropertiesSamAccountName


$FolderName=$Folder.FullName

           if($Folder.Name-eq$Users)

            {

           Stop-Service-NameSpooler


            }

Get-Service-NameSpooler


Start-Service-NameSpooler


Why is the service not getting stopped? if i put it as -neq then it stops the service.


Datatechnician


Viewing all articles
Browse latest Browse all 13565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>