B
Broggy69
Guest
So I got one script working perfectly as I want it too. However my next power script doesn't work
Below is the code that works.
Dim objProcess As New Process()
objProcess.StartInfo.Verb = "runas"
objProcess.StartInfo.FileName = "powershell.exe"
objProcess.StartInfo.Arguments = "E:\Install\3rdParty\Additional_Support_files\Windows_Firewall.ps1"
objProcess.StartInfo.RedirectStandardOutput = True
objProcess.StartInfo.RedirectStandardError = True
objProcess.StartInfo.UseShellExecute = False
objProcess.StartInfo.CreateNoWindow = True
objProcess.Start()
Dim output As String = objProcess.StandardOutput.ReadToEnd()
Dim errors As String = objProcess.StandardError.ReadToEnd()
txt_log.Text += "Output:" + Environment.NewLine
txt_log.Text += "-------" + Environment.NewLine
txt_log.Text += output + Environment.NewLine
txt_log.Text += Environment.NewLine
txt_log.Text += "Errors:" + Environment.NewLine
txt_log.Text += "-------" + Environment.NewLine
txt_log.Text += errors + Environment.NewLine
Here is the code for the new script
Dim objProcess As New Process()
objProcess.StartInfo.Verb = "runas"
objProcess.StartInfo.FileName = "powershell.exe"
objProcess.StartInfo.Arguments = """E:\Install\BlackBoard\TS\BbTS 3.13.0.0 R2\Script\SetSecurityPolicies.ps1"""
objProcess.StartInfo.RedirectStandardOutput = True
objProcess.StartInfo.RedirectStandardError = True
objProcess.StartInfo.UseShellExecute = False
objProcess.StartInfo.CreateNoWindow = True
objProcess.Start()
Dim output As String = objProcess.StandardOutput.ReadToEnd()
Dim errors As String = objProcess.StandardError.ReadToEnd()
txt_log.Text += "Output:" + Environment.NewLine
txt_log.Text += "-------" + Environment.NewLine
txt_log.Text += output + Environment.NewLine
txt_log.Text += Environment.NewLine
txt_log.Text += "Errors:" + Environment.NewLine
txt_log.Text += "-------" + Environment.NewLine
txt_log.Text += errors + Environment.NewLine
Here is the output:
Errors:
-------
E:\Install\BlackBoard\TS\BbTS : The term 'E:\Install\BlackBoard\TS\BbTS' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.At line:1 char:1
+ E:\Install\BlackBoard\TS\BbTS 3.13.0.0 R2\Script\SetSecurityPolicies.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (E:\Install\BlackBoard\TS\BbTS:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I know the folder and script exist. I can run it through powershell manually
Any help or advice is appreciated.
It looks like powershell isn't reading the folder string. There are spaces in the folder which is why I added the """Folder Name"""
Continue reading...
Below is the code that works.
Dim objProcess As New Process()
objProcess.StartInfo.Verb = "runas"
objProcess.StartInfo.FileName = "powershell.exe"
objProcess.StartInfo.Arguments = "E:\Install\3rdParty\Additional_Support_files\Windows_Firewall.ps1"
objProcess.StartInfo.RedirectStandardOutput = True
objProcess.StartInfo.RedirectStandardError = True
objProcess.StartInfo.UseShellExecute = False
objProcess.StartInfo.CreateNoWindow = True
objProcess.Start()
Dim output As String = objProcess.StandardOutput.ReadToEnd()
Dim errors As String = objProcess.StandardError.ReadToEnd()
txt_log.Text += "Output:" + Environment.NewLine
txt_log.Text += "-------" + Environment.NewLine
txt_log.Text += output + Environment.NewLine
txt_log.Text += Environment.NewLine
txt_log.Text += "Errors:" + Environment.NewLine
txt_log.Text += "-------" + Environment.NewLine
txt_log.Text += errors + Environment.NewLine
Here is the code for the new script
Dim objProcess As New Process()
objProcess.StartInfo.Verb = "runas"
objProcess.StartInfo.FileName = "powershell.exe"
objProcess.StartInfo.Arguments = """E:\Install\BlackBoard\TS\BbTS 3.13.0.0 R2\Script\SetSecurityPolicies.ps1"""
objProcess.StartInfo.RedirectStandardOutput = True
objProcess.StartInfo.RedirectStandardError = True
objProcess.StartInfo.UseShellExecute = False
objProcess.StartInfo.CreateNoWindow = True
objProcess.Start()
Dim output As String = objProcess.StandardOutput.ReadToEnd()
Dim errors As String = objProcess.StandardError.ReadToEnd()
txt_log.Text += "Output:" + Environment.NewLine
txt_log.Text += "-------" + Environment.NewLine
txt_log.Text += output + Environment.NewLine
txt_log.Text += Environment.NewLine
txt_log.Text += "Errors:" + Environment.NewLine
txt_log.Text += "-------" + Environment.NewLine
txt_log.Text += errors + Environment.NewLine
Here is the output:
Errors:
-------
E:\Install\BlackBoard\TS\BbTS : The term 'E:\Install\BlackBoard\TS\BbTS' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.At line:1 char:1
+ E:\Install\BlackBoard\TS\BbTS 3.13.0.0 R2\Script\SetSecurityPolicies.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (E:\Install\BlackBoard\TS\BbTS:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I know the folder and script exist. I can run it through powershell manually
Any help or advice is appreciated.
It looks like powershell isn't reading the folder string. There are spaces in the folder which is why I added the """Folder Name"""
Continue reading...