Newest scripting Questions

Q&A for system and network administrators

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 ...

Apache perl script plain text output

Can anyone suggest why my perl script is rendering as plain text: #!/usr/bin/perl use FindBin; BEGIN { lib->import($FindBin::Bin) unless $ENV{mod_perl} } require 'lsmb-request.pl'; My Directory ...

Store PS command output to variable and Invoke-Command

I need to store command output to pass it as variable in function later #This works [scriptblock]$command = {Get-EventLog system -newest 1 | Format-List} $command.Invoke() But when I try to Write-...

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 ...

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 ...

windows executable and extract data from file

On my CD-ROM I have this file: ip.txt which has the content: ip="192.168.1.1" netmask="255.255.255.0" gateway="123.456.789.2" How can I extract from ip.txt the IP, netmask and gw and use as command ...

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 ...

whoami /priv for another user

Is there a way to see the privileges for any (local or domain) user in Windows ? whoami /priv works for the current user. Not clear from the docs: https://technet.microsoft.com/en-us/library/cc771299(...

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/ # ...

Using Powershell to set SMTP port on an existing IIS 6 SMTP Server - Windows Server 2012 R2

Background I have a requirement to restore a snapshot of a server daily into a testing environment, once restored, it is necessary to update numerous bits of configuration to make it a test ...

Execute script when new email arrives (Postfix / Dovecot)

I want to execute a backup script (.sh) when I receive a new mail on my mailserver (running on Debian with Postfix / Dovecot). I've found many posts on this topic, but no one give me a working ...

rake task in upstart service

I am failing at making the Sphinx daemon run automatically at boot. When I do it manually it does work (and this is what I am trying to reproduce in my upstart script): I log in as deploy user cd ...

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() -...

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 get a list of Domain Admin users from a windows 2003 DC

I'm trying to get a list of domain admin users from my Windows Server 2003 domain controller. I am unable to obtain it with powershell because the ActiveDirectory module is not installed. I need to ...

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: ...

bash script to detect when a file is added to folder and command exec

I am trying to write a script to detect whenever a file is added to a specific folder and run a command using the last file added name. What I am specifically trying to do is to create a QR code for ...

Changing root password via script fails but reports success

I have a project which requires me to make a script / sequence of commands to change the root password on a CentOS 7 installation. I can assume the user that will be executing the script is already ...

How to create a script for Exchange Powershell to modify settings for all shared mailboxes?

Following this guide: https://blogs.technet.microsoft.com/exchange/2015/03/03/want-more-control-over-sent-items-when-using-shared-mailboxes/ I must issue these commands in Exchange Powershell (...

Exchange 2013 script to copy email from a users inbox for a specific date range?

Client Mailbox Exchange 2013 Microsoft Scripting Looking for a script that will accomplish the following task. Copy all email from a user’s mailbox that meets a specific date. The copy script should ...

Export Windows Registry for Services

I have a process that I want to automate, I have tried doing some digging but I can't find a way to do it, as I am not a heavy scripter. Here it goes: I want to have a script of some sort, that will ...

Why fgets does not return value? [migrated]

I run ping to server for every 2 seconds. Sometimes I do plug out/in cable, and that for random sequence freezes fgets. Therefore it breaks whole cycle. Is there any option to assign a timeout? any ...

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 ...

Running Exchange Powershell script from a batch file: command doesn't work. What's wrong with my syntax?

Coming from this question here: How to create a script for Exchange Powershell to modify settings for all shared mailboxes? Here is my Powershell script (scroll right to see all): $Mailboxes = Get-...

Save into file git fetch terminal output [migrated]

I have tried several ways to save into a log file 'git fetch output' from terminal, through a bash file but without success, like, git fetch origin > output.log or even adding output.log in the ...

Running script on instance that is created from AWS snapshot

I've a AMI that I'd like to launch more instances based on this. But seems when I create instance based on this images, it doesn't boot-up. So the scripts that I would like to run on startup doesn't ...

powershell: how to print command to file?

I'm currently using the Out-File cmdlet, like so: PS> Some-Cmdlet -someswitch | Out-File -filepath .\somefile.txt It works great. Is there anyway that I can actually get the command line itself ...

How to script downloading file from remote host

In remote server, there are always a pair of files like:- in folder /Pair1 IN_S-WW001_20160418100715.out IN_S-WW001_20160418100715.txt in folder /Pair2 ar.MON.20160226.output.ZZ.out ar.MON....

how to use windows printing_admin_scripts independent of system language

The windows "printing_admin_scripts" are located in the %WINDIR%\System32\Printing_Admin_Scripts\<language> directory While %WINDIR% is defined within the windows SET variables, the value of &...

Pure Perl RPM Version checker

I have a machine located in a secure environment that does not have access to the internet. I has a base load of CentOS with a handful of additional RPMs. This includes a basic install of PERL with ...

How to use wget in an Expect script?

I first download a file to /root/TRY1/: #!/usr/bin/expect cd /root/TRY1/ exec wget --http-user $user --http-password $password $url Then I want to extract the file: cd /root/TRY1/ exec bash -c "tar ...

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 ...

Powershell: a simple script to take a list of commands and append the same cmdlet every time [closed]

I have a list of commands I run in a script like this Some-Cmdlet -someswitch | Outfile -filepath .\somefile.txt -append Another-Cmdlet -someswitch | Out-File -filepath .\somefile.txt -append Hello-...

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....

Script to auto-update bind hostname

I'm looking for a script that can run as a CGI script that will take a specific request (another script running from a cron job, presumably a wget request with credentials) that will update a hostname ...

How to check if a specific list of user accounts are disabled in AD, using powershell v2.0 or CMD / VBS

1) I have a txt list with sAMAaccountNames 2) I need to query each account name and verify whether it is disabled 3) if the account is disabled, delete it from AD I'll just delete them manually if ...

Script to search bots from log file

I have a little log-file, where i should find the bots. File: Friday, 10 October 2012 13:15:39 +0300|192.168.110.5|rock| - |user has made auth in| - Friday, 10 October 2012 13:15:39 +0300|192.168....

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 ...

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\...

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 ...

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 to use sed to replace text with special characters.

I currently have a script that generates random words to create passwords. I run this by selecting the script and letting it know how many words I want .e.g ./generate_passwords.sh 5. This creates ...

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 ...

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 ...

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 "...

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 /...

Need leading zero for batch script for time before 10am [duplicate]

I came across a bug in my script Anytime before 10am two folders are created (check image link) - one with the date and one with the time. After 10am only one folder. Any ideas how to add an extra 0 ...

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 ...

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 ...

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 ...
Translating... 0%