I am working on a custom deprovision task and have the need to delete a directory on a file server (not a profile directory) and cannot find a function in Adaxes to do so. Would you have a powershell script, or something, that would work for me? Basically I need to delete something like the following path:

\\servername\datafiles\hou\UserName\MyDocuments\*

Thanks in advance.

by (50 points)

1 Answer

by (216k points)
Best answer
0 votes

Hello,

Yes, a PowerShell script will perfectly fit for this purpose. Here's a sample script that deletes a folder specified by $folderPath.

# Get Remote Desktop Services profile path  
$folderPath = "\\servername\datafiles\hou\%username%\MyDocuments\"

# Check whether the folder exists
if(!(Test-Path -Path $folderPath))
{  
    $Context.LogMessage("Folder '$folderPath' does not exist.", "Warning") # TODO: modify me
    return
}

Remove-Item -Path $folderPath -Force -Recurse

To add the script to a Custom Command, Business Rule or Scheduled Task, use the Run a program or PowerShell script action.

by (50 points)
0

Thanks but a quick question. in the last line:

Remove-Item -Path $rdsProfilePath -Force -Recurse

should this actually be:

Remove-Item -Path $FolderPath-Force -Recurse

by (216k points)
0

Hello,

Yes, you are right. Sorry for this. We updated the original posting.

Related questions

Hi, is there possibility to search some custom string across all powershell script files used in Adaxes? I.e. Custom commands, Scheduled tasks etc I need to find out where is used some PowerShell command to be able to replace it for another one..

asked Apr 27, 2020 by KIT (1.0k points)
0 votes
1 answer

Hello, We've previously had assistance in implementing a method to transfer email addresses to a specified user via a powershell script for our on-prem Exchange. This has ... $user.SetInfo() Please let me know if you require more clarification. Regards, Josh

asked 5 days ago by jtop (720 points)
0 votes
1 answer

I am trying to create a Script power Shell for creating users with a South American standard. I need to use the first part of firstname + the ... .TargetObject.Put("userPrincipalName", $userPrincipalName) # Aplica as mudanças $Context.TargetObject.SetInfo()

asked Feb 21 by victor.motta (20 points)
0 votes
1 answer

In a business rule, I'd like to pass Adaxes variables into a powershell script that I'll run. For example, pass %username% into the script so it can be used inside the script.

asked Sep 5, 2024 by P-Sysadmin (20 points)
0 votes
1 answer

Hello, We're just getting started evaluating Adaxes and I'm wondering if it's possible to use a custom script to generate user passwords. In my org, we've been ... password for this user." $Password = Read-Host "Enter Initial Password" } return $Password }

asked Jun 24, 2024 by raymondap (50 points)
0 votes
1 answer