Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Profile Folders Check

$
0
0

Good Morning

I was wondering if you could advise on the following

I have noticed on some of our servers, users have got more than one profile folder, therefore possibly creating additional profile folders not needed, like below

C:\Documents and Settings\test.user
C:\Documents and Settings\test.user.profile1
C:\Documents and Settings\test.user.profile2

I would like a script that would search against a list of servers the C:\Documents and Settings\ path and return any results which show more than one instance, possible searching for profile in the foldername and reporting this back

I have tried using test-path although this would work if i ran a query of every possible combination against each user on each server but was wondering if something along the lines of the below would help as i cannot get it to work

$servers - "server1","Server2" etc
$path - "\C$\Documents and settings"

foreach ($server in $servers) {

$path2 = "\\" + $server + $path
$result = test-path $path2 | where-object (contains -eq profile)

If (test-path $result -eq "true") then

Echo $server $Result

}

Hope this helps or explains my needs

Thanks

Barrie


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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