Questions tagged [scripting]
A form of computer programming that — in the context of system administration — lends it self well to automating tasks.
1,836
questions
0
votes
2
answers
5k
views
Check Windows registry to see if host is joined to an Azure AD domain?
On a Windows PC joined to a 'traditional' Active Directory domain, querying Win32_ComputerSystem or Win32_NTDomain returns the domain name.
On Azure anything [joined], those classes return nothing.
...
0
votes
1
answer
551
views
PowerShell, Active Directory Get-object issue
I have been tasked to create a list of members of a custom object/custom attribute in Active Directory. I felt the best way to do so is use PowerShell. I can list the objects in a specific OU, but I ...
0
votes
0
answers
298
views
C# API Get Request with Basic Authentication - Server is Returning (403) Forbidden
I'm attempting to make a connection to an API endpoint. I'm getting (403) Forbidden. I was hoping someone could help me figure out what I'm doing wrong with this. Here's my code:
using System;
using ...
0
votes
1
answer
162
views
Nagios BAT file not returning correct status code
I've written a batch file for a Windows server to detect whether a particular service is running and if it isn't, return a Critical status back to Nagios. The script works perfectly (as in, it can ...
1
vote
1
answer
887
views
Linux script , Incremental backup in the same server
Could you please someone guide for the below incremental backup script, i have already written the script. I am facing an issue while looping the script.
Requirement i need : Consider a source folder ...
1
vote
0
answers
232
views
How can I escape the "|" in file names in a bash script?
I have a list of files in the Linux file system. Some of them contains a "|" in the names.
How can I escape the "|" in a bash script to perform file operation (copy, move) in the ...
1
vote
2
answers
1k
views
Bash script to configure IPTABLES
I am beginner at BASH scripting, I'm trying to write script to configure iptables but it seems something wrong in the first block, Please advise
#!/bin/bash
echo "IPTABLE ASSIGNMEN"
echo -e &...
1
vote
1
answer
277
views
Powershell script credentials prompt appears before read-host executes
I'm calling a script inside another script:
...
...
powershell C:/temp/script2.ps1"
...
...
That joins a VM to a domain after downloading some things. However, when the script runs, the prompt ...
0
votes
1
answer
2k
views
Retrieving Active Directory Users with no Email address from a certain group in powershell
I'm trying in powershell to output all AD users from a certain group with no data in the email address field.
I have the following command:
get-aduser -filter * -properties * | where {!$_.emailaddress}...
0
votes
0
answers
58
views
Email admin scripts
I have been working on scripts to help me administer email servers.
This works pretty well on Postix/Debian server to search logs for sent emails.
You can even use grep to search the reasults ie. /...
0
votes
0
answers
31
views
login to remote Win10 and retrieve file
Currently doing a manual daily backup of certain files, tars and zips, from a number of Win10 boxes to a master Win10 box. Backups are done by RDP - copy - paste. There has to be a way to script ...
0
votes
1
answer
4k
views
PowerShell - List WSUS Updates Needed for Each Client
I need to provide a monthly report to our client listing the updates needed by each Windows server in our environment. Ideally, the report would list the updates for the month and the servers in my ...
0
votes
1
answer
712
views
Failing string replacement in xargs command
I am trying to automatically create symlinks to directories and to replace a certain text string (foo) of the original name in the link name (bar). The name of the target directories may contain ...
-2
votes
2
answers
913
views
what the meaning of #!/usr/bin/php -q
I look at some php script in centos,I notice there is #!/usr/bin/php -q
What is the meaning of this option? because I cannot see it in php --help
0
votes
0
answers
1k
views
How to pass multiple arguments through ssh and use those arguments in the ssh script?
I have written one script on lets say server1 and from that script I want to execute script Start_UI_AdminApp.sh on server2 through ssh. I also need to pass the arguments while executing this ssh ...
1
vote
2
answers
881
views
Windows Equivalent to `sha256sum -c` (cryptographic hash, digest file, recursive integrity check, SHA256SUMS)
What is the equivalent to sha256sum -c in Windows?
I have a set of very important files that I need to copy-to and mirror across many different types of disks in many geographically distinct locations....
0
votes
1
answer
6k
views
How can I set the 'The other domain supports Kerberos AES Encryption' setting programmatically?
In the GUI (Active Directory Domains and Trusts MMC Snap-in (domain.msc)), you can set the "The other domain supports Kerberos AES Encryption" setting for a trust relationship:
I am looking ...
0
votes
1
answer
487
views
Continue statement doesn't work as it should - bash
For the context, i have an infrastructure of multiple machines using ssh.
We connect via ssh as root on the machines without password thank's to the authorized_keys file on each mchine. We are adding ...
0
votes
1
answer
419
views
Ansible; add hosts to inventory by script
I just started working with/learning to use Ansible.
I want to add hosts to an inventory file using a script, and I am wondering if there is a command line tool to accomplish that.
Something that ...
0
votes
1
answer
2k
views
CMD - Check if exist firewall rule, and add if not
I need some help to make an script that check if exist a rule, and add if not.
It auto add all exe inside a folder where i run it.
@echo off
cls
Echo.--------------------------------------------------...
0
votes
1
answer
365
views
only flush the write cache if there's no read activity
Normally the Linux Kernel flushes the write cache if a specified time limit is exeeded or the cache is full. This leads to stalling with HDDs since the writing process makes reading processes much ...
-1
votes
2
answers
82
views
how to automate servers installation with virtualization/LAMP (small IaC)?
How to automate server installation? What infrastructure/systems fit our needs?
We have over 10 phisical servers with over 100 VMs, mostly LAMP. Not too many but also not anything that can keep ...
3
votes
3
answers
2k
views
How to script a check that the key in known_hosts file is correct
I would like to implement a function in a script that checks if the key that corresponds to a given host in known_hosts file is correct. The obvious way to do this is to attempt an ssh connection and ...
0
votes
0
answers
229
views
Running ps command with 'Irix mode' off
I know that within the interactive 'top' screen, I can press 'Shift + i' to turn off 'Irix mode'
Is there a way to do the same thing with 'ps' command?
I am trying the below mini script to print out ...
0
votes
1
answer
597
views
how to use BASH to convert the path to the home folder in the variable bash, in quotation marks into a working one
Use the script, I am trying to create a directory in my home folder. Due to the specifics of integration with terraforms, parameters are passed in this way:
variable = "value"
It would be ...
0
votes
1
answer
577
views
How to convert BASH script to DASH or other solutions?
I am creating an AWS distributor package to modify the syslog configuration on different flavors of Linux servers. I wrote a few simple bash scripts to handle the install, uninstall, and update. I ...
1
vote
0
answers
693
views
How to export the details of a digital certificate (.cer file) to a csv file using powershell?
I have a digital certificate that I'm using for a specific task. I need to export the details of the certificate such as the serial number and issuer to a csv file that is already on my computer using ...
0
votes
2
answers
757
views
write shell script or other script on vCenter
esxcli is existed on vSphere. But I need to write script on vCenter and vCenter doesn't have esxcli command.
How can I write script for vCenter?
-1
votes
1
answer
4k
views
Handle exception with long paths in Powershell
I am new here and I facing issues with my powershell script whith long paths.
This script aims to get relative path and hash from files/folders and its subfolders. It works with some with others I get ...
0
votes
1
answer
176
views
Remote deployment of a script on linux
We are creating a lab and wanted to setup like 10-15 hosts with ldap. We need to install on each computer some packages that are necessary to run ldap, so my question is - can I somehow run 1 bash ...
1
vote
1
answer
118
views
weird behaviour in a Windows 2019 .BAT script
I have to restore a backup from a Linux MariaDB to a Windows MariaDB, where the PowerBI gateway will import its data. "mariabackup" is MariaDB's physical backup tool. But to restore it, the ...
2
votes
2
answers
11k
views
Curl Command Send Asynchronous Request
I using this curl request for sending data to API :
curl --location --request POST 'MY_IP' \
--header 'Content-Type: text/plain' \
--data-raw ' [{
"event_id": "123",
}]
'
...
0
votes
0
answers
223
views
Is there a way to add a comment to a DHCP dynamic simple queue?
I simply want to add a comment (specifically, add the host name) to the simple queues created by the DHCP rate limit option.
However, while scripting, when I tried the command
/queue simple set dhcp-...
0
votes
1
answer
1k
views
whats the diffrence between "command.sh > /dev/null 2>&1" vs "command.sh 2>&1 >/dev/null"
I have many shell and python scripts on my crontab that ending either with:
command.sh > /dev/null 2>&1
or
command.sh 2>&1 >/dev/null
I know that:
> is for redirect
/dev/...
-1
votes
2
answers
1k
views
Find file duplicates and convert them into links [WINDOWS] [closed]
My users tend to save tons of duplicate files what consumes more and more space and generate HW and archiving cost.
Im thinking to create some scheduled job, to:
find duplicate files (check file MD5 ...
0
votes
0
answers
343
views
Alternative location to store tmp files on linux
So I have a python script that I compile with pyinstaller to a single file. at the time of running, by default, the script will unbundle the modules in /tmp/ also you can change the default TMPDIR at ...
0
votes
2
answers
270
views
PowerShell: Why am I getting this error?
I am trying to use the PowerShell Invoke command. I am using it correct but I don't know why I am getting an error.
Invoke-Command Get-EventLog –LogName Security –Newest 100 -ComputerName WIN-...
0
votes
0
answers
114
views
How to merge two data sources with slightly different folder names
How can I copy all .msg files that are spread throughout some GUID sub-folders in one folder to another folder that has a slightly different folder name at the end. Is it possible?
So for example:
...
2
votes
1
answer
6k
views
Not able to access groovy variable inside shell script in JenkinsFile
def NAMESPACE = "Dev"
def BODY= sh(
script:'''body=$(cat <<-EOF
{
"name": "${NAMESPACE}",
"type": "regularwebapp"
}
EOF
)
(echo $body)''...
-1
votes
1
answer
2k
views
Programatically get full path to binary in powershell (which, where, Get-Command)
How do I get the absolute path to a given binary and store it to a variable?
What is the equivalent to the following for Linux Bash in Windows Powershell?
user@disp985:~$ path=`which gpg`
user@disp985:...
0
votes
1
answer
233
views
command that cannot work in background (asterisk)
am trying to run script in background which contain command such like "asterisk -rvd >> xyz.log", when I run it directly it work well but when run it with any background way (service, ...
0
votes
1
answer
427
views
Domain users last logon time on a specific (domain joined) computer
So I have all the once_logged_in profiles listed in C:\Users folder but I need to find out when was the last time these users logged in onto the same computer locally or remotely with their domain ...
0
votes
1
answer
426
views
I Have a problems with qoutes in my bash script [closed]
how to do so that in this script which searches for something from the database. he searched for it and changed its name in the terminal.
I have a problem with the quotes here.
Maybe anyone know how ...
0
votes
2
answers
549
views
How to setup a daily report of users which are sending more than a defined numer of email outside organization within 24h
I'm trying to create a script and schedule it on exchange in order to have a daily report for users which are sending more than a defined numer of email outside organization within 24h.
I found this ...
0
votes
1
answer
4k
views
How to select using script on Task Scheduler the "run with highest privileges"
Hi I'm doing some scripting to add a task on a Task Scheduler. However I need to have a script to select the "run with highest privileges".
Sample code:
Dim settings
Set settings = ...
0
votes
1
answer
645
views
Restart services on multiple remote servers securely
I need to write a script so that my colleagues and myself can restart different services on multiple servers. We all connect to the servers with LDAP so i'd like my script to connect our LDAP users to ...
1
vote
0
answers
3k
views
Powershell Script setting WMI CIMV2 Permissions
I am currently trying do change up a script so that I can put it into a GPO. The Script itself works but I want to do a "if else" around it.
The Script is found here: https://gist.github.com/...
0
votes
2
answers
397
views
Awk script to filter text output to single line
I have a script that is giving me an output like this:
ruby-devel is needed by software1
tcl is needed by software 2
python3 is needed by software 3
ocaml is needed by software 1
I'm new to awk but ...
1
vote
2
answers
30k
views
Script not running on startup for GPO
I have seen many posts on this website about something similar but none of them have had the resources to fix my issue so I will go into as much detail as I can. If I leave any information out let me ...
1
vote
1
answer
694
views
Anyone know of a script, program, etc... to check folder/file permissions and repair/restore?
I am not a newb. I am a professional imploring to other professionals over their discoveries of a quick solution to a common problem, and I know what chmod -R is.
This is in response to the -1 rating ...