r/usefulscripts • • Feb 04 '22

[QUESTION] Turn 5 mouse clicks into 1?

23 Upvotes

Hey everyone, I am new to automation and scripting. Currently I work with a ticketing system where if a new ticket cuts, I have to do 5 mouse clicks to assign that ticket to myself. It is the samw routine everytime. I wanna be able to do this task much faster. I was hoping one of you smart folks could point me in the right direction. I do have beginner programming experience with Python but I just don't know where to start. Any help would be appreciated.

Thank you


r/usefulscripts • • Nov 21 '17

Updating drivers on multiple print servers

23 Upvotes

We’ve got dozens of print servers and I was trying to come up with a way of updating the Ricoh upd driver on them through some type of scripting to save me having to go to each one in print management and clicking add driver and go through that 50+ times. I was looking for a possible solution through powershell but couldn’t find anyone trying to do the same thing and I’m not very good with powershell just yet. Any ideas for something practical? I’m usually pushing the driver from my machine, but could store on a network share if needed. Thanks in advanced for any help on this.


r/usefulscripts • • Sep 26 '17

Run part as admin and part as user.

23 Upvotes

Guys/Gals, I've been trying to work on this for a while now. I want to install the cisco anyconnect as an admin, which i've got, but afterwards i want to push the configuration file and set that up as the user. I can't seem to find a way without having to have the users put back in their credentials to de-elevate the powershell session to not have it run as administrator.. suggestions?


r/usefulscripts • • Jun 05 '17

[POWERSHELL] Script that pings servers on the same network and returns back server information in a JSON format and to a specific directory?

23 Upvotes

Hi all,

I'd like to know if anyone has or could devise a script that allows me to ping a list of servers on my network and return the information back in JSON format?

The server information I would like to get back from the query are:

  • Is the server pingable (online/offline)?

  • Response time (ms)

  • CPU utilizatoin

  • Windows services (are they running, stopped, etc)

  • RAM usage

Ideally, I'd like to have the JSON formatted as the pseudo-JSON below:

{
  "server": "192.168.1.1",
  "hostname": "server1",
  "status": "online",
  "reponse": "18ms"
  "server": "192.168.1.2",
  "hostname": "server2",
  "status": "online",
  "reponse": "19ms"
  "server": "192.168.1.3",
  "hostname": "server3",
  "status": "online",
  "reponse": "20ms"
  "server": "192.168.1.4",
  "hostname": "server4",
  "status": "online",
  "reponse": "21ms"
  "server": "192.168.1.5",
  "hostname": "server5",
  "status": "offline",
  "reponse": "no reponse"
}

Thank you!


r/usefulscripts • • Sep 12 '16

[BASH] SSH command intercept function for your .bashrc, with a whole bunch of added goodies.

Thumbnail
github.com
23 Upvotes

r/usefulscripts • • Mar 07 '16

[CSV File] FCC Telemarketer and RoboCall Blacklist for Google Contacts 03/07/2016

23 Upvotes

Full Primary List - https://pastebin.com/95xfNP74

03/07/2016 Deltas (7 new contacts) available here: https://pastebin.com/R12A8Vqk

02/29/2016 Deltas (8 new contacts) available here: https://pastebin.com/pr4b3AiL

02/22/2016 Deltas (6 new contacts) available here: https://pastebin.com/mSr29W1D

02/16/2016 Deltas (9 new contacts) available here: https://pastebin.com/kbkyTdCv


!WARNING!

Some Android apps will have issues!

Here are the ones that are known:

  • Telegram

  • WhatsApp

  • Hangouts (from /u/bugalou, but need another to confirm)

If an app checks the status of ALL contacts (not just app specific), you'll be in for a bad time.


  1. Copy & paste the pastebin content to notepad

  2. Save As .csv

  3. Go to www.google.com/contacts

  4. Import (might complain, and switch you to the "old" interface)

  5. Select the .csv you made, and upload!

If you don't see them immediately, refresh the page, don't try to upload again!


Options to Block:

  1. Use Google Voice to redirect the Spammers group directly to voicemail

  2. Use Root Call Blocker to reject calls from the Spammers group (Thanks to /u/Toribor)

  3. ....Suggestions?


NOTICE

I'm going to only make a new thread once a month, so make sure to watch my Pastebin account for your deltas every week (the new numbers)!


The list has grown to 31,545 numbers, in 158 contacts (200 numbers per contact), and the deltas reached 1,392 this week!

Don't stop reporting these numbers! You can find out more, and file a complaint with the FCC here: https://consumercomplaints.fcc.gov/hc/en-us/articles/202916660

For those who want the raw data from the FCC, you can get it from here: https://consumercomplaints.fcc.gov/hc/en-us/articles/205239443

You can also watch my Pastebin account for updates: https://pastebin.com/u/Harshmage/

Keep the comments coming!


r/usefulscripts • • Sep 28 '15

[BASH] - script to send a gratuitous arp out for all IPs on all nics

23 Upvotes
#!/bin/bash
#
# send gratuitous arp out for each ip on this machine (inet/inet6 tay appention)
#
for ip in `/sbin/ip a |grep -w inet|awk '{print $2 " " $NF}'|sed -e 's/:[0-9]\+//g' -e 's/\/[0-9]\+ /,/g'`
do
  nic=$(echo ${ip}|awk -F, '{print $2}')
  addr=$(echo ${ip}|awk -F, '{print $1}')
  echo "[INFO] - running gratuitous arp of ${addr} on ${nic}"
  /usr/sbin/arping -i ${nic} -d -S ${addr} -B -c 5
done

r/usefulscripts • • May 06 '15

[POWERSHELL]Monitor Service and Send Email if the script starts it. Emails if it cant find the service

Thumbnail
pastebin.com
23 Upvotes

r/usefulscripts • • Jan 22 '14

[POWERSHELL] Keep track of all users currently logged on to a machine

23 Upvotes

Summary

Saves a plain-text, comma-separated list of currently logged-on users to C:\Logs\logged_on_users (configurable). I threw this together as a way for us to have a plain-text method of tracking logged-on users that we can query with other tools.

Usage

We run the script as part of the logon/logoff/reboot process.

Run with one of these three flags:

-logon  Stamp username to $LOGPATH\$LOGFILE

-logoff  Remove username from $LOGPATH\$LOGFILE

-flush   Flush all usernames from $LOGPATH\$LOGFILE

 e.g. .\logged_on_users.ps1 -logon

Download

v1.0 (2014-01-21)


This was mostly for me to get more comfortable with PowerShell. Corrections and critique welcome.


r/usefulscripts • • 22d ago

[PowerShell] ConsoleMonster PowerShell module

Post image
22 Upvotes

I've written Powershell module and .NET library in one allows you to make your daily terminal a bit more fun to play with. By using Enable-ConsoleFormatting it converts daily cmdlets such as Get-ACL, Format-Table, Format-List into their better versions. However that's just a super simple use case. The module has over 100 cmdlets to build stuff in Terminal making it super pretty and actually useful.

You can make your own powershell scripts super pretty and all demos (40+) on website show exactly how. Each demo has a video showing what you get, and script that generates it. Since the videos are generated using ConsoleMonster you can for example record your own "powershell console" experience and use in presentations or on websites.


r/usefulscripts • • Jan 12 '25

[PowerShell] Simple WebServer

22 Upvotes

Hi all,

I needed a simple pure PowerShell HTTP server implementation to use as part of a pentest tool, but every example I found online had issues:

  • They couldn't be stopped cleanly with Ctrl+C.

  • Error handling is non-existent (server crashes on malformed request).

So, I created a simple PowerShell module which:

  • Starts an HTTP server on any IP and port you specify.

  • Handles errors gracefully (like port conflicts, wrongly formated HTTP request).

  • Can be stopped manually with Ctrl+C or automatically after a timeout.

Maybe it is useful for someone else.

Here's the GitHub link if anyone's interested: https://github.com/zh54321/PowerShell_HttpServer

Cheers


r/usefulscripts • • Sep 02 '21

[Script sharing] Now Easily Audit Email Deletion in Office 365 using PowerShell

Thumbnail self.office365
22 Upvotes

r/usefulscripts • • Apr 27 '21

[QUESTION] Allow a non admin user to run a PowerShell / bat script the requires admin privileges?

22 Upvotes

I would like to have give some users access to a powershell script or bat file that needs to be run with elevated privileges (local admin).

Is there a straight forward way to do this. The script would in essence stop a windows service.


r/usefulscripts • • Mar 02 '21

[PowerShell] Monitoring LDAPS connectivity/certificate with PowerShell

22 Upvotes

Today I've decided to spend some time describing the Test LDAP functionality that Testimo provides as part of many tests it offers. With just one cmdlet you can generate a report that tests all your Domain Controllers for LDAP/LDAPS ports and provides a summary about it.

invoke-testimo -Sources DomainLDAP

I've recently updated that report to cover not only just checking the ports are open but also testing what certificate is there when it's expiring along with few other details.

I've also wanted to invite you to test Testimo after recent changes that where I've updated the visual look of them a bit. It's still a long way to go, but many reports were updated with more information.

The short blog post about it: https://evotec.xyz/monitoring-ldaps-connectivity-certificate-with-powershell/

GitHub Sources: https://github.com/EvotecIT/Testimo

In the next few months, I will be updating Testimo with more details per each test and adding more tests in general. Hope you enjoy this one.

To get it up and running:

Install-module Testimo

And that's it...


r/usefulscripts • • Mar 14 '19

[PowerShell] Switch AD Users to new Manager

22 Upvotes

$orgMan = Read-Host -Prompt "Enter Original Manager's Username "$orgMan = Get-ADUser $orgMan

$newMan = Read-Host -Prompt "Enter New Manager's Username "$newMan = Get-ADUser $newMan

Get a list of users that are managed by the original Manager, Display them using Out-GridView so you can select all or just some of the users.

$Users = Get-ADUser -Filter {Manager -eq $orgMan.DistinguishedName} | select Name, SamAccountName, UserPrincipalName, DistinguishedName | Out-GridView -PassThru -Title "Select Users to Update"

Display Old and New Manager's names and List Users that will be moved.

Write-Host "This will remove" $orgMan.GivenName $orgMan.Surname "and add" $newMan.GivenName $newMan.Surname "to the following user accounts : "

$Users | select -ExpandProperty Name

Confirm user selection before updating accounts

$confirmation = Read-Host "Are you Sure You Want To Proceed "

if ($confirmation -eq "y" -or $confirmation -eq "Y") {

$Users | foreach { Get-ADUser $_.SamAccountName | Set-ADUser -Manager $newMan.DistinguishedName }

}

https://gist.github.com/Haxale/54e6261ee8e78aeb0e20c45f4a6152ec


r/usefulscripts • • Dec 03 '18

[BASH] Automated GPG-encrypted (or unencrypted) backups

22 Upvotes

I originally posted this on /r/bash, but then I found this subreddit, so I'm reposting here.

I used to frequently make GPG-encrypted backups of the same folders, and update the external backup location manually. This process used to involve using the tar command to backup the folders I wanted -- which would (1) require me to look up what flags to use and (2) require me to open my home folder and painstakingly specify each folder I wanted to backup. Then I had to wait for it to end so I could begin encrypting it with GPG. Then I had to wait for that to end so I could copy it to my external backup. Finally I had to make sure I cleaned up all the files I made along the way.

But to this I say no more! So I made this fully automated luxury backup script.

It grabs the specified files and directories from line 40 of the script, then asks you for an output directory and GPG email. If you leave the output directory blank, it places the archive in your Downloads folder. If you leave the email blank, it leaves the archive unencrypted.

The file output name is archive.tar.gz if it's unencrypted, or archive.tar.gpg if you do encrypt it.

Here's the GitLab repo (with more instructions as well): https://gitlab.com/krathalan/bash-backup-script

This is my first Bash script, so I'm not sure I'm doing everything right, but from my hours of testing it seems to work reliably as long as all your inputs are okay -- as in, you're not putting an email for GPG encryption whose public and private keys you do not have in your keyring, nor the directories which you have specified are mounted; that is to say, please make sure you have both public and private keys for the specified email in your keyring if you decide to use GPG encryption, and make sure all specified directories are mounted.

Edit: pull requests totally welcome!

Edit 2: edited the line number as I've edited the script since writing this


r/usefulscripts • • Sep 26 '18

[PowerShell] New-DictionaryFile

Thumbnail
sconstantinou.com
22 Upvotes

r/usefulscripts • • Sep 10 '18

[PowerShell] Enterprise Security: How to configure and use Group Managed Service Accounts

22 Upvotes

A brief walk-through of how to configure Group Managed Service Accounts (gMSA)

http://www.signalwarrant.com/enterprise-security-how-to-configure-and-use-group-managed-service-accounts/


r/usefulscripts • • Oct 18 '17

powershell script to delete attachments ONLY from a user mailbox

22 Upvotes

This script we allow you to go into a users mail in exchange 2010 and delete only attachments from a certain inbox i.e sentitems,deleteditems or outbox. It saves space in the exchange server and it will also log the file in a folder and send it to the user this way they have a log file of what attachments have been deleted.

You will need the following programs to make it work

  1. powershell 4.0

  2. download Web Services\2.0\Microsoft.Exchange.WebServices.dll

powershell website http://community.idera.com/powershell/ask_the_experts/f/203/p/25294/49520#49520

and in reddit https://www.reddit.com/r/PowerShell/comments/76z5yp/delete_only_attachments_but_not_the_actual_email/


r/usefulscripts • • Sep 11 '17

PS Script for Domain-wide "report"

22 Upvotes

Hi Guys,

Some what of a simple one :D

Looking for a PS script that can be run either as PS or through AD Moduel.

I just need to to run on all domain computers and collec the computers Name, Computer Model, and Last logged in users etc.

I was able to use this to find out name and model but difficulties getting last logged in user.

$strFilter = "computer"

$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.SearchScope = "Subtree" 
$objSearcher.PageSize = 1000 

$objSearcher.Filter = "(objectCategory=$strFilter)"

$colResults = $objSearcher.FindAll()

foreach ($i in $colResults) 
{
    $objComputer = $i.GetDirectoryEntry()
    Get-WmiObject Win32_Computersystem | Format-List Name, model

}

r/usefulscripts • • Aug 21 '17

[Request] Powershell to copy and delete files with age restrictions

22 Upvotes

Hi,

I would like a script to copy files with the Date modified less than 1 week from $Source to $Dest. and once they are a week old delete them from $dest.

Basically $dest will only have files that will have been modified in the past week. Files in $Source will not be modified during the week they are in $dest. There are no folders in either directories.

How would I go about this?


r/usefulscripts • • Jul 30 '17

[POWERSHELL] Cross-platform netstat output

Thumbnail
pastebin.com
22 Upvotes

r/usefulscripts • • Jul 28 '17

[ZSH] Simple yet fancy search script

Thumbnail
pastebin.com
22 Upvotes

r/usefulscripts • • May 01 '17

[POWERSHELL] Powershell, Jenkins, AWS: Enforced Security group IPs for management ports

22 Upvotes

[probably easier to just read the blog for the dependencies] (https://i-script-stuff.electric-horizons.com/powershell-aws-jenkins-and-continuously-enforced-security-groups/)

Github link for the direct stuff

So, this basically goes through and defines what IPs you want certain ports in your security group to talk to. In the example I used ssh and RDP. Script will remove the old IP add the new IP in multiple environments.

It is mostly a "get things up to snuff" style script. In that ackward time that every environment goes through that involves manually creating EC2 instances people forget to use the correct firewall group. Then due to a ton of reasons leave SSH and RDP open to the world.

This script fixes that in hopes to tighten security until you can get to a better deployment method.