Skip to content

Commit

Permalink
Merge 4e5676e into c96d688
Browse files Browse the repository at this point in the history
  • Loading branch information
silversword411 authored Apr 29, 2021
2 parents c96d688 + 4e5676e commit dc2e818
Show file tree
Hide file tree
Showing 79 changed files with 1,542 additions and 0 deletions.
20 changes: 20 additions & 0 deletions api/tacticalrmm/scripts/community_scripts.json
Original file line number Diff line number Diff line change
Expand Up @@ -599,5 +599,25 @@
"description": "Add a task to Task Scheduler, needs editing",
"shell": "powershell",
"category": "TRMM (Win):Other"
},
{
"guid": "17040742-184a-4251-8f7b-4a1b0a1f02d1",
"filename": "Win_File_Copy_Misc.ps1",
"submittedBy": "https://github.com/tremor021",
"name": "EXAMPLE File Copying using powershell",
"description": "Reference Script: Will need manual tweaking, for copying files/folders from paths/websites to local",
"shell": "powershell",
"category": "TRMM (Win):Misc>Reference",
"default_timeout": "1"
},
{
"guid": "168037d8-78e6-4a6a-a9a9-8ec2c1dbe949",
"filename": "Win_MSI_Install.ps1",
"submittedBy": "https://github.com/silversword411",
"name": "EXAMPLE Function for running MSI install via powershell",
"description": "Reference Script: Will need manual tweaking, for running MSI from powershell",
"shell": "powershell",
"category": "TRMM (Win):Misc>Reference",
"default_timeout": "1"
}
]
11 changes: 11 additions & 0 deletions docs/docs/contributing_using_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ Customize to your tastes (it doesn't need to be internet configured, just add re
127.0.0.1 mesh.example.com
```

## View mkdocks live edits in browser

Change stuff in `/docs/docs/`

mkdocs is Exposed on Port: 8005

Open: [http://rmm.example.com:8005/](http://rmm.example.com:8005/)

## View django administration

Open: [http://rmm.example.com:8000/admin/](http://rmm.example.com:8000/admin/)
42 changes: 42 additions & 0 deletions scripts/Win_File_Copy_Misc.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Requires WebClient object $webClient defined, e.g. $webClient = New-Object System.Net.WebClient
#
# Parameters:
# $source - The url of folder to copy, with trailing /, e.g. http://website/folder/structure/
# $destination - The folder to copy $source to, with trailing \ e.g. D:\CopyOfStructure\
# $recursive - True if subfolders of $source are also to be copied or False to ignore subfolders

Function Copy-Folder([string]$source, [string]$destination, [bool]$recursive) {
if (!$(Test-Path($destination))) {
New-Item $destination -type directory -Force
}

# Get the file list from the web page
$webString = $webClient.DownloadString($source)
$lines = [Regex]::Split($webString, "<br>")
# Parse each line, looking for files and folders
foreach ($line in $lines) {
if ($line.ToUpper().Contains("HREF")) {
# File or Folder
if (!$line.ToUpper().Contains("[TO PARENT DIRECTORY]")) {
# Not Parent Folder entry
$items = [Regex]::Split($line, """")
$items = [Regex]::Split($items[2], "(>|<)")
$item = $items[2]
if ($line.ToLower().Contains("&lt;dir&gt")) {
# Folder
if ($recursive) {
# Subfolder copy required
Copy-Folder "$source$item/" "$destination$item/" $recursive
}
else {
# Subfolder copy not required
}
}
else {
# File
$webClient.DownloadFile("$source$item", "$destination$item")
}
}
}
}
}
27 changes: 27 additions & 0 deletions scripts/Win_MSI_Install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Function Install-MSI {
Param (
[Parameter(Mandatory, ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[System.IO.FileInfo]$File,
[String[]]$AdditionalParams,
[Switch]$OutputLog
)
$DataStamp = get-date -Format yyyyMMddTHHmmss
$logFile = "$($env:programdata)\CentraStage\MilesRMM\{0}-{1}.log" -f $file.fullname, $DataStamp
$MSIArguments = @(
"/i",
('"{0}"' -f $file.fullname),
"/qn",
"/norestart",
"/L*v",
$logFile
)
if ($additionalParams) {
$MSIArguments += $additionalParams
}
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
if ($OutputLog.IsPresent) {
$logContents = get-content $logFile
Write-Output $logContents
}
}
121 changes: 121 additions & 0 deletions scripts_wip/Mac_Firewall_Enable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/bin/sh
####################################################################################################
#
# Copyright (c) 2017, JAMF Software, LLC. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the JAMF Software, LLC nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
####################################################################################################
#
# ABOUT THIS PROGRAM
#
# NAME
# enableFilewall.sh -- Enables or Disables the firewall on macOS.
#
# SYNOPSIS
# sudo enableFirewall.sh
# sudo enableFirewall.sh <mountPoint> <computerName> <currentUsername> <enableFirewall>
#
# If there is a hardcoded value specified for <enableFirewall> in the script,
# or if the parameter is not passed by Jamf Pro, the hardcoded value in the script will
# be used.
#
# The data that is specified for the <enableFirewall> parameter should be specified in one of
# the following formats. PLEASE NOTE these formats are CASE-SENSITIVE:
#
# "TRUE" or "true" or "YES" or "yes" -> Turn Firewall ON
# "FALSE" or "false" or "NO" or "no" -> Turn Firewall OFF
#
# Example Usage: sudo enableFirewall.sh "mountPoint" "computerName" "currentUsername" "TRUE"
#
# DESCRIPTION
# This script enables or disables the firewall on macOS 10.7 or later.
# It can be used with a hardcoded value in the script, or read in as a parameter.
# Since Jamf Pro defines the first three parameters as (1) Mount Point, (2) Computer
# Name and (3) Username, we are using the fourth parameter ($4) as the passable parameter to
# acquire the status of <enableFirewall>. In addition, the fourth parameter is utilized to set
# the enableFirewall value.
#
####################################################################################################
#
# HISTORY
#
# Version: 1.2
#
# - Created by Nick Amundsen on August 6th, 2008
# - Updated by Nick Amundsen on January 21, 2010
# - Updated by Brandon Wenger on November 27th, 2017
# - Updated by Matthew Mitchell on March 22, 2019
#
####################################################################################################
#
# DEFINE VARIABLES & READ IN PARAMETERS
#
####################################################################################################

# HARDCODED VALUE FOR "enableFirewall" IS SET HERE
enableFirewall=""

# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO "enableFirewall"
if [ "$4" != "" ] && [ "$enableFirewall" == "" ]; then
enableFirewall=$4
fi

####################################################################################################
#
# SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################

#Check to make sure enableFirewall is not blank
if [ "$enableFirewall" == "" ]; then
echo "Error: The parameter 'enableFirewall' is blank. Please specify a value for parameter 4."
exit 1
fi

#Get the current macOS version (the major release) to check for compatibility
#This will return the 'x' in 10.x
OS=`/usr/bin/defaults read /System/Library/CoreServices/SystemVersion ProductVersion | awk '{print substr($1,1,5)}' | cut -d . -f2`

#If the macOS version is greater than or equal to 10.7
if [[ $OS -ge 7 ]]; then

#Check parameter value, if true or yes, turn the firewall on
case $enableFirewall in "true" | "TRUE" | "yes" | "YES")
echo "Enabling Firewall for macOS 10.$OS ..."
/usr/bin/defaults write /Library/Preferences/com.apple.alf globalstate -int 1;;

#If false or no, turn the firewall off
"false" | "FALSE" | "no" | "NO")
echo "Disabling Firewall for macOS 10.$OS ..."
/usr/bin/defaults write /Library/Preferences/com.apple.alf globalstate -int 0;;
esac

else

#The macOS version is not supported
echo "Unsupported macOS version - 10.7 or later is required."

fi

exit 0;
1 change: 1 addition & 0 deletions scripts_wip/Mac_Install_All_Updates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo softwareupdate -ia
4 changes: 4 additions & 0 deletions scripts_wip/Mac_Network_DNS_Set_to_1.1.1.1.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
networksetup -setdnsservers Wi-Fi 1.1.1.1
networksetup -setdnsservers Wi-Fi 1.0.0.1
networksetup -setdnsservers Ethernet 1.1.1.1
networksetup -setdnsservers Ethernet 1.0.0.1
2 changes: 2 additions & 0 deletions scripts_wip/Mac_SMC_and_NVRAM_Reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pmset -a restoredefaults
nvram -c
5 changes: 5 additions & 0 deletions scripts_wip/Win_AD_Join_Computer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$domain = "myDomain"
$password = "myPassword!" | ConvertTo-SecureString -asPlainText -Force
$username = "$domain\myUserAccount"
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Add-Computer -DomainName $domain -OUPath "OU=testOU,DC=domain,DC=Domain,DC=com" -Credential $credential -Restart
4 changes: 4 additions & 0 deletions scripts_wip/Win_AD_Transfer_FSMO_Roles.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Transfer FSMO Roles to server
# Make this machine the FSMO Master role.

Move-ADDirectoryServerOperationMasterRole -Identity $env:computername -OperationMasterRole pdcemulator,ridmaster,infrastructuremaster,schemamaster,domainnamingmaster -Force
1 change: 1 addition & 0 deletions scripts_wip/Win_Bitlocker_Recover_Key.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
manage-bde -protectors C: -get
35 changes: 35 additions & 0 deletions scripts_wip/Win_Blue_Screen_View_And_Email.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Update this script for your company, Modify the "mail variables" section
## Also, host BlueScreenView.exe on a website and update the $url variable
## location accordingly
##
## Blue Screen View is available as freeware at
## https://www.nirsoft.net/utils/blue_screen_view.html


###script variables
$scriptName = "Blue Screen View"
$computerName = (get-wmiObject win32_computersystem).name
$computerDomain = (get-wmiObject win32_computersystem).domain
if($computerdomain -notlike '*.*'){ #if there's no period in the domain, (workgroup)
$computerDomain = "$computerDomain.local"
}

###mail variables
$smtpServer = 'mail.server.com'
$smtpPort = '25'
$smtpFrom = "Atera-$computername@$computerdomain"
$smtpTo = 'support@YOURDOMAIN.com'
$messageSubject = "Atera Script: $computerName, $scriptName"
$attachment = "c:\windows\temp\crashes.html"
$messageBody += "----See Attachment----"

###script start
$messageBody = "----Blue Screen View Results----`r`n"
$url = "https://YOURDOMAIN.com/files/BlueScreenView.exe"
$filename = "BlueScreenView.exe"
$client = New-Object System.Net.WebClient
$client.DownloadFile($url, "$env:temp\$filename")
Start-Process -FilePath "$env:temp\$filename" -ArgumentList "/shtml","c:\Windows\temp\crashes.html","/sort 2","/sort ~1"""

###send mail
Send-MailMessage -Port $smtpPort -SmtpServer $smtpServer -From $smtpFrom -To $smtpTo -Subject $messageSubject -Body $messageBody -Attachments $attachment
61 changes: 61 additions & 0 deletions scripts_wip/Win_Chocolatey_Update_Apps.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
function Update-ChocoApps {
<#
.SYNOPSIS
Update choco apps and removes the newly created shortcuts.
.DESCRIPTION
Update choco apps and removes the newly created shortcuts.
Requires administrator privileges.
.NOTES
Author: Chris Stafford
Version: 1.0.5
Created: 2020.06.17
Modified: 2020.08.06
#>

# Require Admin Permissions
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")

if ($IsAdmin -eq $false) {
Write-Warning 'Admin Rights Required'
break
}

$StartTime = Get-Date

# Aborts if Chocolatey is not installed
if (Test-Path 'C:\ProgramData\chocolatey\choco.exe') {
# Locations for shortcuts to remove
$Desktops = "$env:PUBLIC\Desktop", "$env:USERPROFILE\Desktop"

$Choco = 'C:\ProgramData\chocolatey\choco.exe'

# Parse outdated app names from choco (leave the space in ' Outdated*')
Write-Output 'Searching for Outdated Apps'
$AppList = & $Choco outdated --limit-output | ForEach-Object { $_.Split('|')[0] }

# Skips if no apps are outdated
if ($AppList.Count -gt 0) {
foreach ($App in $AppList) {
# upgrade app
& $Choco upgrade $App --confirm --limit-output --no-progress

if ($App -like '*.install') {
$App = $App.Split('.')[0]
}
# removes shortcut (created by install) based on the app name and time created
Write-Output "Removing Shortcut: $App"
$Desktops | Get-ChildItem -Filter "*.lnk" -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -gt $StartTime } | Remove-Item
}
}
else {
Write-Output 'No Outdated Apps'
}
}
else {
Write-Output 'Chocolatey is not installed'
}
}

Update-ChocoApps
17 changes: 17 additions & 0 deletions scripts_wip/Win_Chrome_Cache_Clear.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ECHO --------------------------------------
ECHO **** Clearing Chrome cache
taskkill /F /IM "chrome.exe">nul 2>&1

set ChromeDataDir="C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default"
set ChromeCache=%ChromeDataDir%\Cache>nul 2>&1
del /q /s /f "%ChromeCache%\*.*">nul 2>&1
del /q /f "%ChromeDataDir%\*Cookies*.*">nul 2>&1
del /q /f "%ChromeDataDir%\*History*.*">nul 2>&1


set ChromeDataDir="C:\Users\%USERNAME%\Local Settings\Application Data\Google\Chrome\User Data\Default"
set ChromeCache=%ChromeDataDir%\Cache>nul 2>&1
del /q /s /f "%ChromeCache%\*.*">nul 2>&1
del /q /f "%ChromeDataDir%\*Cookies*.*">nul 2>&1
del /q /f "%ChromeDataDir%\*History*.*">nul 2>&1
ECHO **** Clearing Chrome cache DONE
12 changes: 12 additions & 0 deletions scripts_wip/Win_Chrome_Clear_Browsing History.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
taskkill /F /IM "chrome.exe">nul 2>&1
set ChromeDataDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default
set ChromeCache=%ChromeDataDir%\Cache>nul 2>&1
del /q /s /f "%ChromeCache%\*.*">nul 2>&1
del /q /f "%ChromeDataDir%\*Cookies*.*">nul 2>&1
del /q /f "%ChromeDataDir%\*History*.*">nul 2>&1

set ChromeDataDir=C:\Users\%USERNAME%\Local Settings\Application Data\Google\Chrome\User Data\Default
set ChromeCache=%ChromeDataDir%\Cache>nul 2>&1
del /q /s /f "%ChromeCache%\*.*">nul 2>&1
del /q /f "%ChromeDataDir%\*Cookies*.*">nul 2>&1
del /q /f "%ChromeDataDir%\*History*.*">nul 2>&1
Loading

0 comments on commit dc2e818

Please sign in to comment.