I am newbie at using Powershell and scripts .. In script file there are simple commands that I would like to run and everything is ok
Sub TestUDF()
MsgBox ScriptFile
End Sub
Function ScriptFile() As String
Dim wshShell As Object
Dim wshShellExec As Object
Dim strCommand As String
Dim strOutput As String
strCommand = "Powershell -File ""C:\Users\Future\Desktop\Test.ps1"""
Set wshShell = CreateObject("WScript.Shell")
Set wshShellExec = wshShell.Exec(strCommand)
strOutput = wshShellExec.StdOut.ReadAll
ScriptFile = strOutput
End Function
My problem is that when running the code, the powershell window appears for two seconds. How can I hide it so as not to display this window at all?