Powershell Inline

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Powershell Inline >

Powershell Inline

PWS. - Powershell-Script Start

Previous Top Next


MiniRobotLanguage (MRL)

 

PWS. Command

Powershell Script Start

 

 

Intention

 

This command is used to start a block with VB-Script. It is always used paired with VBE.

 

The statements between a VBS. and a VBE. are ignored by the SPR-Preprocessor.

They are also ignored by the "Pretty-Printer" in the Editor.

 

VBS. and VBE. enable you, to include a VB-Script or Java-Script Code inline into the SPR-Script. You can use it to check for System-Objects (See Sample 2 below), or you can use it to call WMI-Functions.

 

You can also transfer Variable-Content into VB-Script-Variables (see example 1 below). And use them in your VB-Script.

 

And with VBE. you can get a single result value from the VB-Script back into your SPR-Script (see example 2 below).

 

 

This Sample-Script shows how to get Parameters into the Powerscript and how to get the result out to the SPR.

 

' This is the Powershell-Call with the Parameters

PWS.||Theo|Peter und Franz|Ralf|Heribert|Jürgen

 

param ($var1, $var2, $var3, $var4, $var5)

Write-host "var1 =" $var1

Write-host "var2 =" $var2

Write-host "var3 =" $var3

Write-host "var4 =" $var4

Write-host "var5 =" $var5

 

PWE.$$OUT

' Display the Output from the Powershell in a Messagebox

MBX.$$OUT

ENR.

 

 

Syntax

 

PWS.P1|P2[|P3...|Px]

...

PWE.

 

 

Parameter Explanation for VBS

 

P1 - (optional,in) Addition to Powershell call. Could be something like

     "-ExecutionPolicy Undefined ". Normally leave just empty.

 

P2 - (optional,in) Reserved for STDIN. Currently unused, leave empty.

 

P3-Px - (in) - these are the Parameters to transfer into the

       Powershell-Script. You can use up to 30 KB for all Parameters together.

       In case you need more, use temporary files.

 

 

 

 

Example

 

'**********************************************

' PWS./PWE. - Sample

' with Parameters

'**********************************************

' This is the Powershell-Call with the Parameters

PWS.||Theo|Peter und Franz|Ralf|Heribert|Jürgen

param ($var1, $var2, $var3, $var4, $var5)

Write-host "var1 =" $var1

Write-host "var2 =" $var2

Write-host "var3 =" $var3

Write-host "var4 =" $var4

Write-host "var5 =" $var5

PWE.$$OUT

' Display the Output from the Powershell in a Messagebox

MBX.$$OUT

ENR.

 

 

 

'**********************************************

' PWS./PWE. - Sample

' Get and say the BIOS-Version 2 times.

'**********************************************

PWS.

param( [string]$strComputer = "." )

$colItems = get-wmiobject -class "Win32_BIOS" -namespace "root\CIMV2" -computername $strComputer

foreach ($objItem in $colItems)

          {                        

write-host "Name : "       $objItem.Name

write-host "Version : "    $objItem.Version

write-host "BiosVersion: " $objItem.BiosVersion

write-host "SMBIOSBIOS Version : " $objItem.SMBIOSBIOSVersion

write-host "Caption: "     $objItem.Caption

write-host "Manufacturer : " $objItem.Manufacturer

 

Add-Type -AssemblyName System.speech

$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer

$speak.Speak($objItem.SMBIOSBIOSVersion)

$speak.Speak($objItem.SMBIOSBIOSVersion)

}

PWE.$$OUT

MBX.$$OUT

ENR.

 

 

 

Remarks

 

-

 

 

Limitations:

 

The Powershell-Scripts will be written to the harddisk prior to execution. Therefore they are not permanently crypted together

with the SPR-Script when using the '#CRY:-Option.

 

There are no Limitations about Multithreading here.

 

 

 

See also:

 

    PWE. - Powershell-Script End

    VBE. - VB-Script End