Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module WebAdministration
- Write-Host -foregroundcolor Yellow 'Admin Privileges Required!'
- #create local user
- $accountName = 'someUser'
- $password = 'somePassword'
- $day = get-date -format "MM.dd.yyyy"
- $description = "$day account activated"
- $computer = [ADSI]"WinNT://$env:computername,computer"
- $user = $computer.Create("user", $accountName)
- $user.SetPassword($password)
- $user.SetInfo()
- $user.Description = $description
- $user.SetInfo()
- $user.userflags = 65536 -bor 64 #user cant change / never expire
- $user.SetInfo()
- $ServerName = 'someComputerName'
- $group = [ADSI]"WinNT://$ServerName/FTP USER"
- $group.add("WinNT://$ServerName/$accountName") ;
- #END create local user
- #create users web directory publish folder
- New-Item -path C:\inetpub\ftproot\Localuser `
- -name $accountName -type directory
- Start-Sleep -Seconds 3
- New-Item "IIS:\Sites\Default Web Site\$accountName" `
- -type VirtualDirectory -physicalPath C:\inetpub\ftproot\Localuser\$accountName
- #this function sets access rules for user
- Function Acl-Rule
- {
- #target folder that needs security rules added
- $target = "C:\inetpub\ftproot\Localuser\" + $accountName
- $mydir = get-acl $target
- #allow the proper account Modify control from $account
- $rule = new-object system.security.accesscontrol.filesystemaccessrule`
- ($accountName,"Modify", "containerinherit,objectinherit","none","allow")
- #Add the access rule to be applied later
- $mydir.addaccessrule($rule)
- #}
- #apply all access rules to target directory
- set-acl $target $mydir
- }#end function
- Acl-Rule
- #END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement