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

Hi Experts,
I have the following function trying to synchronize my local folder with a FTP folder.
Sub Example()
 
    Dim mySession As New Session
    
    ' Enable custom error handling
    On Error Resume Next
    
    Download mySession
    
    ' Query for errors
    If Err.Number <> 0 Then
        MsgBox "Error: " & Err.Description
 
        ' Clear the error
        
        Err.Clear
    End If
     
    ' Disconnect, clean up
    mySession.Dispose
     
    ' Restore default error handling
    On Error GoTo 0
    
End Sub
Public Sub Download(ByRef mySession As Session)
'Public Sub Download()
    ' Setup session options
    Dim mySessionOptions As New SessionOptions
    With mySessionOptions
        .Protocol = Protocol_Sftp
        .hostname = "sftp.MySite.com"
        .username = "MyUser"
        .password = "MyPWD"
        .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
        
        
    End With
    
    ' Connect
    mySession.Open mySessionOptions
    
    ' Upload files
    Dim myTransferOptions As New TransferOptions
    myTransferOptions.TransferMode = TransferMode_Binary
    'myTransferOptions.ResumeSupport = TransferResumeSupportState.TransferResumeSupportState_Off
    myTransferOptions.ResumeSupport.State = TransferResumeSupportState_Off
     
    Dim transferResult As SynchronizationResult
    'Set transferResult = _
        mySession.GetFiles("/Outbox/*PatChanges*", "H:\FTP\", False, myTransferOptions)

Open in new window

0
Cloud Class® Course: SQL Server Core 2016
LVL 12
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

I want to automate the file transfer.
FTP Client : Reflection FTP Client
SFTP Server : Tectia SFTP Server.
I tried using similar to winscp scripts powershell but it didnt work.
Can someone help me providing the script which will work to transfer file to sftp server running script.
Authentication method is public key + password authentication and password must be encrypted.
0
Update Word Document with Data entered in Excel
sp
I have Excel sheet displayed on the screenshot above.
I also have word documents with the name that matches exactly the name of each Comp-Name.

BATH.docx
MONR.docx
STAR.docx
JUSGB.docx




Each word document has a table with the same column names as the Excel sheet

I would like to have the respective word document table updates automatically  its data to match the new entered data in Excel .
for instance If I have a new purchase, I can manually add it to a new Excel row, and the program should add that new row automatically to the corresponding word document.

Example:
I have new purchase for a company MONR
On Excel , I will add new entry:
MONR      TX      3/3/2018      3/8/2018

on a corresponding word document MONR.doc, I should have the new entry added automatically to the table in word.

Any help will be very much appreciated.

Thanks
0
Dear expert
Please check below code, I got question on $cred = Get-Credential  how I do this in get-WMI process, I need the script to auth the cred user info and password saved in the variable $cred and run Get-WmiObject with the credential in the variable $cred.
Anyone know how?
Thx

Function Get-SystemInfo {
[CmdletBinding()]
Param(
	[Parameter(ValueFromPipeline=$true)]
	[string[]]$ServerNames = '.',
	[switch]$UptimeAsString
)
	Process {
        $cred = Get-Credential 
		$now = Get-Date
		$ServerNames | ForEach-Object {
			Write-Verbose "Processing $($_) ..."
			$return = '' | Select-Object -Property 'Server', 'Last Boot', 'Uptime', 'Error'
			$return.Server = $_
			Try {
				$system = Get-WmiObject -Query 'select LastBootUpTime from Win32_OperatingSystem' -ComputerName $_ -Credential $Cred -ErrorAction Stop
				$return.'Last Boot' = $system.ConvertToDateTime($system.LastBootUpTime)
				$return.Uptime = $now - $return.'Last Boot'
				If ($UptimeAsString) {$return.Uptime = $return.Uptime.ToString("dd' Days 'hh' Hours 'mm' Minutes'")}
			} Catch {
				$return.Error = $_.Exception.Message
			}
			$return
		}
	}
}
Get-Content -Path c:\script\serverlistOP.txt | Get-SystemInfo -UptimeAsString -Verbose | ConvertTo-Html | Set-Content -Path C:\script\server_rapport.html

Open in new window

0
Hi All,

I need some help in performing Exchange mailbox export as Username@emaildomain.com for each member of the .CSV file as the input?

The input CSV file content from the HR department only contains one column with First Last name format:

user
John Herschel
Mark Sunderland
Cory Jones
Alex Ho
Sue Chen
Lin Fang
....

Open in new window


So any help to modify the below PowerShell script would be greatly appreciated.

Issue 1: How to make sure the input.CSV can match the Display Name of the Exchange mailbox?
Issue 2: How to export the mailbox that failed to process as .CSV file list so I can manually export the .PST?

#Import remote session with exchange on my laptop where Outlook is installed
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://PRODEX02-VM/Powershell/ -Authentication Kerberos
Import-PSSession $Session

$ServerBackupUNCPath = "\\BACKUP\OST\"
$CSVPath = "\\computername\c$\users\user\desktop\users.csv"

try{
	$AllMailboxes = Import-CSV $CSVPath
	foreach ($mbx in $AllMailboxes) { New-MailboxExportRequest -Mailbox $mbx -FilePath "$ServerBackupUNCPath$($mbx.Alias).pst" -baditemlimit 50 -acceptlargedataloss; while ((Get-MailboxExportRequest -mailbox $i | Where-Object { $_.Status -eq "Queued" -or $_.Status -eq "InProgress" })) { Start-Sleep 120 } }
	
	Write-Host "Processing...........$mbx.Alias................" -ForegroundColor Green
}
catch{
	Write-Host "Exception has occured processing....$mbx.Alias...." 

Open in new window

0
Hi Experts,

I have the function below that downloads files from a FTP server.

Option Explicit
 
Sub Example()
 
    Dim mySession As New Session
    
    ' Enable custom error handling
    On Error Resume Next
    
    Upload mySession
    
    ' Query for errors
    If Err.Number <> 0 Then
        MsgBox "Error: " & Err.Description
 
        ' Clear the error
        Err.Clear
    End If
     
    ' Disconnect, clean up
    mySession.Dispose
     
    ' Restore default error handling
    On Error GoTo 0
    
End Sub

Private Sub Download(ByRef mySession As Session)
 
    ' Setup session options
    Dim mySessionOptions As New SessionOptions
    With mySessionOptions
        .Protocol = Protocol_Sftp
        .HostName = "example.com"
        .UserName = "user"
        .Password = "mypassword"
        .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
    End With
    
    ' Connect
    mySession.Open mySessionOptions
    
    ' Upload files
    Dim myTransferOptions As New TransferOptions
    myTransferOptions.TransferMode = TransferMode_Binary
     
    Dim transferResult As TransferOperationResult
    Set transferResult = _
        mySession.GetFiles("/home/user/*", "H:\FTP\", False, myTransferOptions)
     
    ' Throw on any error
    transferResult.Check
     
    ' Display results
    Dim transfer As TransferEventArgs
    For Each transfer In transferResult.Transfers
        MsgBox "Download of " & transfer.Filename & " 

Open in new window

0
Looking to set up "Honey token" or Trip Wire" in Windows PCs and servers.

I have read that you can use /NetOnly to dump fake username/passwords into Lsass.

How can I do this across the domain silently?
0
When I run this below code for multiple servers, the output I am getting is combined and I want to separate them according to their IP or Names. Could you please help me below query.


$Servers = Get-Content c:\temp\servers.txt
foreach ($Server in $Servers)
{
    Invoke-Sqlcmd -ServerInstance $Server -Database master -Query 'Exec sp_databases'
}

Open in new window

0
Hello Folks,
Does anybody know how to Disable Windows 7 from copy/paste  or keeping it from doing so? or eliminating the clipboard ?
0
Hi,

Powershell coding:

I would like to first export all the users in AD that missing a displayname to a excel csv.
Then edit all the displaynames to the users that miss the displayname in that excel file.
Then use get-content to set-aduser to those displayname with the right account.

Anyway to do this?
0
Cloud Class® Course: Certified Penetration Testing
LVL 12
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Powershell scripting.

Dear expert

c:\test\01\test.txt
c:\test\02\test.txt
c:\test\03\test.txt
c:\test\04\test.txt

I need a script that take the first folder 01 file to another folder and then delete the 01 folder. Then it will stop here once removed 01 folder, next day i want the same progress with 02 folder and 03 etc.

Please help. Thanks
0
I want to delete particular row when I click on delete icon ?
Append row working fine when I click on '+' sign


JavaScript Code :
<script type="text/javascript">
  var count=2;
  function addnewrow()
  {
    
    var div = '<div class="row col-md-12" id="row'+count+'">'+
    '<div class="col-md-2">'+
        '<div class="form-group">'+
          '<label for="p_type"><font color="red">*</font>Product Type</label>'+

          '<select id="p_type" name="p_type" onChange="getCatg(this.value,'+count+');" class="form-control" tabindex="1" required>'+
            '<option>Select Product Type</option>'+
            '<option value="Goods">Goods</option>'+
            '<option value="Service">Service</option>'+
          '</select>'+
        '</div>'+
    '</div>'+

    '<div class="col-md-3">'+
      '<div class="form-group">'+
        '<label for="c_name"><font color="red">*</font>Sub-Category</label>'+
        '<select name="c_id" id="c_id_'+count+'" onChange="getProd(this.value,'+count+');" class="form-control" required>'+
          '<option>Select Sub-Category</option>'+
        '</select>'+
      '</div>'+
    '</div>'+
'</div>'+

'<div class="col-md-12">'+
  '<div class="table-responsive">'+
'<table  class="table table-bordered table-hover">'+
          '<thead>'+
            '<tr>'+
              '<th width="20%">Item Details</th>'+
              '<th width="20%">Vendor Name</th>'+
              '<th width="20%">Quantity</th>'+
 

Open in new window

0
Morning all, I'm looking for some code that will enable IE and Chrome to go fullscreen when the web page opens. We have a number of browsers, so a single bit of code would be great.

I've added the current code I have.

What would be the best method to achieve this?

Many thanks

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edward</title>
</head>
<body bgcolor="#000000">
<!--url's used in the movie-->
<!--text used in the movie-->
<!--
:
Min
Sec
-->
<!-- saved from url=(0013)about:internet -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1280" height="1024" id="Edward" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="Edward.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="Edward.swf" quality="high" bgcolor="#000000" width="1280" height="1024" name="Edward" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>

Open in new window

0
Hi Experts,

I have the script below do download all new files from my FTP server into my local PC.
However after running it for a while I get the attached error.

# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"

# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "sftp.MySite.com"
    UserName = "MyUserName"
    Password = "MyPWD"
    SshHostKeyFingerprint = "1234567890="
}

$session = New-Object WinSCP.Session

try
{
    # Connect
    $session.Open($sessionOptions)

    # Transfer files
    $sourcePath = "/Outbox/" # don't add *, will be added where necessary
    $destPath = "H:\FTP\"
    $destPathNew = "H:\FTP\Caspio\"

    $transferOptions = New-Object WinSCP.TransferOptions

    while($True)
    {
        try {
            # Get list of matching files in the directory
            $remoteFiles = $session.EnumerateRemoteFiles($sourcePath, "*.*", [WinSCP.EnumerationOptions]::None)

            # Any file matched?
            if ($remoteFiles.Count -gt 0) {
                foreach ($fileInfo in $remoteFiles) {
                    try {
                        Write-Host "Checking rules for the file " $fileInfo.Name
                        # check the filename for matching the mask
                        if ($fileInfo.Name -like "*PAT*.*" -or $fileInfo.Name -like "*Sch*.*" -or $fileInfo.Name -like "*Full*.*") {
                       

Open in new window

0
Hi ,

I found this script it is useful saving my time.
i want help from experts...
after successful transfer it moving the file to archive..but every week the activity will go and chances for overwrite.
I want to have the dateandtime stamp to put while moving the files to archive..
can help to modify the code pls..

example
Localpathfile : E:\ABC\Zip_Source\testfile.xml.zip.p7
backupPath = "E:\ABC\Backup\testfile.xml.zip.p7_DDMMYYYY_HHMMSS

Script from internet

# Upload Files to FTP and move source files to archive
param (
    $localPath = "E:\ABC\Zip_Source\*.p7",
    $remotePath = "/home/user/",
    $backupPath = "E:\ABC\Backup\"
)
 
try
{
    # Load WinSCP .NET assembly
    Add-Type -Path "WinSCPnet.dll"
 
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = "example.com"
        UserName = "user"
        Password = "mypassword"
        SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
    }
 
    $session = New-Object WinSCP.Session
 
    try
    {
        # Connect
        $session.Open($sessionOptions)
 
        # Upload files, collect results
        $transferResult = $session.PutFiles($localPath, $remotePath)
 
        # Iterate over every transfer
        foreach ($transfer in $transferResult.Transfers)
        {
            # Success or error?
            if ($transfer.Error …
0
Hi All,

Do we have any script for cold migration of multiple vm from one cluster to another.
0
i have multiple files to encrypt using slift software.
I have the manual steps to encrypt but need help for encrypting it.
I have restriction not to store any password in the scripts hence it required password to be encrypted.
command is
slift.exe /e "sourcedirectory" /pfx "privatekeyfile.pfx" password /cer "partnerpublickey.cer"
can help how to script in powershell.
0
I need to do a check some Registry & Files across the entire AD domain for these checks:

Output:
If the computer does not have the file or reg then output "%Computer%-NoReg"  | "%Computer%-NoFile" into a "MissingCBDefense.txt"
If the computer does have the both then output "%Computer%" into a "HasCBDefense.txt"
HKEY_LOCAL_MACHINE\SOFTWARE\CbDefense
c:\Program Files\Confer\RepUx.exe

If the computer does not have the file or reg then output "%Computer%" into a "NoSymantec.txt"
If the computer does have the file or reg then output "%Computer%-HasReg"  | "%Computer%-HasFile" into a "HasSymantec.txt"
HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion
C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\Smc.exe

Note: I do have a lot of Computer Objects that no exist, therefore the script may have to skip those objects that don't really exist or reach.

Thanks in advance.
0
sourcefolder  : C:\zipto\
backupfolder : C:\Zipto\archive
i have xml files in folder..
files 1.xml, 2.xml, 3.xml
want to zip it make the file name 1.zip, 2.zip.3.zip
after sucessfull zip it should move the source file alone to backup folder with 1.xml_DDMMYYYY_HHMMSS
activities must log file logfile
can help to share script...
0
Cloud Class® Course: Microsoft Office 2010
LVL 12
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

I would like to create something for an android tablet similar to a windows batch file.  I have users that will lose their connectivity to the datacenter.  It may be the internet connection or it may be the vpn.  I would like for my users to click on an icon and be able to see if they have vpn connectivity back to the datacenter.
basically it would be a batch file that would ping an internal ip address

ping 192.168.1.1 for example
is there anything like this to give my users quick intelligence if they are connected or not
0
Can you guys please assist with the following:

Via script vbs/powershell I am trying to get the logged on username value and then write this value (username) into HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName

Can you guys help?

Thank you!
0
I recently got some help writing a powershell script that listed all my AD users with their display name, ad account name and email address. Now I have a request for a similar list but this time a column for first name, last name and limited to active users only. Then the same thing with only deleted users. I supposed another column for active users Y or N would also be acceptable if it is easier. There is the last script  Get-Mailbox -ResultSize unlimited | select name, SamAccountName, primarysmtpaddress | Export-Csv c:\results.csv

I assume there must be a parm for first name and last name, but how can I determine if an account is active or disabled?
0
question about scripting.  I need to produce scripts that users can use to move files back an forth.  grab newest files only etc....  I like powershell, but powershell requires some configuration on the user's machines i don't want to go through.   Allow remote signed etc...

i would also like to avoid using good ole fashion batch files, but if i need to i will.  is there a up to date scripting language for windows that is appropriate for moving files.... is cmd prompt and powershell my two main options....
0
Hi ,

I need a help.

I have an lightsail instance on aws which is running ubuntu 16.04 LTS with Bitnami LAMP (No gui) .

I use putty to login . Login username will be bitnami and there is no password ,instead of password we use a default-key pair for authentication which was downloaded from aws console.

Now the Problem is my colleague was resigned and he too has the default-pair key .

I either to set password for bitnami so that even if the same key-pair is used the password will get prompted or i want to change the key-pair.

Could someone help me to accomplish this task .

PS:- i tried changing the user bitnami password , but with default pair key login,instance doesnt prompt for the bitnami password.
0
Hi Experts,

I have the following script downloading new files from a FTP server into a pc local folder.

Wondering if someone can help me convert it to VBA code, so I can integrate into my MS Access application and have full control over it?

# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"

# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "sftp.MySite.com"
    UserName = "MyUserName"
    Password = "MyPWD"
    SshHostKeyFingerprint = "1234567890="
}

$session = New-Object WinSCP.Session

try
{
    # Connect
    $session.Open($sessionOptions)

    # Transfer files
    $remotePath = "H:\FTP\*"
    
    $sourcePath = "/Outbox/*"
    $destPath = "H:\FTP\"
    $destPathNew = "H:\FTP\Caspio\"

    $transferOptions = New-Object WinSCP.TransferOptions

    $transferOptions.FileMask = "*PAT*.*;*Sch*.*|*Full*.*"

    while($True)
    {
         try
        {
            $transferResult = $session.GetFiles($sourcePath, $destPath, $False, $transferOptions)
            $transferResult.Check()
        }
        finally
        {
 	        foreach ($transfer in $transferResult.Transfers)
                {
                   $session.GetFiles($transfer.FileName, $destPathNew, $False, $transferOptions)
                    Write-Host "Download of $($transfer.FileName) succeeded"
                }
                $destPathNew1
        }
    }
    

Open in new window

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.