Thanks for your replys.
I ended up using this tool to set permissions SetACL instead of the XCACLS.vbs tool which I downloaded from Microsoft.

Code:
call DIRPLUS.kix
$setacl = "c:\root\setacl.exe"
$folders = Dirplus('c:\root','/s /ad /m foldername')

For Each $folder In $folders
SHELL '%comspec% /C $setacl '+ $folder.path +' /dir /set %computername%\users /list_folder'
SHELL '%comspec% /C $setacl '+ $folder.path +' /dir /set %computername%\users /write'
Next



Again thanks for the quick replys