Import-Module
WebAdministration
Write-Host
-foregroundcolor
Yellow
'Admin Privileges Required!'
$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
.SetInfo()
$ServerName
=
'someComputerName'
$group
=
[ADSI]
"WinNT://$ServerName/FTP USER"
$group
.add(
"WinNT://$ServerName/$accountName"
) ;
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
Function
Acl-Rule
{
$target
=
"C:\inetpub\ftproot\Localuser\"
+
$accountName
$mydir
=
get-acl
$target
$rule
=
new-object
system.security.accesscontrol.filesystemaccessrule`
(
$accountName
,
"Modify"
,
"containerinherit,objectinherit"
,
"none"
,
"allow"
)
$mydir
.addaccessrule(
$rule
)
set-acl
$target
$mydir
}
Acl-Rule
}