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 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
Cloud Class® Course: C++ 11 Fundamentals
LVL 12
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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
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
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
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
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
Get expert help—faster!
LVL 12
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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 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
Hi Experts,

I have the following script that

1- downloads from a FTP site all new files to a local folder
2- Copy all downloaded files to another local folder.

However I see that 2nd step is not working properly, it downloads/copies all files again to the 2nd folder, not only the new files.
Can someone help me fix that?

# 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 

Open in new window

0
I need a script, and I assume Powershell but I am open to any from of scripting, that I can run and have it pull all users  and list them with their first and last name, or display name, account name and email. For example the top of the list would look something like this;

Adrian Able              AAble        AAble@domain.com
Arthur Apple           AApple      AApple@domain.com
Betty Blue                BBlue        BBlue@domain.com

etc etc etc

If someone can come up with a simple script I can run, probably on the Exchange server, to create a list like this in maybe CSV format, I would appreciate it...thanks
0
Experts,

I am looking for the best way to run a Search-Mailbox command in exchange view the results rather than copy the results to a folder.

Once the Results are determined, I would like to save the results to a custom object and then Add them to an array. Displaying the Subject and the account the message was discovered in.

Here is some raw code that "DOES NOT WORK" but at least you can get an Idea of the logic I am looking for in this script:

$Exchange | ""|Account,Subject,Query
$Exchange.Account = $null
$Exchange.subject = $null
$Exchange.Query = Search-Mailbox -Identity "test@test.com" -SearchQuery 'From:"test1@test.com" Subject:"this is a test subject"'

#This Query Needs to be able to search the Mailbox, Display the results and store the results in the $results variable
$Results = invoke-expressions $exchange.Query
$results |Select Account, Subject
$ExchangeResults = @();
foreach ($result in $Results){
	$Exchange.Name = $result.Account
	$Exchange.Subject = $result.Subject
	$exchangeResults += $exchange
}
$ExchangeResults | out-grid

Open in new window


Thanks in advance for your assistance with this, I am not even sure if it can be done without the -Targetmailbox command in the Search-Mailbox String.
0
Hey Experts.  I need to run a script on the computers in my environment to see if they have Office 2016 or Office 2010.  The plan was to run this script against a txt file that contains the name of all the computers in my environment and echo out the results.  So far I have part of the script down but I don't have the parts where it echos out the results and records that with the computer name.  Any help would be appreciated.

reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer"

Open in new window


Thanks in advance Experts!
1
Hi Experts,

The script below connects to a FTP site and downloads all newest files to a local folder in my pc.

How can I change this script to include only files  either with wording "PAT" or "Sched"?
However if file name contains word "Full" it should not be included.

# 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
    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
        }
    }
    Write-Host 

Open in new window

0
Cloud Class® Course: Microsoft Exchange Server
LVL 12
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Hi Experts,
I have a script (.ps1) that would like to run it every 15 minutes.
When I right click and select run with powershell it runs.
However when trying to run this thru the windows task scheduler it says running, but nothing actually happens.
Perhaps I need a way to indicate it should run with PowerShell?
0
What are the PowerShell commands or script needed to sync the time on a Server 2016 server with an internet time server?
0
Team,

Working on a script and having problems with the logic of the script :

#test.xml

<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <Obj RefId="0">
    <TN RefId="0">
      <T>Deserialized.Selected.System.String</T>
      <T>Deserialized.System.Management.Automation.PSCustomObject</T>
      <T>Deserialized.System.Object</T>
    </TN>
    <MS>
      <S N="runscope">Y</S>
      <S N="identity"> -Identity "Jdoe@test.com"</S>
      <S N="CC_Query">1</S>
      <S N="CC_Query_Reply"> cc:"test@test.com"</S>
      <S N="From_Query"> From:"JaneDoe@test.com"</S>
      <S N="Date_Query">1</S>
      <S N="Date_Query_Reply"> Sent:"4/21/2012"</S>
      <S N="Subject_Query">1</S>
      <S N="Subject_Query_Reply"> Subject:"This is a test Subject"</S>
      <Nil N="Individual_Default_String" />
      <Nil N="Buildstring" />
      <S N="SearchQuery"> -SearchQuery </S>
      <S N="Buildstring1">Search-Mailibox</S>
      <S N="Buildstring2">Get-mailbox</S>
      <S N="loglevel_Query"> -LogLevel Full</S>
      <S N="LogLevel_Reply"> -LogLevel Full</S>
      <S N="LogLevel_Enable"> -LogLevel Full</S>
    </MS>
  </Obj>
</Objs>

Open in new window


$answers = Import-Clixml test.xml

$answers1 = $answers.psobject.Properties |select Name,Value |? {$_.Value -like "1"}
$answers1_Reply = $answers.psobject.Properties |select Name,Value |? {$_.Name -like "*Reply*"}

#in This case, the output shows as 

#Name          Value
#----          -----
#CC_Query      1
#Date_Query    1
#Subject_Query 1

#
#Name                Value
#----                -----
#CC_Query_Reply       cc:"test@test.com"
#Date_Query_Reply     Sent:"4/21/2012"
#Subject_Query_Reply  Subject:"This is a test Subject"

#logic I am trying to implement is the following :

#Loop through $answers1.Name and if Value -eq to "1" Build a string:

$answers.buildstring = $Answers.CC_Query_Reply + $answers.Date_Query_Reply +  $answers.subject_Query_Reply
$answers.Searchquery = $answers.SearchQuery + ($answers.buildstring).replace($($answers.buildstring), "'$($answers.buildstring)'")

#This should generate the following 
# -SearchQuery ' cc:"test@test.com" Sent:"4/21/2012" Subject:"This is a test Subject"'

Open in new window


This code should be Dynamic meaning that if the value does not have a 1 then it should not be put into the SearchQuery String. Other properties could be added in the future so the code would need to be able to compensate for that which shouldn't be a problem if you are able to loop though $answers1.Name


Thanks in advance for your assistance with this as I am racking my brain trying to figure out how to properly write this.
0
Hi All,

I have this powershell script , instead of using if statements i want to use case, or anything better:

$VMs = Get-AzureRmResource -ResourceType Microsoft.Compute/virtualMachines


foreach ($vm in $VMs) {

write-host -ForegroundColor Red "Processing $($vm.name) "

     

if ($vm.tags.keys -eq "displayname") 

    {

    write-host -ForegroundColor green "Tag Key $($vm.tags.keys) Exists in $($vm.name)"

    }

else {

     write-host -ForegroundColor white "Tag Key $($vm.tags.keys) DOES NOT Exists in $($vm.name)"
     #create key
     #try {}
     #catch {}


     }

If ($vm.tags.Values -eq "KayTestVM" ) 

    {

        write-host -ForegroundColor Green "Tag Value $($vm.tags.Values) Exists in $($vm.name)"



    }

Else {


        write-host -ForegroundColor White "Tag Value $($vm.tags.Values) DOES NOT Exists in $($vm.name)"
        #create value
        #try {}
        #catch {}

            
            
      }

} #End Foreach

Open in new window



$VMs = Get-AzureRmResource -ResourceType Microsoft.Compute/virtualMachines


foreach ($vm in $VMs) {

write-host -ForegroundColor Red "Processing $($vm.name) "

$tags = $vm.tags

switch ($tags)

    {

    $tags.keys ( )
    $tags.values ( ) 



    }



} #End Foreach

Open in new window



and is there a better way of doing this?

thank you in advance
0
Hi All,

I have these thousands of tag i need to apply to vms running in both azure and aws: below is an example of tag - values:

BusinessUnit: TestBusinessunit
Owner: KellyG
CostCentreCode: kellycostcentre
Name: KellyTestTagName
ApplicationID: KellyApplicationID
Functionality: functionalitytag
Environment: envronmenttag
Schedule: 10/10/2010
Monitoring: yes
Geography: Geographytag
ExternallyManaged: Managed by oup
Backups: Backed up to Azure RSV

the tags will have different values per resource, example owner:kelly, owner: Sandy,etc.

if tag already exists , we need a log it, etc.

whats the best way to approach this via powershell script. so far my idea is to store the values in csv then from csv produce into a hash table then create a function to apply the tags.

please help. just an overview of how to do this will be great.

reagards,
kelly
0
Tagging in Azure and AWS -

We have thousands of servers withing both the AWS and Azure Cloud providers.

We need to apply the following tags to all the resources as well as any new resources created in any of cloud providers.

BusinessUnit:      Identify business unit e.g. Finance, Marketing, Human Resources,            
Owner:      The email distribution name of the team,            
CostCentreCode:      Used to identify the cost centre code for cross charging,            
Name:      Used to identify the individual resource,            
ApplicationID:      Used to identify resources that are related to specific applications,            
Functionality:      Used to identify the purpose of the resource, i.e. web, message broker, DB,            
Environment:       To identify Production, PreProd, UAT, Dev, Test, Performance, Security etc,            
Schedule:       Identifies whether the server should be powered down at certain times,            
Monitoring:      Required if server is being monitored or not,            
Geography:      This should contain the Oxford University Press' geography the resource group is utilised by,            
ExternallyManaged:      3rd party support details such as HT2, CirrusHQ, Avallain, Cognizant,            
Backups:      Backup schedule and to where            

what is the best way to implement this ? do know anyone know a script i can utilise to deploy this in both environments?

Regards,
Kay
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.