N-able RMM: Community Scripts - Page Twenty-Nine

Last Modified

Tue Jan 29 14:40 GMT 2019

Description

Disclaimer: Please note, if any items or other contains set forth herein is derived from N-able, any items or other content posted are provided as a suggestion or recommendation to you for your internal use. This is not part of the N-able software or services that you have purchased from N-able, and the information set forth herein may come from third party customers. Your organization should internally review and assess to what extent, if any, such custom items or recommendations will be incorporated into your environment. Any custom scripts obtained herein are provided to you "AS IS" without indemnification, support, or warranty of any kind, express or implied. You elect to utilize the custom scripts at your own risk, and you will be solely responsible for the incorporation of the same, if any.

Environment

  • N-able Remote Monitoring & Management (RMM)

Solution


Fix It Script List
 
DownloadProblem title: RMM Powershell script running as logged-in user? 
Problem description: Greetings, My task is simple: I need to push out a Powershell script to Windows 7 workstations that echoes back the size of the currently logged in user's profile directory, commonly called %userprofile%. I don't need %appdata% and any other non-essential folders, so shown below is my quick and dirty solution. However, when I push this script out to the workstations, it runs as the context of $system, not $username, so the values returned to the script are all zero or invalid/incorrect. I am aware of Invoke-Command using Powershell credentials, but the problem I have is that I don't know (nor do I care to know) the passwords of all accounts under which this script will run. How can I modify this script to run under the context of the currently logged in user? $startFolder = "$ENV:UserProfile\Desktop" $colItems = (Get-ChildItem $startFolder -recurse | Measure-Object -property length -sum) $startFolder + " - " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB" $startFolder = "$ENV:UserProfile\Documents" $colItems = (Get-ChildItem $startFolder -recurse | Measure-Object -property length -sum) $startFolder + " - " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB" $startFolder = "$ENV:UserProfile\Downloads" $colItems = (Get-ChildItem $startFolder -recurse | Measure-Object -property length -sum) $startFolder + " - " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB" $startFolder = "$ENV:UserProfile\Favorites" $colItems = (Get-ChildItem $startFolder -recurse | Measure-Object -property length -sum) $startFolder + " - " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB" $startFolder = "$ENV:UserProfile\Music" $colItems = (Get-ChildItem $startFolder -recurse | Measure-Object -property length -sum) $startFolder + " - " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB" $startFolder = "$ENV:UserProfile\Pictures" $colItems = (Get-ChildItem $startFolder -recurse | Measure-Object -property length -sum) $startFolder + " - " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB" $startFolder = "$ENV:UserProfile\Videos" $colItems = (Get-ChildItem $startFolder -recurse | Measure-Object -property length -sum) $startFolder + " - " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB" 
Fix description: Without knowing their passwords this was the only other way that I could think of, I believe it does what you're looking for. It's not very pretty and the variable names are kind of uncreative but let me know if it does what you want.
DownloadProblem title: Auto Start Application/program after "Process check fails" 
Problem description: I'm having a problem with getting the "Automated Task" to execute a batch file I've uploaded. This is the exact scrip which will execute on the local desktop - but I can not get it to execute thur the Automated Task. @echo off cd "C:\Program Files\Aldelo\Aldelo For Restaurants\Aldelo For Restaurants POS" Start AFR38.exe Back ground - this is the Point of Sale system software I support for my customers. 1. I have a process check in place which lets me know when the application AFR38.exe is not running. 2. I have linked the .bat to the process check to run when the process fails. 3. . bat file will run successfully from the desk top - but not from the auto task in RMM (Identity crisis) dashboard. Any help - would be great. My coding is ... non existent. Best regards, Vincent. 
Fix description: Hello, Assuming the machines are at least WIndows 7 it may be easier to use PowerShell over a batch script. You could also use custom scripts to handle both operations. One to monitor the process and return an error code when it isn't running and another to restart the process and check if it was started successfully. What I've written below is a bit rough but it should do the trick. Realistically you could just combine the below scripts and have one do both unless you want them separate for reporting reason.
DownloadProblem title: Create Hyper-V Virtual Machine 
Problem description: Need to create and configure virtual machines on Windows Server . I think using Windows PowerShell can do it faster. 
Fix description: This is the one that I've used in the past.
DownloadProblem title: Block Windows 10 Upgrade via Script 
Problem description: With Microsoft now upgrading computers to Windows 10 without user's authorization, we need a script to prevent this from happening. 
Fix description: I'm not sure if this is exactly what you're looking for but a simple fix could be this. It should also keep it from being enabled on reboot.
DownloadProblem title: Windows Server 2012 & Hyper-V Tasks 
Problem description: I have a few Windows server and Hyper-V scripts laying around and would be happy to share them if anyone is interested in automating parts of Windows Server 2012 and Hyper-V; installing roles/features, setting up the installed roles and for Hyper-V things such as VM creation, checking for snapshots/checkpoints etc. Also if you're looking for something more specific I may be able to help out. 
Fix description: I've added a script, I'm not sure why I didn't add one originally when I created the post.
DownloadProblem title: A better Windows Server Backup monitoring script [Updated] 
Problem description: I know this isn't a problem but I wanted to share this with the community, I was looking at the built in windows server backup monitor and it was a bit underwhelming. It looks like it grabs the last event ID and spits out the word "successful", which is great and all but personally I like to be able to take a glance and have confirmation of the last backup date among other details like last date the backup actually ran as I've had examples in the past where the last backup was successful but the backup schedule itself had stopped running for about a week before it was caught. I've thrown together something quick that gives the latest time stamp for the most recent backup and marks successful or failed, the failed backup also gives you the time stamp. The script is written in PowerShell and requires Windows Server 2008/2012, the windows feature for Windows Server Backup command line options (can't remember the actual name of it) must be installed as well. I believe you get the feature automatically in Windows Server 2012R2. If I get enough interest I can start adding features to it. 
Fix description: You can see the script that I mentioned below. Edit - I've added some features to the script, the output now looks more like the standard output seen in MaxRMM and I've added more details to the output itself.
DownloadProblem title: Change DNS All Adapters 
Problem description: Looking for a script that can be used in RMM - for changing the primary and secondary DNS settings for all network adapters for a workstation. Thank you. 
Fix description: Assuming the computers are running Windows 8.1 and above you can use the following powershell script to easily change all the adapters DNS settings. If not it will be a bit trickier and may be better in the long run to upgrade the computers PowerShell versions to 3, 4 or even better 5.
DownloadProblem title: Need VBscript to exit script if user logs into a certain computer 
Problem description: Hi guys. Total VBscript newb here. We have a logon script that we've been using for awhile. A former employee made it. I've been asked to add to it though. I need the script to cancel or end if a user logs into a certain computers (3 terminal servers to be exact). Any help would be appreciated. Thanks!! 
Fix description: You could add the following to the beginning of the script. This will pull the computer name, and compare it to the strComputerOne, strComputerTwo, and strComputerThree variables. The names are case sensitive. Be sure to enter the names inside the double quotes, exactly as spelled in the computer name.
DownloadProblem title: Run cmd via remote background 
Problem description: Hi All I need to run this cmd : **"c:\Program Files (x86)\Cibecs Continuity\Agent\cibecsagent.exe" backup** On certain users's pc's but it must be run under the logged in users account. I have tried running it via max's remote background cmd line utilty but The Remote Command Line session runs under the Log On credentials of the Advanced Monitoring Agent, by default the Local System Account & the cmd fails. Does anyone know if there is a way to do this via a batch file running a scheduled task or a powershell cmd etc? Any ideas would be greatly appreciated. Tx Shane 
Fix description: Add this powershell script to the individual pc as an automated task. Run it once a day, once a week, whatever makes sense to make sure it stays there. This just adds it to the current user's registry run commands upon login. If multiple users are on the same pc, change the HKCU to HKLM The Max Dashboard will show the date & time this was run. If you add this today, push it out manually, or let the scheduled time run it tonight, then tomorrow when they log in, it will run. If you have many users like this, create a template then apply the template as needed.
DownloadProblem title: Some local machines need to be locked ... 
Problem description: Some local machines in my company need to be locked during a certain time of day. Is there a script out there that can lock a local workstation? 
Fix description: asdfaasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf
DownloadProblem title: How can I collect information on my desktop monitors? 
Problem description: I need to collect information on a physical, non-laptop or portable monitor. How can I do this? 
Fix description: Adding to Becky's version which only worked for the first monitor. Request was for plural MonitorS, which this modified version now handles.
DownloadProblem title: RMM - iDrive Log Check 
Problem description: Hello, I am looking to create a script (preferably in PowerShell) to check a log for the iDrive cloud backup service and report back to RMM the status of the last backup. I am new to RMM and currently learning PowerShell so I am just figuring this out on my own currently. Any direction in the way of where to look or good examples of what I will need to accomplish would be greatly appreciated. Here is an example of a log file that I would like to check for completion: - - 2016-08-26 02:05:35 admin@domian.com 53 0 Success 00:00:03 Ref : Username - admin@domain.com!!!Computer Name : SERVER01!!!Periodic Cleanup!!!Start Time : 08-26-2016 2:05:31!!!End Time : 08-26-2016 2:05:35!!! Periodic Cleanup 08262016000000C:\ProgramData\IDrive\\IBCOMMON\Administrator\Session\Periodic Cleanup\08-26-2016 00-00-00 The program creates a new .xml log file each day with the date as the title, ie: 08-26-2016.xml Thank you in advance for any assistance you might be able to help with! 
Fix description: $CleanupOutput=$Output.replace("","").replace("","")#The string had the xml formatting around it and figured it would be cleaner to remove it. if (($LoRMMle) -match "Failure") Write-Output "Backup Failed" Exit 1001 if (($LoRMMle) -match "Success") Write-Output "Backup Success" Exit 0 Write-Output "Backup Not Run" Exit 1001 Write-Host "The backup on $BackupDate.ToShortDateString() was $Output" Exit 0
DownloadProblem title: Gather disk space usage info from all computers 
Problem description: Does anyone have a script to gather all disk space usage from all computers in a site? I'm thinking maybe a client-side script that will report in and update a loRMMle in a shared directory? Or is there a way to pull that information from the Dashboard? I can manually view the info if I set a Disk Space check but I can't seem to find a report that will dump the info for all computers or at least an entire site. 
Fix description: I was looking around in the reports and it looks like you can generate one based off of a scheduled task, this includes custom tasks as well. You should just need to run this task on all the necessary machines and then generate a report from the custom task.
DownloadProblem title: Remove Malwarebytes from Workstations 
Problem description: I need a script to remove Malwarebytes. 
Fix description: Open Notepad and copy / paste the following. Save as yourfilename.bat . You can upload this as a task in the RMM console then make a template and assign that template. I've found you need to wait a few hours often for the task / script to copy to the PCs, sometimes overnight seems best. I found your post looking for a template myself. I tested this as a batch file, and it did work on my PC (Win7X64) ---------- ;REM EMC IT SOLUTIONS - REMOVE MBAM SCRIPT "C:\Program Files (x86)\Malwarebytes Anti-Malware\unins000.exe" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART
DownloadProblem title: RMM Script - Add Website shortcut link to All users Desktop 
Problem description: I need to add a shortcut to a website to all users desktop. 
Fix description: Hello, This should do that you're looking for. This has been tested on a Windows 10 machine as well. This will copy a file from a UNC path as the source and place it on every users Desktop. Edit: You may also want to be wary of any permissions on the source file as I believe the copy will bring over and specified permissions as well so I would make sure to copy them from a public share.
DownloadProblem title: RMM - iDrive Log Check 
Problem description: Hello, I am looking to create a script (preferably in PowerShell) to check a log for the iDrive cloud backup service and report back to RMM the status of the last backup. I am new to RMM and currently learning PowerShell so I am just figuring this out on my own currently. Any direction in the way of where to look or good examples of what I will need to accomplish would be greatly appreciated. Here is an example of a log file that I would like to check for completion: - - 2016-08-26 02:05:35 admin@domian.com 53 0 Success 00:00:03 Ref : Username - admin@domain.com!!!Computer Name : SERVER01!!!Periodic Cleanup!!!Start Time : 08-26-2016 2:05:31!!!End Time : 08-26-2016 2:05:35!!! Periodic Cleanup 08262016000000C:\ProgramData\IDrive\\IBCOMMON\Administrator\Session\Periodic Cleanup\08-26-2016 00-00-00 The program creates a new .xml log file each day with the date as the title, ie: 08-26-2016.xml Thank you in advance for any assistance you might be able to help with! 
Fix description: Hello, this should be relatively easy with PowerShell. You can store the content of the XML file in a variable/array and then search it for whatever string you're looking for. For example I quickly tested it and I was able to parse out the string "Success" with the below commands. Edit - I've made some changes and included some if and if/else statements for Success, Failure and Cancelled status'. I haven't had a chance to test it so let me know how it goes.
DownloadProblem title: VB Script to search for a file name using Wildcards 
Problem description: We are trying to create a VB Script that will search on a local drive for a file name that includes _HELP_instructions The file name has random numbers before it and sometimes it may have different extensions (EG _13_HELP_instructions.html _24_HELP_instructions.txt I want to be able to run a wildcard search that will return a result if it finds anything or not. We have a similar script that is working that searches for a file name that is always the same: '****************************************** 'Adaptation of CryptoWall Script 'Detect Cryptowall 4.0 'Run Script, It will either return a "System Clear" or a location path - "is Infected" message. '****************************************** strComputer = "." set objFSO = CreateObject("Scripting.FileSystemObject") Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colShares = objWMIService.ExecQuery("Select * from Win32_Share") '****************************************** 'Check for "help_your_files.html" '****************************************** For each objShare in colShares strInfected = False If objFSO.fileexists(objShare.path & "\help_your_files.png") OR objFSO.fileexists(objShare.path & "\help_your_files.html") OR objFSO.fileexists(objShare.path & "\help_your_files.txt") OR objFSO.fileexists(objShare.path & "\help_your_files.txt") OR objFSO.fileexists(objShare.path & "\help_your_files.html") OR objFSO.fileexists(objShare.path & "\help_your_files.png") then strInfected = True wscript.echo "Network Share " & objShare.Path & " is INFECTED!" wscript.quit(2015) End If Next '****************************************** 'If no infection Quit with Success '****************************************** If strInfected = False Then wscript.echo "System Clear!" wscript.quit(0) End If *********************************************************************** If anyone can modify this please so that it searches for the wildcard file name mentioned above that would be a great help! Jordan 
Fix description: I don't know if VB script is a requirement or not but I have something in PowerShell that should do what you're looking for. It is simple enough to modify as well.
DownloadProblem title: RMM Script - Add Website shortcut link to All users Desktop 
Problem description: I need to add a shortcut to a website to all users desktop. 
Fix description: Here is a Powershell script that I use for deployment of a new remote PC. All of our client servers and workstations have a folder on the c: drive to store misc scripts and tools and there for our use only. While it creates the folder, it also creates a URL shortcut on the desktop to our help page. This script also downloads our favicon and stores it in the new folder to reference for the shortcut. The process renames the favicon to whatever you want to save it as or you can keep the name.
DownloadProblem title: Execution Policy and Powershell Script Time Outs 
Problem description: Hello All, I was wondering if it is helpful to begin a PowerShell script by setting the Execution Policy to Unrestricted? I have a script that seems to work well 80% of the time but from time to time I get Script timed out errors in RMM. If I go to that server and open PowerShell and Set the Execution Policy to Unrestricted and then trigger the Script Check from RMM it will check successfully. Not sure if this would resolve the issue for the last 20% but wanted to get some feedback from others if you have seen this issue? All best... Jason 
Fix description: Do you already have a method? I have been working with a batch to test.
DownloadProblem title: Script check Time Machine Backups and report how long since last good backup on Client Daily Report 
Problem description: There is not a built-in way to check Time Machine backups in the OSX Agent version 1.0. A script is needed to do this. I was going to post my script, but I do not have enough points, so I will try back tomorrow. 
Fix description: Modified to work with OSX 10.11+ by: Jeremy Adams 5 Feb 2016 Changed variable "isYosemite" to "isYosemitePlus" and edited the following line: - isYosemitePlus=`echo $osVersion '< 10.2' | bc -l to identify 10.10 through 10.11 as Yosemite or newer - isYosemitePlus=`echo $osVersion '== 10.10' Should work up to OSX 10.20 or 11 if nothing else changes. Whichever comes first.
DownloadProblem title: Reporting if a NIC isn't running at 1Gbps 
Problem description: Hi, We are trying to develop a Script that will report to MaxRM Dashboard if a NIC isn't running at 1Gbps. Currently I have a script that can report the Link Speed of a NIC - But I can't get an IF Statement working with this to report to MaxRM: My Script with the IF Statement attached that isn't working is below $adapter = Get-NetAdapter | Select-Object LinkSpeed If ($adapter = "1Gbps") { Write-Host "1 Gbps" $adapter exit 2015 } else { Write-Host "Less than 1Gbps!" exit 0 } Any help would be greatly appreciated 
Fix description: Try the following. Hint: Get-NetAdapter is available on Windows 8.1 and upwards.
DownloadProblem title: Check network latency to a given hostname 
Problem description: Is there a way to check the network latency to a given hostname? 
Fix description: Powershell alternative offering option to vary number of packets to send.
DownloadProblem title: Reporting if a NIC isn't running at 1Gbps 
Problem description: Hi, We are trying to develop a Script that will report to MaxRM Dashboard if a NIC isn't running at 1Gbps. Currently I have a script that can report the Link Speed of a NIC - But I can't get an IF Statement working with this to report to MaxRM: My Script with the IF Statement attached that isn't working is below $adapter = Get-NetAdapter | Select-Object LinkSpeed If ($adapter = "1Gbps") { Write-Host "1 Gbps" $adapter exit 2015 } else { Write-Host "Less than 1Gbps!" exit 0 } Any help would be greatly appreciated 
Fix description: For several NICs try the following:
DownloadProblem title: Reporting if a NIC isn't running at 1Gbps 
Problem description: Hi, We are trying to develop a Script that will report to MaxRM Dashboard if a NIC isn't running at 1Gbps. Currently I have a script that can report the Link Speed of a NIC - But I can't get an IF Statement working with this to report to MaxRM: My Script with the IF Statement attached that isn't working is below $adapter = Get-NetAdapter | Select-Object LinkSpeed If ($adapter = "1Gbps") { Write-Host "1 Gbps" $adapter exit 2015 } else { Write-Host "Less than 1Gbps!" exit 0 } Any help would be greatly appreciated 
Fix description: Solution for Windows 7. This also works in Windows 8 and above, but the other solutions are preferred for OS 8 and higher.

In addition to the Community Scripts, review the N-able Automation Cookbooks to leverage automation policies, custom monitoring, and scripts to gain more efficiency in your business.