0 votes

Here are the actrions of the custom command. image.png Here are the parameters. image.png Need a script to copy the param user's file path for home drive example: Param user's home drive is //server1/homedirs/username Target (copy to user) should be //server1/homedirs/%username%. Then give the user full control of the folder.

by (1.0k points)
0

Hello,

Sorry for the confusion, but we are not sure what you need to achieve. If it is about copying a user folder, you can try using the following script from our repository: https://www.adaxes.com/script-repository/copying-folder-structure-with-permissions-s380.htm. if this is not what you need, please, describe the desired behaviour in all the possible details with live examples.

0

When a user chooses the custom command they choose a user to copy to. Then a user to copy from. This parameter is an active directory object picker. The script whould catch the param user (copy from user), get the server share the user has set for home drive. And use the share to create the copy to user's folder in said share. Then permission the share. Example UserA has a home drive //server1/homedrive/usera so UserB would get a home drive of //server1/homedrive/userb with full control. Example two UserC has a home drive //server2/homedrive/userc So UserD would get a home drive of //server2/homedrive/userd

0

Hello,

That is exactly what the script we referenced does. You just need to adjust the variables according to your custom command parameters.

0

This scipt copies the items in one folder to another so no this is not what I need. This tells me the script is trying to copy items in one folder to another. $items = Get-ChildItem -Path $sourceFolder -Recurse -ErrorAction Stop }

This is in regards to a new user. New user's access and home drive location are copied by an existing script run by our Service Desk. I am attempting to replace this with an Adaxes Custom Command.

They choose a user or template user if the template or chosen user doesn't have a home drive, the new user doesn't get a home drive. If the template or chosen user has a folder in \server1\share, The script should set the user's Home folder to \server1\Share\%username% image.png

I don't see in the script where it sets this attribute, creates the new folder on the share, and set's permissions for the new user.

0

Hello,

Thank you for the provided details. As such, the script should do the following:

  1. Get the user from the parameter.
  2. Get the path to the user home directory.
  3. Replace the last part of the path with the username of the target user.
  4. Create a home directory for the target user with the new path and grant full control permissions over it.

Is that correct? If so, what should be done in case the user in the parameter does not have a home directory?

0

If the parameter user doesn't have a home drive the user we are copying to should not have a home drive set.

0

Sorry, Yes you are correct.

1 Answer

0 votes
by (267k points)

Hello,

Thank you for the provided details. You can use the below script. In the script:

  • $sourceUserParameterName - Specifies the name of the parameter used to select the source user. The parameter name should be specified with the -param prefix.
  • $inheritPermissionsFromParent - Specifies whether permissions inheritance should be enabled for the created folder.
  • $setUserAsOwner - Specifies whether to set the target user as the new folder owner.
$sourceUserParameterName = "param-Template" # TODO: modify me
$inheritPermissionsFromParent = $True # TODO: modify me
$setUserAsOwner = $True # TODO: modify me

# Get source user home folder path
$sourceUserDN = $Context.GetParameterValue($sourceUserParameterName)
if ($NULL -eq $sourceUserDN)
{
    return
}

$sourceUser = $Context.BindToObjectByDN($sourceUserDN)
try
{
    $homeDirectoryPath = $sourceUser.Get("homeDirectory")
    $homeDrive = $sourceUser.Get("homeDrive")
}
catch
{
    return
}

# Get parent folder path
$parentFolderPath = Split-Path $homeDirectoryPath

# Create a home directory
$Context.TargetObject.CreateHomeDirectory("$parentFolderPath\%username%", $homeDrive, "ADM_USERACCESSPERMISSION_FULL",
    $inheritPermissionsFromParent, $setUserAsOwner)

Related questions

0 votes
1 answer

Is there a way to have a Scheduled Task with 4 different condition? I want to create a scheduled task start every Monday and the condition see: The next Saturday of the week ... of the week is the fifth of the month then no action Thanks in advance, Simone

asked Jan 18, 2022 by Simone.Vailati (430 points)
0 votes
1 answer

We have four OUs in Active Directory (Pending Deletion, Disabled with Mail Delegates, Disabled with HR Extensions and Disabled_Temp_Leave) that users are moved to prior to their eventual ... past 7 days have been moved to one of 4 of these OUs. Thanks!

asked Jun 3, 2021 by RayBilyk (230 points)
0 votes
0 answers

We have users with group memberships in multiple domain. All groups are type Universal. For example we have DOMAIN A and child domains for each dept, such as ... group memberships during user account copy, including memberships from other domains? Thank you,

asked Sep 10, 2020 by maliguinem (20 points)
0 votes
1 answer

Our Help Desk currently 'mirrors' the group membership of a new user based on another existing user in our AD. I'd like to be able to automate this so that the initiator ... and 'paste' it on the new user being created. Any help on this would be appreciated!

asked Apr 21, 2020 by RayBilyk (230 points)
0 votes
1 answer

I had a script that would copy the values from adm-CustomAttributeTextMultiValue1 and save them into extensionAttribute15 as a comma seperated list. The script somehow got deleted and I can't seem to find the tutorial I used to create it before.

asked Jul 1, 2022 by jordan (110 points)
3,293 questions
2,991 answers
7,664 comments
544,194 users