Jump to content

ButlerKevinD

Members
  • Posts

    3
  • Joined

  • Last visited

Reputation

0 Neutral

About ButlerKevinD

Personal Information

  • Location
    Little Rock. Arkansas
  1. Arthur, I am completely new at PowerShell scripting. This is my initial foray into the subject. I should hope as time progresses my understanding and skills will increase and reflect a more streamlined approach to the topic at hand.
  2. James, I was able to solicit assistance from user "cduff" on the SpiceWorks forums. Here is the modified code that is operating without errors: # # Get the user account SAMAccount names from specific OU and dump into text file # # Get-ADUser -filter * -SearchBase "ou=KDBDOM Users,dc=ad,dc=kdbdom,dc=us" | Select sAMAccountName > c:\Test\kdbdom.txt # Get-ADUser -filter * -SearchBase "ou=KDBDOM Users,dc=ad,dc=kdbdom,dc=us" | Select-Object -ExpandProperty sAMAccountName > c:\Test\kdbdom.txt # # Pull user SAMAccount names from text file and create associated folder. # $users = Get-Content "C:\Test\kdbdom.txt" # # Create folders for each user in text file based upon sAMAccountName flag on User Object # ForEach($user in $users) { $newPath = Join-Path "c:\Test" -childpath $user New-Item $newPath -type directory -Force # Assign Full Control permissions to new folders created by sAMAccountName flag on User Object $acl = (Get-Item $newpath).GetAccessControl('Access') $permission = "KDBDOM\$user","FullControl",@("ContainerInherit","ObjectInherit"),"None","Allow" $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission $acl.SetAccessRule($accessRule) $acl | Set-Acl $newpath } The fixes for my initial code were: And and lastly:
  3. Greetings all. This is my first foray into writing PowerShell scripts. Currently, I am attempting to compile a script that will: 1. Search a specific OU containing user accounts in AD and dump the SAMAccountname field into a text file. 2. Read the contents of said text file and create folders based upon those names in a specific folder location. 3. And then assign Full Control permissions to the folder name based upon the SAMAccountname. Thus far, I have the first third of my aforementioned actions working. The last portion that assigns the permissions to the folders based upon the SAMAccountname continues to fail miserably. (NOTE: I have taken some snippets from people attempting the same ordeal but they reported success in their endeavor, unlike myself) As time permits, I would appreciate comments and/or solutions to my issue at hand. I am attaching my script code below. As much as I hate to admit it, its probably something simple, yet I am still missing the forest for the trees. Thanks in advance for any assistance. Powershell # # Get the user account SAMAccount names from specific OU and dump into text file # Get-ADUser -filter * -SearchBase "ou=KDBDOM Users,dc=ad,dc=kdbdom,dc=us" | Select sAMAccountName > c:\Test\kdbdom.txt # # Pull user SAMAccount names from text file and create associated folder. # $users = Get-Content "C:\Test\kdbdom.txt" # # Create folders for each user in text file and assign permissions # ForEach($user in $users) { $newPath = Join-Path "c:\Test" -childpath $user New-Item $newPath -type directory -Force $acl = Get-Acl $newpath $permission = "KDBDOM\$user","FullControl","Allow" $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission $acl.SetAccessRule($accessRule) $acl | Set-Acl $newpath }
×
×
  • Create New...