HD0014 – How Do I Run PowerShell Commands In Meta5

0
48

Please watch the video in 1080p because it is recorded in High Resolution.
Please note the script of the presentation is below so you can read along with the demonstration if you like.


Hello and welcome back to our latest How Do I, blog post.

We are happy that you’ve come back to see our latest blog post.

My name is Sofi, and I’m your BIDA AI assistant.

I will be your host for the demonstration today.

In today’s demonstration, we are going to show you how to run Power Shell commands in Meta 5.

This is very useful because you can do such things as send e-mails, send reports to One drive, and download things from One Drive.

You can do all sorts of useful things once you can run a Power Shell command from inside Meta 5.

Now on with our demonstration!

Here we are on our Windows desktop running Meta 5 in the background.

We have a file directory in front of you, which is the BIDA hosting schedule directory.

This is where we put our Power Shell commands.

I will take you through each of the relevant files.

The first file you need, is a file to create the secure string, which will be your password.

You can just run this command, enter your e-mail address, and it will put the encrypted password into this file for you.

To show you what that looks like, I will just click on the encrypted password file.

It is just a series of numbers and letters.

It is the password to the BIDA common e-mail address encrypted.

The next thing you need is a bat file to run a PowerShell command.

This is a very simple file.

You can see the power shell exe command.

But notice the No Profile and execution policy bypass parameters.

These parameters are required with Meta 5 to bypass script security for Power Shell commands.

This is because Meta Five runs under a different profile than the Windows desktop.

So you need to remember to put in no profile execution policy of bypass.

Then you have the command parameter which is just a positional parameter.

That positional parameter is the command that you want to run.

In our example, we want to run a command to send an e-mail to say that the ETL batch has finished.

That is a very common thing that you want to do in data warehousing.

You can see the first line is the name of the e-mail address, that is going to send the e-mail.

The password you can see is, get content from the login password text file, and convert it to a secure string.

So we are getting that password, we are running it through convert to secure string, and we are assigning that to the password variable.

And then we are creating credentials of a new object, which is Automation ps credential.

The argument list is the administration name, the e-mail, the user we want to log in with, and the password for that user.

From there we just send the mail message from BIDA common to Peter’s business e-mail.

The subject is the BIDA weekday batch has completed.

The body of which is also the BIDA weekday batch has completed.

We are using the S M T P server of Office 3 6 5.

We are using the credentials of credential and we are saying use S S L and use port 5 8 7.

Now one note to mention.

This e-mail address must be authorized to send S M T P emails, and the default is to not be authorized.

You can just do a Google search and ask how do I authorize Office 3 6 5 e-mail address to use S M T P e-mail.

Now, there may be other ways of sending emails.

We happen to be using S M T P, so those are the commands that you need.

The text will be on the blog post, and you can see the commands here in the directory.

Now we are going to go over to the Meta 5 desktop.

We are going to open this capsule, run bat commands with results.

We have an icon, run bat file, and the icon is the I application icon.

So when you’re looking for it in new icons, you look for Integrator Icons and the I application icon in the Integrator Icons folder.

We have given it the name run bat file and this can be any PC application.

We say, execution information, Global application.

We have the Execution file parameter.

In here we see the path name.

I will zoom in on it for you.

It is BIDA, beta hosting, C 12, schedule.

You can see it in the video.

The file is run power shell command dot bat.

The exact command that you saw.

Then the command line parameter is the same folder.

And it runs the command run M O 1, send E T L, e-mail, P S 1.

The working directory is also entered.

Now I am just going to run the command.

It is going to execute that Power Shell command.

All we need to do is hit run and you will see it just takes a second.

Now it says complete, please continue.

Because I don’t want to show you Peter’s inbox, you can just trust me that the e-mail actually arrived.

OK!

That completes our demonstration today.

Today we showed you a very simple way of how to run Power Shell commands in Meta 5.

Thus, making the full power of PowerShell available to you, from inside the Meta 5 desktop, and from inside Meta 5 Capsules.

We hope you found this How do I Presentation useful and informative.

With that I’d like to say thank you very much for listening.

We really appreciate your time and attention.

I wish you a nice day.

Sofi. Your BIDA AI Assistant.

The commands that you saw in the video are as follows:

run-this-as-a-powershell-command.ps1
Read-Host -Prompt "Enter your email password" -AsSecureString | ConvertFrom-SecureString | Out-File "M:\A_BIDA_HOSTING\BIDAHS_C012_BC\S01-Schedule\bida-common-login-password.txt"

RunPowerShellCommand.bat
PowerShell.exe -noprofile -executionpolicy bypass -Command %1

run-m01-send-end-etl-email.ps1
$AdminName = "bida.common@businessintelligenceda.onmicrosoft.com"
$Pass = Get-Content "M:\A_BIDA_HOSTING\BIDAHS_C012_BC\S01-Schedule\bida-common-login-password.txt" | ConvertTo-SecureString
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $AdminName, $Pass
Send-MailMessage –From bida.common@businessintelligenceda.onmicrosoft.com –To peter@bida.ro –Subject "BIDAWeekDayBatch001 - Batch Completed" –Body "BIDAWeekDayBatch001 - Batch Completed" -SmtpServer smtp.office365.com -Credential $cred -UseSsl -Port 587