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 (215k 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 (520 points)
0 votes
1 answer

I'm trying to understand the best approach to use when developing scripts for Adaxes. In the Management console you can't see the details of an object while coding. ... possible there are additional attributes I don't see. Thanks in advance for your advice.

asked Aug 7, 2020 by ComputerHabit (790 points)
0 votes
1 answer

Hi We create different Groups when a new OU is generated. The name of the groups consist of the OU name with additional text. We would like ... value $Context.SetModifiedPropertyValue($property, $value) $Context.LogMessage($value, "Information") Thanks, Mario

asked Jul 9, 2020 by maca (100 points)
0 votes
1 answer

I have a script that i am trying to run against all users in an OU, but the script will only run against 1 user then not run again for any other users in the OU. Any thoughts on why this would happen?

asked Mar 1, 2018 by kevball2 (100 points)
0 votes
1 answer

Hi smart people! I'm using this script: http://www.adaxes.com/script-repository ... t-s423.htm Which works great for sending an email to someone, listing their direct ... body of the email at once would be greatly appreciated! Thanks for any and all replies!

asked Mar 24, 2017 by 3Jake (150 points)
2,640 questions
2,375 answers
6,305 comments
985,919 users