Quantcast
Channel: Software Communities : Popular Discussions - ActiveRoles
Viewing all articles
Browse latest Browse all 1277

Run dos command via Powershell (onPostCreate)

$
0
0

Hi

I am trying to run the dos command "icacls" to run after a new user creation.  As part of the new user creation process we copy a "Vista" directory to the users home drive - e:\vista.  I am then trying to run ICACLS.EXE to set the "ownership permission on this folder and propogate below.

I am using the following Poweshell script without success.

function onPostCreate($Request)
{

$DirObj.GetInfo
$samAccountName = $DirObj.Get("samAccountName")

Invoke-Expression "cmd.exe /c icacls.exe \\server1\$samAccountName$\vista /setowner bgs.com\$samAccountName /t /c"

}

I did have it working without the variable however I now cannot get it working. Any assistance or alternative method would be much appreciated.

Thanks

Nick


Viewing all articles
Browse latest Browse all 1277

Trending Articles