Scripting Languages

27K

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

I need a Power Shell Script that will add multiple lines of text to a CSV file or Text File.
FailureScript.docx
0
Free Tool: Subnet Calculator
LVL 12
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Dear experts

Please read the script code below, I would like to improve it with some more function in it. First I would like to make it runable for double click on the file and after indata with $Path and $Pattern, it show up the result in it and then it will ask if you wanna search again yes or no, if yes then rerun the script from Param if no breaks.  I tried to write a if statement below well, knowing that it will not  work like that, would be great for a solution.

Thanks alot.

Param(
	[Parameter(Position=0, Mandatory=$True)][ValidateNotNullOrEmpty()]
	[String]$Path,
	[Parameter(Position=1, Mandatory=$True)][ValidateNotNullOrEmpty()]
	[String]$Pattern
)

function Runscript ($Path, $Pattern) {
Get-ChildItem -Path $Path -Recurse -File |
	Select-String -Pattern $Pattern |
	Group-Object Path |
	ForEach-Object {
		$LWT = (Get-Item -Path $_.Name).LastWriteTime
		$_.Group | Select-Object Path, LineNumber, @{n='LastWriteTime'; e={$LWT}}
	}
}

Param([Parameter(Position=0, Mandatory=$True)][ValidateNotNullOrEmpty()]
[String]$rerun
)

if ($rerun = y){
Runscript
}
else {
break }

Open in new window

0
Hello
I am having an issue with making “test-path” work and export some kind of log either to the directory or to the event log…..

So the challenge is to make this work on the remote computers. It only worked for the local computer.

See attached script.
0
I am trying to split pfs using PDFTK. I am trying to create a batch file that will split multiple PDF's in a folder and output all pages into a directory even if the pdf only has one page.
Is that possible ? and if so how ?
script that i have is:

pdftk c:\test\test2\*.pdf burst output c:\test\test3\page-%%02d.pdf
0
Trying to reach out the ping a website using python 2.7. Used import however its not recognized by Python. is this the right syntax?
0
Hi...
The following GUI that is used to restore backups for a system.

import Tkinter as tk

root = tk.Tk()

v = tk.IntVar()
v.set(1)  # initializing the choice, i.e. Python

backups = [
    (200,"WIN_7", "active", 4096, 320, 1),
    (201,"WIN_7_sp1", "active", 4096, 320, 2),
    (210,"WIN_Java", "inactive", 8019, 8),
    (230,"Linux_C78", "active", 4096, 90),
    (241,"Linux2_B78", "active", 4096, 80)
]

def ShowChoice():
    print(v.get())

tk.Label(root,
         text="""Choose a backup
to restore from the list:""",
         justify = tk.LEFT,
         padx = 20).pack()

for val, backup in enumerate(backups):
    tk.Radiobutton(root,
                  text=backup,
                  padx = 20,
                  variable=v,
                  command=ShowChoice,
                  value=val).pack(anchor=tk.W)


root.mainloop()

Since the back up list is changing from one system to another, the script needs to be changed to list the available backups. If I run the program 'listbk', it outputs the list as follows:

ID      NAME           STATUS      MEM    Disk    RANDOMID
100     WIN_7          active      4096     320        1
301      WIN_7_sp1     active      4096     320        2
390      WIN_Java      inactive    8019     320        8
480      Linux_C78     active      4096     320       90
541      Linux2_B78    active      4096     500       80  


Inside the python script, I am able to run the script using the below …
0
hello,

i use this gui script to change user password for my helpdesk.

i need to be able to send the new password in the local printer server for the user so it can print the new password with his own badge :).
i need to add a condition before line 23 with if condition like this:
i have 15 different OU so i think 15 different condition

get the OU of user in this form: OU=USA,OU=USERS,DC=contoso,DC=com
if $OU= "OU=USA,OU=USERS,DC=contoso,DC=com" ==> $printer="serverUSA.contoso.com"  and do this command:
PsExec.exe -u contoso\$SSAUserName -p $SSAPassword1 cmd.exe /c "PRINT /d:\\$printer\printerqueue D:\script\password.txt"

get the OU of user in this form: OU=CANADA,OU=USERS,DC=contoso,DC=com
if $OU= "OU=CANADA,OU=USERS,DC=contoso,DC=com" ==> $printer="servercanada.contoso.com"  and do this command:
PsExec.exe -u contoso\$SSAUserName -p $SSAPassword1 cmd.exe /c "PRINT /d:\\$printer\printerqueue D:\script\password.txt"
......
.....

# Change password.
	$ButtonMainChangePasswordChangePassword_Click =
	{
		if ($SSAActiveDirectoryModuleLoaded -eq $True)
		{
			Get-SSAUserName
			if ($SSAUserName)
			{
				Add-SSAOutput -OutputText "Changing password of user '$SSAUserName'."
				try
				{
					$QueryADUser = Get-ADUser -Identity $SSAUserName -Properties * @SSAApplicationUser -Server $SSAActiveDirectoryDomain -ErrorAction Stop
					Get-SSAPassword1
					Get-SSAPassword2
					if ($SSAPassword1 -and $SSAPassword2)
					{
						if ($SSAPassword1 -eq 

Open in new window

0
Hi All

I built the below script in MySQL Version 5.5

use airrider_tunn3l;
select distinct
	b.customer_name as 'Flyer Name'
    ,FROM_UNIXTIME(b.timeslot) as 'Flight Date and Time'
	,i.num as 'Invoice Number'
    ,b.voucher_title as 'Product'
    ,b.minutes as 'Flight Minutes'
    ,b.origin_nb_flights as 'Flight Quantity'
    ,b.customer_num as 'Guest Number'
    ,i.paid_ttc as 'Gross'
    ,i.total_ht as 'Net'
    ,i.total_tva as 'Tax'
    ,i.payment_method as 'Pay Method'
    ,FROM_UNIXTIME(b.checkin) as 'Check In'
FROM booking b
join invoices i on i.id = b.invoice_id
order by b.customer_name, b.timeslot, i.num, b.voucher_title, b.minutes, bb.origin_nb_flights, 
b.customer_num, i.paid_ttc, i.total_ht, i.total_tva, i.payment_method, b.checkin asc

Open in new window


The output is great, however despite using the distinct function I still end up with duplicate entries, for example (duplicate in bold)

Customer Name	Flight Date and Time	Invoice Number	Product	Flight Minutes	Flight Quantity	Gueest Number	Gross	Net	Tax	Pay Method	Check In
Test Test Test	1/21/18 01:30 PM	00000228	Kids Party Extra Flyer	1.9	2	18000182	1498	1413.21	84.79	 paymentexpress	                         1/21/18 01:44 PM
[b]Test Test Test	1/21/18 01:30 PM	00000228	Kids Party Extra Flyer	1.9	2	18000182	1498	1413.21	84.79	paymentexpress	                          1/21/18 01:44 PM[/b]

Open in new window


How do I tackle the duplicates? I know this can be done in Excel but since I'm saving the script in MySQL as a view. Any help is greatly appreciated!
0
I need the script to accept more than one directory and group. Why doesn’t it accepts multiple values?? It doens't produce the report when I do this
[String[]



#DOES NOT WORK. I get empty report.

  param(
    [Parameter(Mandatory = $True)]
    [String[]$Group,
    [ValidateScript({Test-Path -Path $_})]
    [Parameter(Mandatory = $True)]
    [String[]$Directory
)


THE FOLLOWING works.

  param(
    [Parameter(Mandatory = $True)]
    [String]$Group,
    [ValidateScript({Test-Path -Path $_})]
    [Parameter(Mandatory = $True)]
    [String]$Directory
)
#Requires -Version 4


$DataToExport = @()
$Dirs = Get-ChildItem -Path $directory -Recurse -Directory

Foreach($dir in $Dirs)
{
    $Acls = (Get-Acl -Path $dir.FullName).Access

    Foreach($acl in $Acls)
    {
        If($acl.IdentityReference.Value.ToString() -like $Group)
        {
            $props = @{
                "Path" = $dir.FullName
                "IdentityReference" = $acl.IdentityReference.Value.ToString()
                "AccessControlType" = $acl.AccessControlType
                "InheritanceFlags" = $acl.InheritanceFlags
                "PropagationFlags" = $acl.PropagationFlags
                "FileSystemRights" = $acl.FileSystemRights
                "IsInherited" = $acl.IsInherited
            }
            $DataToExport += (New-Object psobject -Property $props)
        }
    }
}

$DataToExport | Export-Csv "PermissionsDomainUsers1.csv" …
0
Hi,
I would like to get an inventory of groups and users SHARED permissions on the SHARES. SEe the screenshots.
not NTFS permissions, but SHARED permissions.

Thank you so much!

Perhaps you already written a scirpt like this.
0
The 14th Annual Expert Award Winners
LVL 7
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Help me to improve the script by adding param or variables or function. Or perhaps it is OK like that.


So, I have this script which is working. However, I would like to make it more professional and add some param or function to it. So, i tried adding param for group that I want to filter by "TESTSOURCE\DOMAIN Users". As soon as I add param, it doesn't work. Please let me know.

  param(
    [String]$Group='Domain Users',
    [String]$Directory='c:\install'
)

Get-ChildItem $directory -Recurse | ?{ $_.PsIsContainer } | %{
$Path = $_.FullName
 
 (Get-Acl $Path).Access | Select-Object `
    @{n='Path';e={ $Path }}, IdentityReference, AccessControlType, `
    InheritanceFlags, PropagationFlags, FileSystemRights, IsInherited| ?{$_.identityreference.value.ToString() -like $Group}
} | Export-CSV "PermissionsDomainUsers9b.csv"

i get an error:

Get-ChildItem : Access to the path 'C:\Windows\System32\LogFiles\WMI\RtBackup' is denied.
At line:7 char:1
+ Get-ChildItem $directory -Recurse | ?{ $_.PsIsContainer } | %{
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\Syst...es\WMI\RtBackup:String) [Get-ChildItem], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
0
Hello,
I need help with this script.

I need to make this script to only get a report of BUILTIN groups like Domain Users, Administrators, Domain Admins because we don't migrate them. The builtin groups look like this “Builtin\<AccountName>”

thank you so much. Currently, the following gets all the groups.


# Include only folders from the root path
Get-ChildItem "C:\installs" -Recurse | ?{ $_.PsIsContainer } | %{
  $Path = $_.FullName

  (Get-Acl $Path).Access | Select-Object `
    @{n='Path';e={ $Path }}, IdentityReference, AccessControlType, `
    InheritanceFlags, PropagationFlags, FileSystemRights, IsInherited
} | Export-CSV "Permissions.csv"
0
I have built a basic tool using Python to run powershell commands. I would like to create some .bat or something that can open said Python script within an Admin Powershell terminal. Some of the commands require Admin privileges, and I can't change to a different drive in admin mode, so I want to store the "startup" script within an all encompassing folder (holding the python script and various powershell scripts that I wasn't able to translate into Python yet), so this would be a portable tool. Does anyone have a suggestion on how to accomplish this? I was able to write a simple script to open an admin powershell terminal, but it only opens a blank terminal separately, and the python script opens within the first terminal that opens, which doesn't have admin rights.
0
Following is SE linux policy definition.
When permitting access to CGI scripts in system's '\tmp' directory,
which entries should be made in place of (A) and (B)

    policy_module(apache_ext, 1.0.1)

    require {
        type httpd_sys_script_t;
        type(A);
    }

    allow httpd_sys_script_t(B) :file_r_file_p
0
VB Script is choking on the long file name format we are using. The portion "1. Awaiting Director Signature" hangs up the script, as it has too many spaces and obviously exceeds formating. How can overcome this naming issue, without renaming the folder?


arrFolders = Array( "\\company\Shares\Departments\Information_Technology\Public\Purchasing\1. Awaiting Director Signature" )

Open in new window

0
What am i doing wrong here? I can get it to map the drive but apparently the drive goes away once i end the psexec session.
when i try to copy the file over with the next psexec command it tells me the drive doesn't exist
please help
@echo off
setlocal EnableDelayedExpansion 
	set /p "ip_address=Enter IP address:"
	set /p "target=Enter computer Manager(2),Training(3):"
	for /f %%a in ("%ip_address%") do (
		for /F "tokens=1,2,3 delims=."  %%i in ("%%a") do (
			set other_ip=%%i.%%j.%%k.%target%
			)
		echo !other_ip! is the Target computer
		psexec -u administrator -p twash01 \\%%a -i cmd /s /c net use z: "\\!other_ip!\c$" "password" /user:administrator 
		psexec \\%%a -u administrator -p twash01 copy c:\source\team*.reg z:\temp -y
		psexec \\%%a -u administrator -p twash01 cmd.exe /c net use z: /delete
	)

Open in new window

im wanting to remote into one computer and share a drive on it and then copy files to the other computer all locally on the remote system . this will make file distripution faster instead of having to send to all computers. I can just send it to one computer and let it copy to the others locally.
Thanks!
0
I was mailbox flooded through my contact form last night so I need to block the country that caused the attack until I can upgrade my site to take the current recaptcha from Google.  Here is the script I need to work.  I want to be ready if it happens again tonight.

for IP in $(wget -O - http://www.ipdeny.com/ipblocks/data/countries/{ua,kp}.zone) do

Open in new window

and it won't execute.  instead I get a greater than symbol ">."

This is an example:
for IP in $(wget -O - http://www.ipdeny.com/ipblocks/data/countries/{ua,kp}.zone) do
>

Open in new window


This script used to work but I had to retype it and now I get that > symbol.

Please help.

Randal
0
Hello All ,

There is script for health check of machine ,script is running manually but not running as per Task Scheduler(from Administrator account). It was working earlier but suddenly stopped working
Scrpit running from windows server 2008 R2 server.

please help to find the cause
0
Dear experts, this code below is not working,
I think $htmlout = select-object count| convertto-html -head $a
is not really work as thought, I want to show the sqlQuery result in a html file and I use: "select-object count" Now Im not sure if i used it right. the result is blank. Nothing. Anyone can help me help me solve this?

Thanks

$SQLServer = "SQL01\Trans"
$SQLDBName = "Runtime"

$SqlQuery = "

SELECT (
SELECT count(*)
FROM [Prod].[Data].[IncomingUpdate_fd]
WHERE InsertTime >= DATEADD(day,-10, getdate())
)As Incoming Prod,
(
SELECT count(*)
FROM [Prod].[Data].[IncomingUpdate_fd]
WHERE InsertTime >= DATEADD(day,-10, getdate()) AND IsProcessed = 'P'
)As Incoming Processed,
(
SELECT count(*)
FROM [Prod].[Data].[IncomingUpdate_fd]
WHERE InsertTime >= DATEADD(day,-10, getdate()) AND IsProcessed is null
)As Not Processed

"

$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; user id = XXXX; password = XXXX"

$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection

$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd

$DataSet = New-Object System.Data.DataSet
[void]$SqlAdapter.Fill($DataSet)
 
$SqlConnection.Close()

$a = "<style>"
$a = $a + "BODY{background-color:white;font-family:verdana;font-size:12px;}"
$a = $a + …
0
Free Tool: SSL Checker
LVL 12
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Dear experts

I would like to run a query:
This query will show 2 selections in one table with result count. Now problem here is that I want the column name change to Processed and Not_Processed, this is not working right now, it shows No column name.

How do i do?

Code below, thanks.

SELECT (
SELECT count(*)
FROM [Prod].[Data].[IncomingUpdate] As Processed
WHERE InsertTime >= DATEADD(day,-10, getdate()) AND Is = 'P'
),
(
SELECT count(*)
FROM [Prod].[Data].[IncomingUpdate] As Not_Processed
WHERE InsertTime >= DATEADD(day,-10, getdate()) AND Is is null
)
0
Hi Experts,
I would like to have a script/function that opens the following site
https://pages.caspio.com/login/bridgelogin/default.aspx?_ga=2.157757818.1116850724.1518037460-1462101065.1512014265
fills in the account, username and password.
See attached.
Should either be done thru Access VBA or via script.
Thanks in advance.
Untitled.png
0
I want to kill a specific process (our ERP application process name) when the app is idle for 15 minutes to resale the license for other users. How can I :
  1. Define the application being inactive  from  its process level (IO or CPU time?)
  2. Set a 15 minute timer
  3. kill the taske (taskkill process name probably)
0
Hi Experts,

Is there any shell command for how to find files in a specific folder between a data range ?

Any help regarding this would be appreciative.
0
I need to rename files on a remote folder based on the contents of that folder that change as items get processed.
The folder contains hundreds of files, they have an extension of .ready and are sequentially named:
Item Bank-1.ready
Item Bank-2.ready
Item Bank-3.ready
etc
When a service sees a file with a .zip extension in this folder, every 5 minutes it picks up that file and beings to process the contents. While processing, the file is renamed to .inprogress
When processing is complete, the file is renamed to either .failed or .done, and a corresponding .txt file is created.

I have to have these files processed under the same file name as the file name plays a part in how they are processed, so currently the work flow is:
1. Rename a file from .ready to .zip, removing the numbered suffix
    e.g. Item Bank-1.ready becomes Item Bank.zip
2. Wait for processing to finish, folder now contains:
Item Bank.done
Item Bank.zip
Item Bank-2.ready
Item Bank-3.ready
etc
3. Rename the recently completed files to add the numbered suffix again:
 Item Bank-1.done
 Item Bank-1.zio
4. Rename the next file from -2.ready to .zip
5. rinse, repeat, 400 times.

What I'd live to try and do is have a service that watches the remote folder, when it sees the .done or .failed and the .txt, it automatically renames those by adding the original suffix number, then finds the next .ready file and renames it by removing the suffix.

It doesn't matter which order the files are …
0
Dear expert, I want to write a script that first it does a SQLquery, and then it will count the query. for exemple: query will show a result of 145 row of data. I want first to show that this SQLquery is done and run in current date, if it's failed it will show the error message, then I want show the result of 145 number.

Is this possible to do? Thanks.
0

Scripting Languages

27K

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.