My goal here was to send myself an email of all new files received from vendors. This is assuming the files are not picked up and processed by BizTalk automatically. If that were the case, you might be able to point the folders to your archive directories and still achieve the same results.

In my particular case, we have a production serer exposed to our vendors. They send us test files, and I have to manually copy them and process them on our test server. At this time, we don’t have any access from one server to the other. So the email alert will trigger me to go process the files, rather than waiting for an email from the vendor.

#
#      Name: Neal Walters
#      Date: 2019/07/29 
#
#   Purpose: Send email with all any new test files received. 
#            Files are received on Prod server that is exposed to outside world. 
#            We have to manually copy these files to our test system and process them. 
#
#

cls

$minutes = $args[0]

#allow this to be run 
if ($minutes -eq $null)
   {
     $minutes = 60
   }
   

$filterDate = (Get-Date).AddDays(-6) 
Write-Host "filterDate=$filterDate" 

$folderMask = "c:\BizTalk\Vendors\*\AS2FilesReceived\*.*"
#-Exclude "*997*.*"
$files = Get-ChildItem -Path $folderMask -File | Where-Object {$_.CreationTime -gt (Get-Date).AddMinutes($minutes)} | Sort-Object FullName
Write-Host "Number of Matching AS2 Files = $($files.Count)" 

$folderMask = "f:\SFTPFiles\*\*Test\From*To*\*.*"
$FTPfiles = Get-ChildItem -Path $folderMask -File | Where-Object {$_.CreationTime -gt (Get-Date).AddMinutes($minutes)} | Sort-Object FullName
Write-Host "Number of Matching SFTP Files = $($FTPfiles.Count)" 


$fileCount = 0 
$HTMLmessage = "<Table border=1>"

foreach ($file in $files) 
{
     $fileCount = $fileCount + 1 
     Write-Host "$fileCount $($file.FullName) $($file.CreationTime)`n" 
     $HTMLmessage = $HTMLMessage + "<tr><td>$fileCount $($file.FullName)</td><td> $($file.CreationTime)</td></tr>`n" 

}

foreach ($file in $FTPfiles) 
{
     $fileCount = $fileCount + 1 
     Write-Host "$fileCount $($file.FullName) $($file.CreationTime)`n" 
     $HTMLmessage = $HTMLMessage + "<tr><td>$fileCount $($file.FullName)</td><td> $($file.CreationTime)</td></tr>`n" 

}

$HTMLmessage = $HTMLMessage + "</Table>"

#[string[]] $toEmails = "nwalters@rogent.com", "bshaw@rogent.com" # List of toEmails to email your report to (separate by comma) or use a distribution list 
[string[]] $toEmails = "nwalters@rogent.com" # List of toEmails to email your report to (separate by comma) or use a distribution list 

$smtpServer = "smtp.rogent.com" 
$fromemail = "noreplyFilesReceived@rogent.com"
$emailSubject = "BizTalk EDI Files Received"

if ($fileCount -gt 0)
{
   send-mailmessage -from $fromemail -to $toEmails -subject $emailSubject  -BodyAsHTML -body $HTMLmessage -priority High -smtpServer $smtpServer
   $traceDateTime = get-date
   Write-Host "$traceDateTime Email sent to: $toEmails (size in bytes=$($HTMLmessage.length))" 
}



How to get files created in the most recent x days.

$days = -3 
$folderMask = "c:\BizTalk\Vendors\*\AS2FilesReceived\*.*"
$files = Get-ChildItem -Path $folderMask -File | Where-Object {$_.CreationTime -gt (Get-Date).AddDays($days)} | Sort-Object FullName
Write-Host "Number of New AS2 Files = $($files.Count)" 

First run npm to install js-sha3 (See GitHub https://github.com/emn178/js-sha3
This example show how to do it without using web3 library, in case you don’t have an ETH node to connect to, or can’t get the library working.


npm install js-sha3

Subroutines below come from either agove GitHub or https://ethereum.stackexchange.com/questions/1374/how-can-i-check-if-an-ethereum-address-is-valid

const keccak256V = require('js-sha3').keccak256;
const sha3_256 = require('js-sha3').sha3_256;

function toChecksumAddress (address) {
  address = address.toLowerCase().replace('0x', '')
  var hash = keccak256V(address);
  var ret = '0x'

  for (var i = 0; i < address.length; i++) {
    if (parseInt(hash[i], 16) >= 8) {
      ret += address[i].toUpperCase()
    } else {
      ret += address[i]
    }
  }

  return ret
}

/**
 * Checks if the given string is an address
 *
 * @method isAddress
 * @param {String} address the given HEX adress
 * @return {Boolean}
*/
var isAddress = function (address) {
    if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
        // check if it has the basic requirements of an address
        return false;
    } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
        // If it's all small caps or all all caps, return true
        return true;
    } else {
        // Otherwise check each case
        return isChecksumAddress(address);
    }
};

/**
 * Checks if the given string is a checksummed address
 *
 * @method isChecksumAddress
 * @param {String} address the given HEX adress
 * @return {Boolean}
*/
var isChecksumAddress = function (address) {
    // Check each case
    address = address.replace('0x','');
    //var addressHash = sha3(address.toLowerCase());
	var addressHash = sha3_256(address.toLowerCase());
    for (var i = 0; i < 40; i++ ) {
        // the nth letter should be uppercase if the nth digit of casemap is 1
        if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
            return false;
        }
    }
    return true;
};

var originalAddress = "0x41b418a9bea5c6652a5fb6674370126e828b50fe"; 
var checkSumAddress = toChecksumAddress(originalAddress); 
console.log("checkSumAddress=" + checkSumAddress);

var isAddressResult = isAddress(originalAddress); 
console.log("isAddressResult=" + isAddressResult); 

You can validate the address here:
https://tokenmarket.net/ethereum-address-validator

The following is code I copy and paste a lot into my various Powershell prorams.

The commented out line creates a backup zip file, so I like to have the file name with the date/time in it.

$fmtDateTime = $(get-date -f "MM/dd/yyyy HH:mm:ss")
Write-Host "Start Time: $fmtDateTime"

$fileDateTime = $(get-date -f "MM_dd_yyyy__HH_mm_ss")
Write-Host "File DateTime: $fileDateTime"

$filename = "C_Temp_$fileDateTime" 

#.zip suffix is automatically added 
#Compress-Archive -Path C:\Temp -DestinationPath f:\Backup\TempDir\$filename

Use the queries to find database tables for an owner (namespace/schema), tables containing certain phrases, all columns in a table, or column containing a certain phrase.

-- All tables for an owner (prefix before table name) 
SELECT owner, table_name FROM all_tables where owner = 'PO';

-- Find table names 
SELECT owner, table_name FROM all_tables where Table_Name like '%INVOICE%INTER%' order by Owner, Table_Name 
SELECT owner, table_name FROM all_tables where lower(Table_Name) like '%pos_shipping_addresses%' order by Owner, Table_Name 

-- Find column names (along with data type and length/size) 
SELECT table_name, column_name, data_type, data_length from dba_tab_columns where lower(column_name) like '%ship%' and upper(table_name) = 'PO_HEADERS_INTERFACE'