Scripting Languages

26K

Solutions

20K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

Share tech news, updates, or what's on your mind.

Sign up to Post

This script gets the services on a set of systems, and returns the service name, 'logon as' and server it is on, then exports it to a csv file. This works fine.
I tried adding a where-object to it to remove "local System"  "Network Service" "LocalSystem" any by themselves do nothing, with a -or also does nothing. My attempts have been in vain, is there an easy way to filter out the chaf?
$datetime = (get-date -f yyyy-MM-dd-HH-mm)
Get-Content systems.txt| Foreach-object  {
  Write-Host "Retrieving Servers for $_ "    
  Get-WmiObject win32_service -ComputerName $_  | select Name,
  @{N="Service Account";E={$_.StartName}},
  @{N="System Name";E={$_.Systemname}}}|where-object { $_.StartName -notlike "LocalSystem"} |export-csv -path  D:\path\$datetime-Services.csv -nti

Open in new window

0
Free Tool: Site Down Detector
LVL 9
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Can you recommend any resources/tutorials to learn Autosys R11? I have to learn how to create autosys jobs including jil files.
0
Hello -

I am trying to uninstall Symantec Endpoint Protection and replace with new AV within SCCM 2012. I have the install application for Symantec and new AV. The Symantec application should have a uninstall switch, however not sure how to double check that with .exe I have for Symantec. I have tried to run uninstall of Symantec with Uninstall.exe however no luck. I have also tried to run a batch file from my desktop with wmic product where "name like 'Symantec Endpoint Protection%'" call uninstall /nointeractive, however no luck.
0
Hi All,

Greetings...

According to my work, I need to zip files present in a folder using batch script without using any 3rd party software.

I tried with below code ,but getting the error.error also attached below.

Any help regarding this would be highly appreciated.
'Get command-line arguments.
Set objArgs = WScript.Arguments
Set FS = CreateObject("Scripting.FileSystemObject")
InputFolder = FS.GetAbsolutePathName(objArgs(0))
ZipFile = FS.GetAbsolutePathName(objArgs(1))

'Create empty ZIP file.
CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)

Set objShell = CreateObject("Shell.Application")

Set source = objShell.NameSpace(InputFolder).Items

objShell.NameSpace(ZipFile).CopyHere(source)

'Required!
wScript.Sleep 2000

Open in new window


This code is present in zip.vbs file. We have to zip the files into Outputfile.zip file.
in command prompt  , I have entered below command

C:\Users\abc>Cscript zip.vbs input path  output path\OutputFile.zip

While executing this ,I got below error. " Path not found error" for both the input and output file path.

It will be helpful if anyone corrects me the mistake which I made in this script.
2
i'll need a Shell script that scans thru creation dates of all patches (ideally only the security ones but
if this is not possible, then all patches) installed in an RHEL 7 server, get the latest one, compute
the difference from today's date & give the difference in number of days & if the difference is
more than 90 days, echo out a message, "It has been more than 90 days since last patch)

Purpose is to check the last patch date & remind Linux admins.  Believe RHEL releases patches
at least every 3 monthly?
0
I have a simple script to check up down of ips. I have it displaying the way I would like, I would also like to save all of those up/downs to a text file. ( I have to send the results to someone else.) When I try to pipe it after the write-hosts are done, I get "An empty pipe element..."
Is there a simple way to get both?

Get-content c:\path\names.txt | %{
	If (Test-Connection $_ -Quiet -Count 2){
	write-host -foregroundcolor black -backgroundcolor green "$_ is UP"
	}
	Else{
	write-host -foregroundcolor black -backgroundcolor red "$_ is Down"
	}
}
|Out-File c:\path\result.txt

Open in new window

Thanks!
0
Dear,
I have to copy 2 files containted in one folder to dynamic set of sub folder.
Let's say
files are stored in c:\template
Destination folders are c:\Documents\A .......; c:\Documents\Z

I want the 2 files into all subfolders of c:\Documents
I have this but seems not working...


Get-ChildItem -Path c:\template | ?{ $_.PSIsContainer } | Copy-Item c:\documents $_.fullname
0
So I have this script, but when I run it, it's not working, it doesn't delete the files.
So I had someone write this for me, and it's supposed to keep 150 files, and delete the files from the directory listed, and delete all etl files. Am I missing something?


@echo off (need to change the below to the locations needed and file types)

call :delolder 150 "E:\ms\Output_On_08-10-2017__Time_17-12-31PM" "etl"
exit /b

:delolder
set type=%~3
set thedir=%~2
set keep=%~1
for /f "delims=" %%D in ('dir "%thedir%" /ad /b /s') do (
  echo Working on dir %%~fD
  for /F "skip=%keep% delims=" %%a in ('dir "%%~fD\*.%type%" /a-d /o-d /b 2^>NUL') do DEL "%%~D\%%~a"
)
echo Working on root dir %thedir%
for /F "skip=%keep% tokens=* delims=" %%a in ('dir "%thedir%\*.%type%" /a-d /o-d /b 2^>NUL') do if "%%~nxa" NEQ "%~nx0" DEL "%thedir%\%%~a"
exit /b

Open in new window

0
I have a roadblock where I could not bypass the Banner message appears while connecting over RDP...

$Server = 'Server1'
$wshell = New-Object -ComObject WScript.Shell
$wshell.run("Mstsc")
Start-Sleep 1
$wshell.AppActivate("Remote Desktop Connection")
$wshell.sendkeys("$Server")
$wshell.sendkeys("{ENTER}")
sleep 30 ----------------------------------------->>>> at this stage, I can see it is connected to remote server and banner message is being shown.
$wshell.AppActivate("Server1 - Remote Desktop Connection")
$wshell.sendkeys("{ENTER}")

I have tried all the modules/functions found over google but did not help...  when I try the same thing through WinAutomation and Devolutions Remote Desktop Manager, it is working fine.. any clue why and any solution ?
0
There is  a form with "post" that in the action it says:

(I run it with get and the line reads http://domain.com/test/?(variables))

http://domain.com/test

It doesn't specify the script that takes the form data to process and returns a result

I dont know in what language it is programmed in

I tried index.php (domain.com/test/index.php

the same for index.asp, default.php and default.asp but those scripts dont exist in the server.

I use chrome developers tools but it only returns  (index) which could be anything

Any ideas?
0
On Demand Webinar: Networking for the Cloud Era
LVL 9
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Is it possible to block a state via htacess?  Hypothetical, I am not allowed to business in CA so I want to block the state of CA?
Are there instructions on how to block all countries except the USA via htaccess?
0
Is it possible to write a script / powershell to

1. Unlock the bitlock portable driive and save files/folders into it
2. lock the bitlock portable
3. send email to inform the completion.

The folder is created with multi-language (not pure English). Alternatively, any free tools will also be considered.

Thx
0
I have a script that is not working, perhaps I'm doing something wrong.
So I've changed the variables below, but it's not actually deleting the files.
Any ideas what I'm doing wrong?


@echo off (need to change the below to the locations needed and file types)

call :delolder 7 "E:\mailflow backups" "*"
exit /b

:delolder
set type=%~3
set thedir=%~2
set keep=%~1
for /f "delims=" %%D in ('dir "%thedir%" /ad /b /s') do (
  echo Working on dir %%~fD
  for /F "skip=%keep% delims=" %%a in ('dir "%%~fD\*.%type%" /a-d /o-d /b 2^>NUL') do DEL "%%~D\%%~a"
)
echo Working on root dir %thedir%
for /F "skip=%keep% tokens=* delims=" %%a in ('dir "%thedir%\*.%type%" /a-d /o-d /b 2^>NUL') do if "%%~nxa" NEQ "%~nx0" DEL "%thedir%\%%~a"
exit /b
0
I had this question after viewing Modifying PowerShell to list some Event logs with certain username ?.

People,

I wonder if it is possible to modify the below PowerShell script to dump all information from the Event ID 4625 ?

The below script was created by one of the experts here but it is just for Event ID 4624.

$LogonType = @{
	[uint32]2 = 'Interactive'
	[uint32]3 = 'Network'
	[uint32]4 = 'Batch'
	[uint32]5 = 'Service'
	[uint32]7 = 'Unlock'
	[uint32]8 = 'NetworkCleartext'
	[uint32]9 = 'NewCredentials'
	[uint32]10 = 'RemoteInteractive'
	[uint32]11 = 'CachedInteractive'
}

Get-ADComputer -LDAPFilter "(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=8192))" | ForEach-Object {
    "Processing $($_.DNSHostName) ..." | Write-Host
	Get-WinEvent -ComputerName $_.Name -FilterHashTable @{LogName="Security"; ID=4625; Data="FirstName.LastName"} -MaxEvents 100 | ForEach-Object {
		New-Object PSObject -Property ([ordered]@{
			MachineName = $_.MachineName
			TimeCreated = $_.TimeCreated
			User = $_.Properties[5].Value
			Domain = $_.Properties[6].Value
			LogonType = $_.Properties[8].Value
			LogonTypeString = $LogonType[$_.Properties[8].Value]
			SourceIP = $_.Properties[18].Value
			SourceName = (Resolve-DnsName -Name $_.Properties[18].Value -ErrorAction SilentlyContinue).NameHost
			Keywords = $_.KeywordsDisplayNames -join ";"
		})
	}
} | Export-Csv -Path C:\TEMP\User-LockedOutSource.csv -NoTypeInformation -UseCulture

Open in new window


More Information about Event ID: 4625: https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventID=4625
0
People,

I need some help to query all domain controller for certain Security Event ID like: 4740, 4771 and 4776.
My goal is to know which location of the Locked AD account.

This is the script that I have and been working:
$LogonType = @{
	[uint32]2 = 'Interactive'
	[uint32]3 = 'Network'
	[uint32]4 = 'Batch'
	[uint32]5 = 'Service'
	[uint32]7 = 'Unlock'
	[uint32]8 = 'NetworkCleartext'
	[uint32]9 = 'NewCredentials'
	[uint32]10 = 'RemoteInteractive'
	[uint32]11 = 'CachedInteractive'
}
Get-ADComputer -LDAPFilter "(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=8192))" | ForEach-Object {
    "Processing $($_.DNSHostName) ..." | Write-Host
	Get-WinEvent -ComputerName $_.Name -FilterHashTable @{LogName="Security"; ID=4624; Data="John.Wick"} -MaxEvents 200 | ForEach-Object {
		New-Object PSObject -Property ([ordered]@{
			MachineName = $_.MachineName
			TimeCreated = $_.TimeCreated
			User = $_.Properties[5].Value
			Domain = $_.Properties[6].Value
			LogonType = $_.Properties[8].Value
			LogonTypeString = $LogonType[$_.Properties[8].Value]
			SourceIP = $_.Properties[18].Value
			SourceName = (Resolve-DnsName -Name $_.Properties[18].Value -ErrorAction SilentlyContinue).NameHost
			Keywords = $_.KeywordsDisplayNames -join ";"
		})
	}
} | Export-Csv -Path C:\TEMP\John.csv -NoTypeInformation -UseCulture

Open in new window


and this is the second PowerShell script:

get-eventlog -logname "security" | where {($_.eventID -eq 4771) -or ($_.eventID -eq 4776) -or ($_.eventID -eq 4625) } | select timegenerated,message

Open in new window


Any help would be greatly appreciated.
0
Hello it is possible download with wget a site with a href links?

For example we have an index,html that has only a list of a href links:

<p><a href="http://xxx.xxx.xxx/list.html">list 1</a></p>
<p><a href="http://xxx.xxx.xxx/list2.html">list 2</a></p>
.
.
.

Open in new window


Like that the index.html has a lot of a href.

Now the question is possible download all that index.html a href?
Also is considering for example the destinations list.html, list2.html,... are web pages with different elements, images etc.

We tried to use httrack and just download the index.html
and also we tried:

wget --convert-links -r http://xxx.xxx.xxx/index.html

Open in new window


and the same just download the index.html.

Any ideas?
0
So long story short I think it MAY have something to do with my shebang in my python. I know on our server we have a few different versions of Python and I installed my modules (paramiko and pysftp) in the correct place I believe. Honestly I have researched and am having trouble understanding how exactly the shebang works and knowing what interpreter it is pulling from or why the cron job is failing for that script (is there a log file perhaps to help determine the cause?)

Cron listing:
* * * * * /usr/local/mlb_cdt_download_newv2.py > /dev/null 2>&1
(Yes for testing purposes I am trying to have it run every minute just to see if it runs)

Script:
#!/usr/local/lib/python2.7
import os
import pysftp
import os.path
import paramiko

HOST=""
USER=""
PASSWORD=""
SUFFIX_TO_FETCH__AND_DELETE=".csv"
DESTINATION_PATH="/mnt/sas/ftp_mlb"

srv = pysftp.Connection(host=HOST, username=USER, password=PASSWORD)

def do_nothing(fname):
        return  " "

def fetch_and_remove(fname):
    if not fname.endswith(SUFFIX_TO_FETCH__AND_DELETE):
        return # skip files with wrong suffix
    dst_fname = os.path.join(DESTINATION_PATH, fname)
    dst_dirname = os.path.dirname(dst_fname)
    if os.path.isfile(dst_fname):
        return " "
    else:
        srv.get(fname, dst_fname)
        srv.remove(fname)

srv.walktree('.', fetch_and_remove, do_nothing, do_nothing)

srv.close()

Open in new window


For the record, running this script from the commando line works instantly and perfectly. But when trying to automate it through the cron I have no luck.

Any help trying to understand which interpreter my cron is trying to use and the location of such would be greatly appreciated.
0
Please provide me with a command line or powershell command I can use to set a static IP address on a Windows computer.

IP address: 10.10.10.225
Subnet Mask: 255.255.255.0
Default Gateway: 10.10.10.250

DNS address: 75.75.75.75
Secondary DNS address: 75.75.76.76
0
Hi,

Any idea why the following is not ignoring hidden rows? I've tried ".hidden", ."SpecialCells(xlVisible)". Nothing seems to work.

Sub CountOffSpecs(sheet, col, status, row_)
    Dim i As Long
    Dim LastRow As Long
    Dim rarray() As Variant, dict As Object
    Dim v As Variant
    ReDim Preserve rarray(0 To 1)
    t = 0
    Set dict = CreateObject("Scripting.Dictionary")
    LastRow = sheet.Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To LastRow
        If InStr(1, sheet.Cells(i, status), "|") And Cells(i, status).EntireRow.Hidden = False Then
            resarray = Split(sheet.Cells(i, status), "|")
            lNumElements = UBound(resarray) - LBound(resarray)
            For l = 0 To lNumElements
                ReDim Preserve rarray(LBound(rarray) To UBound(rarray) + lNumElements)
                rarray(UBound(rarray)) = resarray(l)
            Next l
        ElseIf sheet.Cells(i, status) <> "" And Not InStr(1, sheet.Cells(i, status), "|") And Cells(i, status).EntireRow.Hidden = False Then
            resarray = sheet.Cells(i, status)
            ReDim Preserve rarray(LBound(rarray) To UBound(rarray) + 1)
            rarray(UBound(rarray)) = resarray
        Else
            'nothing
        End If
    Next i
    
    For m = LBound(rarray) To UBound(rarray)
        If dict.exists(rarray(m)) Then
            dict.Item(rarray(m)) = dict.Item(rarray(m)) + 1
        Else
            dict.Add rarray(m), 1
        End If
    Next m
    
    a = 1
    

Open in new window

0
Optimize your web performance
LVL 1
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

I am looking for few things to be automated in AD- through script or any other better available solution

1.To Send email notification after AD user creation
2. To send reminder Email on password expiry  (before 1 Day, 10 Day's, 20 Day's)
3. Generate password automatically  and then send it on email

Thanks in Advance for prompt support .
0
Hey Scripting Guys, how can i list all the duplicate files in a folder and sub folder with there file name, paths and size. I have couple of million files on a E drive of a windows server 2008.
For audit reasons, I cannot delete the original file however duplicate can be deleted. my plan is to move those files to external tape for a backup for next few months to avoid any issue.
 
So, part 1 - finding duplicate files ( file can have same name or same name with date as for example text01011992, problem is the same file can be saved by the user with multiple name ...hence need a wild card to handle this) and finally, exporting the data into csv or excel

Part 2- deleting them

Rule - part 1 and 2 can't be merged.

so far - i have below script
ls *.* -recurse | get-filehash | group -property hash | where { $_.count -gt 1 } | % { $_.group | select -skip 1 } | echo
ls *.* -recurse | get-filehash | group -property hash | where { $_.count -gt 1 } | % { $_.group | select -skip 1 } | del
0
Hi,

I am using Jupiter to write a read csv line.

So far,I wrote>>

(1)      import pandas as pd
(2)      pd.read_csv('C:/Users/USER1/Documents/Exports/ItemStatus.csv', sep=',')

but its giving me error. See text file. What I need to change to make this work…
python-read-error.txt
0
Greeting Experts,

I have a script that works w/o any problems as is but I need to add an email function that will allow it to send email in the event a website is not blocked. The way the script works (see below) is checked to see if status code of each site ( i.e. -eq 200) and checks to see if can be reached or not. Verify if our content controls are working or not. If it's blocked, then it will come back with "Site it blocked: URL, " or if not blocked then you will get "Site is not blocked at this time: URL."   I am looking to add an email function to the script to alert me and others in the case a site pops up as not blocked. Can somebody help me update this text ... thanks

$objXmlHttp = New-Object -ComObject MSXML2.ServerXMLHTTP
$URLlist = Get-Content "C:\FileLocation\List.txt"
Foreach($url in $URLList) {
    $objXmlHttp.Open("GET", $url, $False)
    $objXmlHttp.Send()
    $content = $objXmlHttp.responseText
    $status = $objXmlHttp.status
    $statustext =$objXmlHttp.statusText
    if ($status -eq 200) { 
        Write-Host "Site is Not blocked at this Time: $URL" 
    }
    else {
        Write-Host "Site is blocked: $URL "
    }
}

Open in new window



Output from Script:

Site is blocked: http://www.playboy.com 
Site is blocked: http://www.gambling.com 
Site is blocked: http://www.zob.com
Site is blocked: http://www.gmail.com
Site is blocked: http://www.dropbox.com
Site is blocked: http://www.facebook.com
Site is blocked: http://www.Twitter.com
Site is blocked: http://www.snapchat.com
Site is Not blocked at this Time: http://www.skydrive.com
Site is Not blocked at this Time: http://www.hotmail.com
Site is Not blocked at this Time: http://www.outlook.com

Open in new window

0
I want to import a huge number of very small text files (content is 1 line per file) parse the line and convert it to another text file using delphi. Using the simplest assign(f) etc approach will take several weeks to execute. The bottleneck might probably be the opening/closing of each file. Is there any other way of doing this a lot faster?  maybe using another scripting language? which one?
0
Every month  we wud like to sftp over  Win 7 n Win 10 patches (.msi  .msu, ??)  to about 20 remote PCs that are located in our supplier/service providers premises as these PCs are npt part of our corporate's AD/domain n we cant Rdp/remote to them for security reason.

Can anyone provide a batch or cmd scripts tt will scan for the presence of msi or msu (or any extensions tt MS patches may come in) in a folder (say c:\MSpat )  n will execute them in silent mode (ie dont need us to input/intervene) but dont reboot after patching.  Ideally, output logs ( >>) or error ( 2>>) to 2 separate logs.  Housekeep away the patch files
0

Scripting Languages

26K

Solutions

20K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.