mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-24 15:49:02 +01:00
Updated new-user.ps1
This commit is contained in:
parent
7d34c7cdf5
commit
587c0824b9
@ -2,29 +2,30 @@
|
||||
.SYNOPSIS
|
||||
Creates a new user account
|
||||
.DESCRIPTION
|
||||
This PowerShell script creates a new user account.
|
||||
This PowerShell script creates a new user account with an encrypted home directory.
|
||||
.EXAMPLE
|
||||
PS> ./new-user.ps1
|
||||
PS> ./new-user.ps1 Joe
|
||||
✔️ Created new user 'Joe' with encrypted home directory in 11 sec
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$Username = "")
|
||||
param([string]$username = "")
|
||||
|
||||
try {
|
||||
if ($Username -eq "") { $Username = Read-Host "Enter new user name" }
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
if ($username -eq "") { $username = Read-Host "Enter the new user name" }
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
if ($IsLinux) {
|
||||
& sudo adduser --encrypt-home $Username
|
||||
& sudo adduser --encrypt-home $username
|
||||
} else {
|
||||
throw "Not supported yet"
|
||||
}
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ created new user '$Username' with encrypted home directory in $Elapsed sec"
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Created new user '$username' with encrypted home directory in $elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user