brianroma
asked on
PowerShell Script that References CSV User list and checks for domain memebership and Exports results to csv
Hey guys I have another challenge...
we have a csv list of user accounts from a directory list of roaming profile folders. We want to delete some of the folders but our management wants confirmation that there aren't Active Directory accounts associated with the folders.
Is there a way to script PowerShell to look at a csv (that has a list of names of old roaming profile folders) file, query AD if each item in the list is a user account, and if the item in the first csv is not an AD user account, then write to a second csv?
We can then take the second csv and delete the orphan roaming profile folders on our file server.
Thanks for your help...
we have a csv list of user accounts from a directory list of roaming profile folders. We want to delete some of the folders but our management wants confirmation that there aren't Active Directory accounts associated with the folders.
Is there a way to script PowerShell to look at a csv (that has a list of names of old roaming profile folders) file, query AD if each item in the list is a user account, and if the item in the first csv is not an AD user account, then write to a second csv?
We can then take the second csv and delete the orphan roaming profile folders on our file server.
Thanks for your help...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK that works great!
Thanks!
Brian
Thanks!
Brian
Sorted with deleting the folders afterwards?
Chris
ASKER
I added "FolderName" at the top of the OldFolders.csv (snippet below):
FolderName
A1017230
acsbackup
administrator
Archive (Tom)
BPCopy
The NoADAccount.csv is created when the script runs, but it's empty.
I am getting this Error
Import-Csv : Cannot open file C:\PowerShell-Brian\Workin
At C:\Users\myAccount\AppData
+ Import-CSV <<<< "OldFolders" | %{ If ((Get-QADUser $_.FolderName) -eq $Null) { $_ } } | Export-CSV "NoADAccount.csv"
PS C:\PowerShell-Brian\Workin