public static PowerShellResponse executeSingleCommand ( String command ) { PowerShellResponse response = null ; try ( PowerShell session = PowerShell . openSession ( ) ) { response = session . executeCommand ( command ) ; } catch ( PowerShellNotAvailableException ex ) { logger . log ( Level . SEVERE , "PowerShell not available" , ex ) ; } return response ; }
Execute a single command in PowerShell console and gets result