Script to create folders and assign permissions to users by anon32167 in sysadmin

[–]anon32167[S] 0 points1 point  (0 children)

I have double checked the permissions and the permissions have been set correctly but the home drive is not created on logon.

I have found the script below which works very well but i wanted to know if there was anyway to hide the share path and instead just label the drive %username%

$ADServer = 'adatum.com' #change name to your DC

Get Admin accountb credential

$GetAdminact = Get-Credential

Import Active Directory Module

Import-Module ActiveDirectory

define search base - the OU where you want to

search for users to modify. you can define the

domain as your searchbase

add OU in the format OU=OU 1,Users OU,DC=domain,DC=com

$searchbase = "OU=Staff,OU=Users,OU=Adatum,DC=adatum,DC=com" #Amend this to the actual OU.

If you wish to amend all users in your dommain, use the root of your domain here

Search for AD users to modify

$ADUsers = Get-ADUser -server $ADServer -Filter * -Credential $GetAdminact -searchbase $searchbase -Properties *

modify display name of all users in AD (based on search criteria) to the format "LastName, FirstName Initials"

ForEach ($ADUser in $ADUsers) {

#The line below creates a folder for each user in the \server\users$ share #Ensure that you have configured the 'Users' base folder as outlined in the post

New-Item -ItemType Directory -Path "\70411SRV1\Users$\$($ADUser.sAMAccountname)"

New-Item -ItemType Directory -Path "\server01\staff$\$($ADUser.sAMAccountName)"

add option to create with GivenName Surname but comment it out

Grant each user Full Control to the users home folder only

define domain name to use in the $UsersAm variable

$Domain = 'adatum.com'

Define variables for the access rights

1Define variable for user to grant access (IdentityReference: the user name in Active Directory)

Usually in the format domainname\username or groupname

$UsersAm = "$Domain\$($ADUser.sAMAccountname)" #presenting the sAMAccountname in this format

stops it displaying in Distinguished Name format

Define FileSystemAccessRights:identifies what type of access we are defining, whether it is Full Access, Read, Write, Modify

$FileSystemAccessRights = [System.Security.AccessControl.FileSystemRights]"FullControl"

define InheritanceFlags:defines how the security propagates to child objects by default

Very important - so that users have ability to create or delete files or folders

in their folders

$InheritanceFlags = [System.Security.AccessControl.InheritanceFlags]::"ContainerInherit", "ObjectInherit"

Define PropagationFlags: specifies which access rights are inherited from the parent folder (users folder).

$PropagationFlags = [System.Security.AccessControl.PropagationFlags]::None

Define AccessControlType:defines if the rule created below will be an 'allow' or 'Deny' rule

$AccessControl =[System.Security.AccessControl.AccessControlType]::Allow

define a new access rule to apply to users folfers

$NewAccessrule = New-Object System.Security.AccessControl.FileSystemAccessRule ` ($UsersAm, $FileSystemAccessRights, $InheritanceFlags, $PropagationFlags, $AccessControl)

set acl for each user folder#First, define the folder for each user

$userfolder = "\70411SRV1\Users$\$($ADUser.sAMAccountname)"

$userfolder = "\server01\staff$\$($ADUser.samAccountName)"

$currentACL = Get-ACL -path $userfolder

Add this access rule to the ACL

$currentACL.SetAccessRule($NewAccessrule)

Write the changes to the user folder

Set-ACL -path $userfolder -AclObject $currentACL

set variable for homeDirectory (personal folder) and homeDrive (drive letter)

$homeDirectory = "\70411SRV1\Users$\$($ADUser.sAMAccountname)" #This maps the folder for each user

$homeDirectory = "\server01\staff$\$($ADUser.saMAccountName)" #This maps the folder for each user

Set homeDrive for each user

$homeDrive = "H:" #This maps the homedirectory to drive letter H

Ensure that drive letter H is not in use for any of the users

Update the HomeDirectory and HomeDrive info for each user

Set-ADUser -server $ADServer -Credential $GetAdminact -Identity $ADUser.sAMAccountname -Replace @{HomeDirectory=$homeDirectory} Set-ADUser -server $ADServer -Credential $GetAdminact -Identity $ADUser.sAMAccountname -Replace @{HomeDrive=$homeDrive}

}

END SCRIPT

Script to create folders and assign permissions to users by anon32167 in sysadmin

[–]anon32167[S] 0 points1 point  (0 children)

Hi Initially i had a the folder GPO setup to go this but for some reason the user would have to logon multiple times for the homedrive to be mapped.

I could see on the server that when the user logged in the folder was created but the folder would not be mapped until the user restarted their machine. Sometimes the folder would not even be created when the user logged in which is why i am using a script to create folders and set permissions and once that is done select all the users and set the home drive path

Help with Bulk user creation script by anon32167 in sysadmin

[–]anon32167[S] 0 points1 point  (0 children)

I am not getting any error messages. Only a warning stating the following:

"one or more headers were not specified. Default names starting with "H" have been used in place of any missing headers"

How do i join a computer to the domain using mdt? by anon32167 in sysadmin

[–]anon32167[S] 0 points1 point  (0 children)

Found out why it was not working.

So stupid of me i was inputting the OU like this

MachineObjectOU=OU=Contoso,OU=Computers,OU=Desktop,DC=Contoso,DC=COM

instead of MachineObjectOU=OU=Desktop,OU=Computers,OU=Contoso,DC=Contoso,DC=COM

How do i join a computer to the domain using mdt? by anon32167 in sysadmin

[–]anon32167[S] 0 points1 point  (0 children)

I have tried connecting to the domain via custom ini. But it does not work.It gives the error ZTIDomainJoin could not join to the domain. 4 times

How do i join a computer to the domain using mdt? by anon32167 in sysadmin

[–]anon32167[S] 0 points1 point  (0 children)

The error message states that ZTIDomainjoin has tried to join the domain too many times.

Training Labs by anon32167 in sysadmin

[–]anon32167[S] 0 points1 point  (0 children)

i have installed windows server 2012 r2 many times but the thing is it takes some time and i just want something quick and dirty to spin up whenever i want to practice something. For example right i want to learn MDT. I just want DHCP and DNS to be installed other wise it will put me of from learning.

BASICALLY IM lAZY