Newest scripting Questions

Q&A for system and network administrators

NetworkManager up scripts running twice

My system, Ubuntu 16.04, uses NetworkManager. In order to hook an interface up event I have placed a script in /etc/network/if-up.d/. The head of the script looks like: #!/bin/bash NETIF="enp2s0" ...

Script to delete FTP data older than 7 days

Currently I am using following simple line script to take backup of server directory to remote FTP location # Take backup to remote location ncftpput -z -R -uusername -ppassword ftp.example.org /...

Newbie Sys Admin - Bash Script Assistance

I am a new sys admin who is learning the role as I go. I have a bash script here that I cant get to work. This is just a test script as its my first one so I know setting authorized_keys to 777 is ...

Force all domain users to have a specific “search folder” in outlook

I want to implement in my domain by GPO or by script that all of the users will have a "search folder" in outlook that searches for items larger then 5 MB. I want to be able to tell users who had ...

Duplicate folders in one parent folder [on hold]

Is there any way to find the duplicated folders based on the name and content ? list the names in red hat Linux ? I tried to search through find command and it is not succeed

Execute command on multiple files

I need to execute jpeg-recompress on thousands of files. I've tried: for image in *.jpg; do image2=${image%.*}.jpg; ./jpeg-recompress /path/to/images/$image /path/to/images/$image2; echo "...

How to minimize missed events using WMI Polling with __InstanceCreationEvent?

I'm using a WMI query (shown below) to capture when a process is created, however a lot of processes that run quickly are missed. For example, if I set polling to every 30 seconds, then a process that ...

What are the Associated Extensions for the Interpreter memcached.exe

What are the Associated Extensions for the Interpreter memcached.exe I want to program Abyss Web Server to manifest Interface FastCGI (Local - TCP/IP Sockets) for Interpreter Memcached.exe for ...

How to get AD user's “Display name” instead of logon name (domain\userid) while exporting “send as” and “full” permissions?

I have googled and created two scripts . (1), (2) (1)First one is to export "Full Access" of a shared email box called "ap.cz" Get-Mailbox ap.cz | Get-MailboxPermission | where {$_.user.tostring() -...

batch file to install application (Adobe Reader)

I previously used ninite to install this. However, this is no longer supported through ninite anymore. I usually install this manually but I know where a way to automate this using a batch script of ...

Finding script trying send spam via postfix

I have had this problem before with crap wordpress sites on my server but it was always easy to find the source, a php script by looking at the spam header and see the php scripts name. But this time ...

How create directory structure with permissions from web?

I have a directory structure in a shared folder with specific folder permissions for making projects in a Active Directory Domain like \server\shared\Projects\Project1, \server\shared\Projects\...

Script to search bots from log file

I have a little log-file, where i should find the bots. File: Mon, 22 Aug 2016 13:15:39 +0200|178.57.66.225|fxsciaqulmlk| - |user logged in| - Mon, 22 Aug 2016 13:15:39 +0200|178.57.66.225|...

Plugins and skripts for munin master or munin node?

I am new to munin monitoring. I am a bit confuse about two things about munin. First: Do I put plugins or scripts(self written) in munin master or munin node (a host to be monitored) for able to ...

Ubuntu - adduser / useradd both ask for password to be set, can force a script to bypass this?

I have a script that works fine on Centos because useradd doesnt require a password to be set there and then, but the same script doesnt work on ubuntu servers as it requires this info. I ideally ...

Launch AD for alt domain batch stopped working after win10 upgrade

I have a simple batch script that I have been using to launch the AD Users and Computers modules for domains other than the one my current session is logged in to. I've been using this for longer ...

one script to monitor incoming ssh connections to the server

I want to make a script to monitor incoming ssh connections to the server. Try ForceCommand in sshd_config but it will not let me in if I put it there my script. Match User * X11Forwarding no ...

Need script to replace TEXT in selected files

Environment Windows 10, C:\Folder_With_VMXfiles, installed sed for windows Tools: Batch script, sed for Windows Requirements: In folder C:\Folder_With_VMXfiles Need to replace some text inside the ...

AWS ELB - how to attach the latest/newest snapshot automatically?

I'm really new to AWS ELB and I'm reading about how to automatically mount an EBS volume from a snapshot via the ebextensions script. I've found this post as a reference: https://aws.amazon.com/blogs/...

Powershell script to export email address of users in an OU

so I have a ton of OU's on our DC that are all formatted the same way with a 6 digit number to start and then a name after the number. I am wondering if there is a way to write a Powershell script ...

How to show lines where uniq more than 3

I have a file, where i should make "uniq" and show result. My file: 178.57.66.225 fxsciaqulmlk 178.57.66.225 fxsciaqulmlk 178.57.66.225 fxsciaqulmlk 178.57.66.225 faaaaaa11111 178.57.66.215 ...

content_filter not executed after script python

I'm using postfix with dovecot. I had a content_filter with a specific script but when I receive a mail the dovecote filter is not executed I try to call the dovecote filter in same time than my ...

RD Licensing server add doesn't work with script without RDS (Win SRV 2012)

First notice, I'm a beginner scripter (and sys-admin student) so I have no idea how stupid the question is I'm about to ask... I have created a script that adds the RD Licensing role to a server. I ...

Powershell send CTRL A

I am tryng to make a .bat in order to launch a program, and save the result as a txt file. The issue is in order to save you have to select some line so i would like to do a CTRL+A and a save as in ...

Don't work loop on bash

I have written script on bash. It got all list of interfaces. And in loop has compared with variable. But it doesn't work good. My script: #!/bin/bash search=`ls -1 /sys/class/net | grep -v lo` echo ...

Make one machine look like the rest regarding packages

I've been given the daunting task of deploying one "pristine" machine's packages to the rest of them - about 120 machines in total. All of the machines are running CentOS 6.8. The power users have ...

Searching of bots from log-file [duplicate]

I have written this message before. So, i have done my task, but i have a little not correct output. So... I will start. I have a log file: Mon, 22 Aug 2016 13:15:39 +0200|178.57.66.225|fxsciaqulmlk| ...

RedHat Cluster Manual Service Startup Script

Due to some issues with cluster stability and how often we only have a very limited time available in which to work, frequently we will need to restore the service running in the cluster even when the ...

hpacucli.exe opening in a new cmd

I am trying to collect the output from hpacucli.exe on Windows in PowerShell. I am using the following code: $execPhysical = & $hpacucli 'ctrl all show config' Write-Output $execPhysical For ...

Make sql querry in a loop in bash [on hold]

I want to search replace some string in bash in a loop from sql table. What i have written: for i in "wwe" "wwf" "wcw" "roh"; do UPDATE wrestling SET value = REPLACE(value, "$i", "wrestlemania"); ...

Don't work correctly script in bash

I need to get interface by number. My script: #!/bin/bash interfaces=/root/tt interfaces_with_numbers=/root/tt2 ls -1 /sys/class/net > /root/tt cat -n $interfaces > $interfaces_with_numbers ...

wrapper script for mail.log / postfix database

I maintain a mailserver sending around 50k emails a day from a handful of mailadresses. I need to evaluate quite often questions like how many mails were send today by emailadress x which emails send ...

import list of pcs using import-Csv and change attribute using powershell script

Im trying to write a powershell script to change attribute called "comment" in a list of pcs using csv and import-Csv. Here is my script $computers=Import-Csv -Path "C:\sds.csv" foreach ($...

Grep by block of text\lines

I have the text, that contains some lines. So, i need to make GREP of several lines. For example, i have repeating text and i should GREP get lines, that have this repeating key-words. grep -o "test|...

Large amounts of files over ftp can't be downloaded through ncftpget [on hold]

I need to backup files automatically from my host and the only available method is through ftp. I used to not have problems with ncftp, but I already noticed that the larger is the amount of files to ...

Delete all folder not containing filename matching glob/regex

I want to do the following. I have depth 2 file hierarchy like this: A | B | | g | | h50000 | C Where A, B, C are folders. I want to delete all folders without files matching specific patters, (in ...

Backup powershell script pauses until i press space

I made a script to export all mailboxes ( as secondary backup for my Exchange 2013 Server.) The script basically gets all the mailboxes from a list in a text file and does a for-loop going through ...

Replace a string once another string has been found

I'm programmatically building boxes, but I need to update a .repo file for PHP which has the following contents: # Repository: http://rpms.remirepo.net/ # Blog: http://blog.remirepo.net/ # ...

Nagios php script to read iostat values

I'm working on a php script(nagios plugin) to read r/s,w/s,rMB/s,wMB/s,%util from the iostat command, e.g. #iostat -xm sda avg-cpu: %user %nice %system %iowait %steal %idle 1.05 0....

Check microphone level and change accordingly via script

I am trying to check what the existing volume on client workstations is and set to x (let's say x = 16.5). I figured out how to set the volume via cli which is using nircmd. To be specific: nircmd....

TrimStart() improperly truncates string

I wrote a script to backup bitlocker keys to Active Directory. The works great unless the Password ID starts with 'D'. Here is script #Get recovery info $recoveryinfo = manage-bde -protectors -get c: ...

gae app displays differently depending on location?

We deployed a webapp with user-generated images which rotates like a "carousel". Now after a few updates the old carousel still rotates from my view but the new doesn't. My partner who is in India ...

Script does not work in cron [duplicate]

i have written script, that check process avaliability. So. The text of my script. #!/bin/bash export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" tool="pidof" service="nginx"...

batch script to download office 2016 install files

Writing a powershell script to run via my RMM agent that will copy Office 2016 Deployment Tool from my server to theirs then try to run the initial download to help ease my deployment process. These ...

Entering local admin username and password in a script

I have alot of clients on my network and I want my script to do the following: [1] Open an elevated command prompt using the local admin details. Note: I do not want to have to enter a username ...

Bash script aborting after defining lsb functions

I'm currently trying to get a script to work, which needs to define some LSB functions. This is happening here: echo "step 1" # Read configuration variable file if it is present [ -r /etc/default/$...

std output and error from functions

Is there a way to get the standard output and estandard error from the functions inside a bash script? This is what "I thought" I was trying to accomplish with my script: #!/bin/bash LOGS="tmp/sync....

Query Powershell Error Object Time Occured

Powershell error objects contain a lot of data but I can't seem to track down the time of occurrence for a given error. Using $Error[0] | fl -f retrieves a lot of information but none that appears to ...

Find old files in directory

I'm writing backup rotation script, that suppose to take all files older then 5 days and delete them. Problem is that i've got some weird search results. for example: [root@spr1-nas01 storage]# date ...

logrotate when size reaches 10M

Please kindly advise/assist. I want to set up logrotate that does the following: when the log file size reaches 10M,the file is rotated and also there is no keeping of older compressed log files. I ...
Translating... 0%