0 votes

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

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

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.

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

0

Hello,

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

Related questions

0 votes
1 answer

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 (960 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 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 by raymondap (50 points)
0 votes
1 answer

Hello Adaxes Support, I couldn't find a script to enable MessageCopyForSentAsEnabled for a shared mailbox, do you have a script for me to do that?

asked May 22 by dominik.stawny (280 points)
0 votes
1 answer

Good afternoon, Is there a script for adding a user to an already existing Office 365 Shared Mailbox? I want to add this script onto the onboarding rules I have added already.

asked May 7 by ocanizales (60 points)
3,548 questions
3,239 answers
8,232 comments
547,814 users