Questions tagged [scripting]

A form of computer programming that — in the context of system administration — lends it self well to automating tasks.

Filter by
Sorted by
Tagged with
0
votes
1answer
266 views

Rewriting HTTP request contents that are going through Mikrotik RouterOS VPN

I need to pipeline through all the requests from my VPN clients connected to Mikrotik OpenVPN gateway, but when request being made is and HTTP request and is targeting particular destination, I want ...
0
votes
1answer
30 views

How to filter files which have permissions changed in last n minutes

Example, I have two files -rw-rw---- 1 1000 1000 5 Sep 28 01:25 file1 -rw-rw---- 1 1000 1000 13 Sep 28 01:25 file2 After echo "asdfg" >> file1 (file1 content was modified) -rw-rw---- 1 ...
0
votes
1answer
5k views

Powershell send-mail message, how to put line break in body variable

I am searching for a string in multiple files within a folder. If I get that string, then I would like to email all these folders which have this string. I have figured all that out and have adjusted ...
0
votes
1answer
1k views

Queue VMware Virtual Machine vMotion using powercli

I wrote this quick Powershell script where it queues vMotion of VMs and runs only 4 vMotion tasks at a time. I thought this might help someone, so you are free to modify the code as per your like. We ...
0
votes
1answer
48 views

ssh script doesn't work

Hi guys I need some help, I wrote a script to connect to multiple ssh hosts but the script only work with the first IP the other ones didn't change. Here is my script: #!/bin/bash HOSTS="192.168.120....
2
votes
2answers
452 views

How to change the display name of a bulk of shared mailboxes? accentuation issue

I have to rename a bulk of shared mailboxes to a new format, the script is ready and works but when the script runs, the names that contains accentuation are not being updated properly and a question ...
0
votes
1answer
42 views

Git branches for managing machine specific scripts and timers: OK or bad idea?

I have a bash script that I need to run on multiple (personal) machines, using systemd timers. While largely similar, there is some functionality in these scripts that I need enabled on some machines, ...
-1
votes
2answers
79 views

Connect to Multiple EC2 Instances from Ubuntu without typing the IP everytime [closed]

I wanted to connect my multiple Linux EC2 Instances from my Ubuntu desktop, without writing the IP of each server every time I take the SSH. Just like in Windows you can use WinSCP, save the SSH key ...
0
votes
1answer
28 views

WinSCP automatically configure runtime

I have a bastion/jump box providing WinSCP for users to carry out transfers to secured hosts. This is integrated into a privileged access management (PAM) service. I want to automate some behaviours ...
1
vote
1answer
7k views

Jenkins execute shell return value commands vs file

I was using the Execute shell function in Jenkins with a different set of commands (calling the newman testing application). When one of the test cases was failing through newman, my build was marked ...
2
votes
2answers
518 views

Powershell script - Find LogOn attribute - How from specific OU?

This is the PowerShell script I use to find the LogOn attribute from users in Active Directory. Now rather than getting all users I want it to search only in a specific OU. The domain looks like this: ...
1
vote
0answers
50 views

Windows Firewall - Unblocking via Script

I'm trying to setup a script to unblock IP's that may get caught up in a custom rule on Windows Firewall. I am trying this: netsh advfirewall firewall delete rule name="rule_name" remoteip="ip" In ...
1
vote
2answers
4k views

Powershell - Split Array Value keep first element

I'm trying to extract just the IPs from a filtered JSON using the following code: $curl = Invoke-WebRequest -Method Get -Uri "http://urltojson.com/file.json" $curl2 = $curl.Content.replace("Script", "...
2
votes
1answer
198 views

Truncating part of an LDAP DN in Powershell? (Or getting the OU from an LDAP DN.)

What's the easiest way to get the OU containing an LDAP object in PowerShell? I'm working on a script to manage some groups that I've made "dynamic" with a script, and I can get the full ...
-1
votes
1answer
726 views

Powershell - add to array without echoing index

I'm adding items to an array called $MissingIps using the following command $MissingIps = @("") [System.Collections.ArrayList]$ExistingIps = $MissingIps if ($lbips -notcontains $awsip){ ...
0
votes
2answers
690 views

How to expand this property in PowerShell

I'm trying to expand Members property in powershell whithout success :( Here is my code... Import-Module ActiveDirectory Get-ADGroup -Filter * -Properties * | Select-Object -Property Name, ...
0
votes
1answer
52 views

Method of maintaining read variable during while loop

After "Enter server name" and setting the $servselect variable in the script below the variable is lost after the "Hello" and "Goodbye" options are selected. This requires completing "Enter server ...
0
votes
1answer
123 views

How can I create a file screen for each path in this variable?

I have a script that scans a server for drives that contains shares. After that I need it to create a file screen from a template that is already created with the same script, that part works fine. ...
3
votes
2answers
2k views

List users recursively in large organization AD

I have a script that recursively lists group members. The issue is that there are over 5K so I cannot use Get-ADGroupMember, and I also need to only get enabled users. UAC, despite microsoft ...
1
vote
2answers
62 views

Protocolling Windows-Logins with logParser

I would like to protocoll all windows logins with logparser. Everything works fine for Application or System but not in Security. The script looks like this: "C:\Program Files (x86)\Log Parser 2.2"\...
0
votes
1answer
41 views

Debain Start Up Script - Google Cloud

so I would like to know how to create a script the performs three basic commands. sudo su - Admin cd ~/AMP ./ampinstmgr -a This is what I got, I have also given it 777 perms. #! /bin/sh ...
0
votes
1answer
535 views

SED not working with complicated string

I have a file that starts like this: [global] pid = /var/run/php-fpm/php-fpm.pid error_log = /var/log/php5-fpm.log and want to replace error_log = /var/log/php5-fpm.log with error_log = /var/...
0
votes
1answer
44 views

DOS Set variable only available after execution

I have a very simple script that I want to take a value from a text document (single line, one value) and pass it to taskkill - it needs to be a one liner too so I have: set /p pidtokill=<C:\temp\...
1
vote
2answers
594 views

Rsync files-from trouble

I have strange rsync behaviour. I need to copy all files youngest than 2 days from one folder to another. So i've mixed rsync with files-from argument and find utility in a script to do what i need ...
0
votes
1answer
223 views

Icinga2 conditional logic

I have four device types: apache11, apache12, apache22 and apache24. The first two use password "4597" and the second two use password "9634." All of these webservers have the same admin user, "...
0
votes
3answers
791 views

private ip addresses in public DNS servers [closed]

I'm looking for a DNS service provider that allow me to: Add LAN IP addresses as A record. For example I need to add 192-168-0-1.example.com mapped to 192.168.0.1. I've tried godaddy and cloudflare. ...
0
votes
1answer
638 views

how to reset original owner after assigning permissions to Windows specific folders using ICACLS and takeown?

For a specific requirement i need to assign permissions to "Starks" for C: and C:\Windows C:\Windows\System32 and few other windows specific folders on a Win7 machine without tampering existing ...
1
vote
0answers
950 views

Behaviour of environment variables in HKCU\Volatile Environment reg key

I have a .bat script that runs for every user at login (copies Oracle Java Exception Sites). It copies a file to: %userprofile%\appdata\LocalLow\Sun\Java\Deployment\security\exception.sites ...
0
votes
1answer
661 views

“Permission denied” if a file doesn't eixist

I run this in bash: sudo ./my_script.sh arg1 >& result.log And I'm getting this: -bash: result.log: Permission denied if result.log doesn't exist. However, I don't want it to exist before I ...
4
votes
2answers
3k views

Run script on first boot

I want to create a script that will run only on first boot, and never again. I am working on a VM that will be converted on a template so I want to make sure I can create a script that can run ...
1
vote
0answers
987 views

Powershell script run System.IO.FileSystemWatcher as Windows service

I need a FileWatcher script to detect new files and execute another powershell script if the files are found. The destination directory of this 2nd PS script outputs file to a UNC mount that has the ...
0
votes
1answer
56 views

Processing image files once and only once without missing any

I have a wordpress installation with a large number (millions) of images. I want to optimize those images using ImageMagick mogrify but I only want to process them once (processing them over and over ...
0
votes
1answer
511 views

Batch script errorlevel issue with registry key

The script below was wrote to check whether if teamviewer is installed or not, and for what architecture and it will retrive it ClientID, transform it to decimal and print it to a file. Everytime, ...
0
votes
0answers
488 views

Run script after plugging in USB device of certain vendor ID and product ID

I have a USB device and I need to execute a "infinite" script when I plug in this device and pass the /dev/... path as an argument. The real example is: The device is RFID reader (0403:6001), which ...
1
vote
1answer
35 views

Append all the files from different VM's to a particular one?

I want to get particular file from different Vm's and get it appended to a single file.I tried it like this scp admin@data-1:/var/log/elasticsearch/cluster.log /home/itadmin/logstash/logstash-2.4.1/...
1
vote
0answers
2k views

Access denied in powershell when executing command to remote servers

I'm trying to execute the following script on several remote servers and I think the syntax is correct, but it keeps coming back as "access denied". A few things to note - I am executing the script ...
0
votes
1answer
4k views

bash script loop until webserver response 200

I'm struggling to create a bash script that monitors the web service and if is down to restart the service in a while loop until it comes back up with a 200 status response. Example : #!/bin/bash ...
-4
votes
3answers
73 views

Illegal Content in Company Assets [closed]

I am trying to find illegal content in company laptop such as: movies, torrents, music, etc. We are thinking of building a script that automates the search and reports filenames with certain ...
6
votes
2answers
65k views

How to edit Local Group Policy with script?

I have to set the local Group Policy settings and the the local Security Policy for a couple of machines which are not in a Windows Domain. Until now, I've done that by manually setting the keys in ...
0
votes
1answer
524 views

fail2ban ban GET get.php requests with status code 200

So i am newbie about all this. This is how log looks: 213.135.179.254 - - [27/Apr/2017:17:39:06 +0200] "GET /get.php?username=1515&password=1515&type=m3u HTTP/1.1" 200 0 "-" "-" 213.135.179....
0
votes
1answer
50 views

How to delete all (resizes of an) images inside folders except the main one

We have a folder structure of: assets/user/YYYY/MM/DD/ID/image.jpg|png|... and there are over 8,000+ users posted on on different times and different IDs. Within that same folder we create 6 ...
0
votes
1answer
1k views

How to ssh from shell script and execute for loop using global parameters?

What I am trying to accomplish is something like this. Servers = (11, 12, 13) ssh -t admin@10.1.1.10 << EOF sudo tar -zcf somefolders.tar.gz ~/somefolders for i in "${Servers[@]}" ...
2
votes
1answer
161 views

Create list of computers to disable

I have been tasked with automating our disabling/deleting of old computers. Unfortunately I found out the hard way that the data I am being given for this task has many errors and I am having issues ...
2
votes
1answer
879 views

Powershell - Compress-archive consuming all memory

Im new to powershell and scripting. I'm trying to compress IIS Log files (60GB total) using compress-archive cmdlet, however everytime I get the error: "Exception of type 'System....
1
vote
2answers
55 views

Pre-run “cancellation” in bareos/bacula

DNS in my environment is a bit wonky at times. When Bareos connects to a client, the client is not always the one specified by the hostname. I have a cron script that runs jobs automatically and ...
0
votes
1answer
707 views

pam_exec in linux mint does not work

I am trying to run a script when a user logs in using pam_exe.so. /etc/pam.d/common-sesion is: session required pam_unix.so session optional pam_sss.so session optional pam_systemd.so ...
-2
votes
1answer
33 views

How to change a users shell in passed with script

I am writing a bash script to change a users shell in passwd and have it be called from Rundeck. I have tried awk but I like the inline editing of sed. But I am not sure what shell the user had to ...
12
votes
1answer
318 views

Manage Multiple IIS servers without shared configuration

We currently have 2 web servers IIS 8.5 in DEV We will push the servers to production to replace our current production servers My question is, is the a way to build scripts on the fly to apply ...
3
votes
4answers
9k views

Bash script to retrieve name of Ethernet Network interface

In Ubuntu 16.04 I made a script to dinamically configure IP address of the wired ethernet interface based on certain parameters. Now the problem is that in my script I assume that the name is eth0, ...
0
votes
0answers
175 views

Script using trap and wait shows inconsistent behaviour across different systems

The following script shows inconsistent behaviour across different systems (Fedora, CentOS & RHEL) I've ran it on: #!/bin/sh -p set -x SCRIPT=`basename $0` case "$1" in start) ./$...