0 votes

Good Morning,

I've been working through some of my processes and I'm not looking to make sure the deletion of Home directories (both remote and standard) as well as folder redirect directories.

I already have a script provided to delete the users profile directories, but now need to expand this.

I see there is an option for delete home directories built into Adaxes, I just wish to verify if this includes entries in the remote desktop services home folder field in AD.

If not I may need a script.

Lastly Our Folder Redirect is pushed out via GPO. I want to make the process as simple as it possibly can be, so the idea would be to pull the server name from either the remote profile or home directory path (i.e. the profile path is as follows \\servername01\profile$\username - the folder redirect will always be as follows \\servername01\fldredir$\username)

I'm not sure how possible this might be to have this all in a single script, or if it makes sense to separate these into multiple scripts in the business rule for user deletion.

If there are any questions or clarification needed, please let me know.

by (700 points)
0

Hello,

Do we get it right that if a user's profile path is \\servername01\*profile$\username, then the home folder path will always be \\servername01\fldredir$*\username? What about the profile path and home folder path for Remote Desktop Services? Can you explain this in as much detail as possible?

0

Hello,

When I noted profile path, that path should be the same as the remote profile path (i.e. \\servername01\profile$\%username%), The home directory follows suit (i.e. \\servername01\home$\%username%).

We generally don't define the home and profile paths under the Profile tab in AD, but mainly under the Remote Desktop Services Profile tab, Our preference would be to review both as users may have a home directory defined under the profile tab if they are not terminal services users.

I have attached two examples of how our AD is configured. Not all accounts would be on the same server (i.e. not all accounts will be on "\\servername01" but may be on "\\servername02") but they still follow the same pathing

\\servername\profile$\%username%
\\servername\home$\username%
\\servername\fldredir$\%username%

Hope this helps.

(Shows Remote Desktop Services Paths)

(shows home directory on profile tab)

0

Hello,

just curious if I need to provide more information?

0

Ok,

So I've been playing around with some scripts and came up with the following

# Get the Remote Desktop Services profile path
$rdsProfilePath = $Context.TargetObject.TerminalServicesProfilePath
if($rdsProfilePath -eq $NULL)
{
    return
}
# Check whether the Remote Desktop Services profile folder exists
if(!(Test-Path -Path $rdsProfilePath))
{
    $Context.LogMessage("Incorrect Remote Desktop Services profile path: $rdsProfilePath", "Error")
    return
}
# Delete Remote Desktop Services profile
Remove-Item -Path $rdsProfilePath -Force -Recurse

# Get the Remote Desktop Services home directory path
$rdsHomePath = $Context.TargetObject.TerminalServicesHomeDirectory
if($rdsHomePath -eq $NULL)
{
    return
}
# Check whether the Remote Desktop Services Home Directory exists
if(!(Test-Path -Path $rdsHomePath))
{
    $Context.LogMessage("Incorrect Remote Desktop Services profile path: $rdsHomePath", "Error")
    return
}
# Delete Remote Desktop Services Home Directory
Remove-Item -Path $rdsHomePath -Force -Recurse

So Far during my tests I am able to delete the Home directory with no problem, but in our environment our profile directories append ".V2" (ex. \\server\profile\accountname.V2). I'm looking for the syntax to take this into account in the RDS Profile cleanup.

Further, I'm looking for the following functionality.
We currently use Folder Redirect to provide roaming profile's to our end users. The format is below
\\servername\fldredir$\%username%

We currently have two servers that I would need to differentiate between based on Company as one of our companies is on a different server.

i.e.
If Company1 Then
\\server1\fldredir$\%username%
ELSE
\\server2\fldredir$\%username%

Any help would be appreciated.

0

I'm curious if your Powershell guru's have had a chance to review this request.

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello,

The following script will do what you need. In the script:

  • $fldredirPathTemplate - specifies for the folder redirect;
  • $rdsHomeDirectorySuffixes - specifies a list of suffixes for home folder paths.
$fldredirPathTemplate = "\\{0}\fldredir$\%username%" # TODO: modify me
$rdsHomeDirectorySuffixes = @(".V2", ".V4") # TODO: modify me

# Get Remote Desktop Services home folder path
$rdsHomeDirectoryPath = $Context.TargetObject.TerminalServicesHomeDirectory

if($rdsHomeDirectoryPath -eq $NULL)
{
    return
}

$rdsHomeDirectoryPaths = @($rdsHomeDirectoryPath)

# Check folder paths with the suffixes specified
foreach ($suffix in $rdsHomeDirectorySuffixes)
{
    $rdsHomeDirectoryPaths += "$rdsHomeDirectoryPath$suffix"
}

foreach ($path in $rdsHomeDirectoryPaths)
{
    # Check the Remote Desktop Services home folder path
    if(!(Test-Path -Path $path))
    {
        $Context.LogMessage("Remote Desktop Services home folder not found. Path: $path", "Warning") # TODO: modify me
    }
    else
    {
        # Delete Remote Desktop Services home folder
        Remove-Item -Path $path -Force -Recurse
    }
}

# Get server name from home folder path
$serverName = $rdsHomeDirectoryPath.Replace("\\","").Split('\')[0]

# Build path for Folder Redirect
$fldredirPath = [System.String]::Format($fldredirPathTemplate, $serverName)

# Check the Folder Redirect path
if(!(Test-Path -Path $fldredirPath))
{
    $Context.LogMessage("Folder Redirect path does not exist. Path: $fldredirPath", "Error") # TODO: modify me
    return
}

# Remove folder redirect
Remove-Item -Path $fldredirPath -Force -Recurse
0

That did indeed do the trick thank you again!

Related questions

0 votes
1 answer

Good afternoon, I'm currently updating some of our scripts and I'm looking to have an option that delete's a users V2 profile path when run. All the scripts I've ... is a script or option available to complete this task, or if you need further clarification.

asked Jan 26, 2015 by jtop (700 points)
0 votes
1 answer

Is it possible after a user logs in to be Redirect to the Home Page (if enabled) ? If so where would that need to be changed? I've found multiple difference Web Config ... where or how it gets redirected to the My Properties page so it can be changed. Thanks

asked Jul 23, 2019 by Helios5287 (100 points)
0 votes
1 answer

Hello, We are evaluating Adaxes as a replacement for our existing AD management interface. As a result, we are looking at how Adaxes can simulate or replicate the ... more than happy to provide further information if required. regards and thanks, Jay Paterson

asked Feb 15, 2013 by jayapaterson (20 points)
0 votes
0 answers

Hello, I am using this script found in the repository to remove the permissions for Adaxes service administrators from a newly provisioned user home directory: https://www. ... namespace, so the folder path is similar to \ \domain.domain.com\ServerName\Users

asked Nov 14, 2022 by GronTron (320 points)
0 votes
1 answer

Hello Adaxes Support, is there any way you could help me with a script that changes the permissions on a users home folder? I need to remove the permission to delete the folder and add the permission to delete subfolders and files.

asked Aug 1 by dominik.stawny (280 points)
3,588 questions
3,277 answers
8,303 comments
548,101 users