Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param([string] $path, [string]$username, [string]$password)
- $username = 'testuser'
- $password = 'testpassword'
- if ($path -eq $null -or $path -eq '')
- {
- $path = 'C:\\Program Files (x86)\\FileZilla Server'
- }
- $configPath = '{0}\\FileZilla Server.xml' -f $path
- function Get-MD5([string]$Content)
- {
- $cryptoServiceProvider = [System.Security.Cryptography.MD5CryptoServiceProvider];
- $hashAlgorithm = new-object $cryptoServiceProvider
- $bytes = [System.Text.Encoding]::Default.GetBytes($Content)
- $hashByteArray = $hashAlgorithm.ComputeHash($bytes);
- $formattedHash = [string]::join("",($hashByteArray | foreach {$_.tostring("X2")}))
- return $formattedHash.ToLower();
- }
- $password = Get-MD5($password)
- [xml]$config = Get-Content $configPath
- $users = $config.LastChild.LastChild
- $newuser = $users.FirstChild.CloneNode(1)
- $newuser.SetAttribute('Name', $username)
- $password_option = $newuser.FirstChild
- $password_option.InnerText = $password
- $password_option
- $users.AppendChild($newuser)
- $config.Save($configPath)
Add Comment
Please, Sign In to add comment