Hi Cruisader03,
This is shiva. I face the same issue what Lee facing.
I am not suppose to create any ps1 files. All the powershell commands i have to execute from java code.
Example:
Process proc0 = Runtime.getRuntime().exec("powershell.exe -ExecutionPolicy Unrestricted");
System.out.println(proc0);
proc0.getOutputStream().close();
Process proc1 = Runtime.getRuntime().exec("PowerShell.exe $LiveCred = New-Object System.Management.Automation.PSCredential <
>, ConvertTo-SecureString <> -AsPlainText -Force");
System.out.println(proc1);
proc1.getOutputStream().close();
Process proc2 = Runtime.getRuntime().exec("PowerShell.exe $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection");
proc2.getOutputStream().close();
Process proc3 = runtime.exec("PowerShell.exe Import-PSSession $Session");
proc3.getOutputStream().close();
System.out.println("Before MailBox Create statement");
Process p = runtime.exec("PowerShell.exe New-Mailbox -Name <> -WindowsLiveID <> -Password (ConvertTo-SecureString -String <> -AsPlainText -Force) -RemotePowerShellEnabled $false -FirstName <> -LastName <>");
p.getOutputStream().close();
Please suggest.
Thanks
SP