From 9f9ecc521fd5764d034dea224c6e9d4a6c199a77 Mon Sep 17 00:00:00 2001 From: silversword411 Date: Thu, 17 Jun 2021 15:27:40 -0400 Subject: [PATCH] community script updates --- .../scripts/community_scripts.json | 22 +++++-- scripts/Win_User_Create.ps1 | 64 +++++++++++++++++++ ..._Computer_Users.ps1 => Win_Users_List.ps1} | 0 3 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 scripts/Win_User_Create.ps1 rename scripts/{Win_Get_Computer_Users.ps1 => Win_Users_List.ps1} (100%) diff --git a/api/tacticalrmm/scripts/community_scripts.json b/api/tacticalrmm/scripts/community_scripts.json index e4a8e93e..69037025 100644 --- a/api/tacticalrmm/scripts/community_scripts.json +++ b/api/tacticalrmm/scripts/community_scripts.json @@ -8,7 +8,6 @@ "shell": "powershell", "category": "TRMM (Win):Browsers", "default_timeout": "300" - }, { "guid": "3ff6a386-11d1-4f9d-8cca-1b0563bb6443", @@ -38,7 +37,7 @@ "description": "This script installs Duplicati 2.0.5.1 as a service.", "shell": "powershell", "category": "TRMM (Win):3rd Party Software", - "default_timeout": "300" + "default_timeout": "300" }, { "guid": "81cc5bcb-01bf-4b0c-89b9-0ac0f3fe0c04", @@ -48,7 +47,7 @@ "description": "This script will reset all of the Windows Updates components to DEFAULT SETTINGS.", "shell": "powershell", "category": "TRMM (Win):Updates", - "default_timeout": "300" + "default_timeout": "300" }, { "guid": "8db87ff0-a9b4-4d9d-bc55-377bbcb85b6d", @@ -58,7 +57,7 @@ "description": "Cleans the C: drive's Window Temperary files, Windows SoftwareDistribution folder, the local users Temperary folder, IIS logs (if applicable) and empties the recycling bin. All deleted files will go into a log transcript in $env:TEMP. By default this script leaves files that are newer than 7 days old however this variable can be edited.", "shell": "powershell", "category": "TRMM (Win):Maintenance", - "default_timeout": "25000" + "default_timeout": "25000" }, { "guid": "2f28e8c1-ae0f-4b46-a826-f513974526a3", @@ -279,7 +278,7 @@ "submittedBy": "https://github.com/unplugged216", "name": "ADDS - Direcotry documentation in Hudu", "description": "Auto generates ADDS documentation and submits it to your Hudu instance.", - "args": [ + "args": [ "-ClientName {{client.name}}", "-HuduBaseDomain {{global.HuduBaseDomain}}", "-HuduApiKey {{global.HuduApiKey}}" @@ -640,9 +639,18 @@ "shell": "powershell", "category": "TRMM (Win):Storage" }, + { + "guid": "6a52f495-d43e-40f4-91a9-bbe4f578e6d1", + "filename": "Win_User_Create.ps1", + "submittedBy": "https://github.com/brodur", + "name": "Create Local User", + "description": "Create a local user. Parameters are: username, password and optional: description, fullname, group (adds to Users if not specified)", + "shell": "powershell", + "category": "TRMM (Win):Other" + }, { "guid": "57997ec7-b293-4fd5-9f90-a25426d0eb90", - "filename": "Win_Get_Computer_Users.ps1", + "filename": "Win_Users_List.ps1", "submittedBy": "https://github.com/tremor021", "name": "Get Computer Users", "description": "Get list of computer users and show which one is enabled", @@ -697,4 +705,4 @@ "category": "TRMM (Win):Misc>Reference", "default_timeout": "1" } -] +] \ No newline at end of file diff --git a/scripts/Win_User_Create.ps1 b/scripts/Win_User_Create.ps1 new file mode 100644 index 00000000..5f6240d9 --- /dev/null +++ b/scripts/Win_User_Create.ps1 @@ -0,0 +1,64 @@ +<# + .SYNOPSIS + Creates Local User on computer + + .DESCRIPTION + Creates a Local user with password and adds to Users group. If group specificed you can add to a different group + + .OUTPUTS + Results are printed to the console. + + .EXAMPLE + In parameter set desired items + -username testuser -password password -description "Big Bozz" -group administrators + + .NOTES + Change Log + 6/17/2021 V1.0 Initial release + 6/17/2021 v1.1 Adding group support + + Contributed by: https://github.com/brodur + Tweaks by: https://github.com/silversword411 +#> + +param( + $username, + $password, + $description = "User added by TacticalRMM", + $fullname = "", + $group +) + +if ([string]::IsNullOrEmpty($username)) { + Write-Output "Username must be defined. Use -username to pass it." + EXIT 1 +} + +if ([string]::IsNullOrEmpty($password)) { + Write-Output "Password must be defined. Use -password to pass it." + EXIT 1 +} +else { + $password = ConvertTo-SecureString -String $password -AsPlainText -Force +} + + +try { + New-LocalUser -Name $username -Password $password -Description $description -PasswordNeverExpires -FullName $fullname + if ([string]::IsNullOrEmpty($group)) { + Add-LocalGroupMember -Group "Users" -Member $username + Write-Output "Adding user to the User Group" + } + else { + Add-LocalGroupMember -Group $group -Member $username + Write-Output "Adding user to the $group Group" + } + EXIT 0 +} +catch { + Write-Output "An error has occured." + Write-Output $_ + EXIT 1 +} + +EXIT $LASTEXITCODE \ No newline at end of file diff --git a/scripts/Win_Get_Computer_Users.ps1 b/scripts/Win_Users_List.ps1 similarity index 100% rename from scripts/Win_Get_Computer_Users.ps1 rename to scripts/Win_Users_List.ps1