Question: I have a simple PowerShell script that using windows.forms for presenting and getting data using GUI.
It works when I run it using PowerShell , but doesn't work via CMD.
Here is the .ps1 example :

```
[System.Windows.MessageBox]::Show('message','Step 1','YesNoCancel','Question')

```

batch file for executing :

```
powershell "&{start-process powershell -ArgumentList ' -noprofile -file c:\temp\gui.ps1' -verb RunAs} exit $LASTEXITCODE" < NUL

```

Th error I get is : Unable to find type [System.Windows.MessageBox].
I understood that the CMD running with different context and the assembly need to be loaded , so I tried to load it from the CMD command , but still same error .

```
powershell "&{[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); start-process powershell -ArgumentList ' -noprofile -file c:\temp\gui.ps1' -verb RunAs} exit $LASTEXITCODE" < NUL

```

Error:
[![enter image description here](https://i.stack.imgur.com/9t8dz.png)](https://i.stack.imgur.com/9t8dz.png)
Any idea ?

Answer: 
I achieved it by reading this [blog](https://amundtveit.com) :)

```
let data = _currentScaledMotionArrays.reduce([], +) //result is of type [Double] with 480 elements
guard let mlMultiArray = try? MLMultiArray(shape:[40,12], dataType:MLMultiArrayDataType.double) else {
    fatalError("Unexpected runtime error. MLMultiArray")
}
for (index, element) in data.enumerated() {
    mlMultiArray[index] = NSNumber(floatLiteral: element)
}
let input = PredictionModelInput(accelerations: mlMultiArray)
guard let predictionOutput = try? _predictionModel.prediction(input: input) else {
        fatalError("Unexpected runtime error. model.prediction")
}

```
This is how I did it. Probably not the best way to handle optionals but gets the job done for testing

Create an instance of the `MLMultiArray` object with shape and data type

```
let mlArray = try? MLMultiArray(shape: [3], dataType: MLMultiArrayDataType.float32)

```

`mlArray` does not have an append function so you literally have to iterate through it and add values

```
for i in 0..<array.count {
     mlArray?[i] = NSNumber(value: input[i])
}

```

Full function

```
    func convertToMLArray(_ input: [Int]) -> MLMultiArray {

        let mlArray = try? MLMultiArray(shape: [3], dataType: MLMultiArrayDataType.float32)

        for i in 0..<array.count {
            mlArray?[i] = NSNumber(value: input[i])
        }

        return arr!
    }

```