public CommandResult Execute(string scriptFile, CalamariVariableDictionary variables, ICommandLineRunner commandLineRunner) { var powerShellEngine = new PowerShellScriptEngine(); if (variables.Get(SpecialVariables.Account.AccountType).StartsWith("Azure")) { return(new AzurePowerShellContext().ExecuteScript(powerShellEngine, scriptFile, variables, commandLineRunner)); } return(powerShellEngine.Execute(scriptFile, variables, commandLineRunner)); }
public CommandResult Execute(Script script, CalamariVariableDictionary variables, ICommandLineRunner commandLineRunner) { var powerShellEngine = new PowerShellScriptEngine(); if (!string.IsNullOrEmpty(variables.Get(SpecialVariables.Action.ServiceFabric.ConnectionEndpoint))) { return(new AzureServiceFabricPowerShellContext().ExecuteScript(powerShellEngine, script, variables, commandLineRunner)); } else if (variables.Get(SpecialVariables.Account.AccountType).StartsWith("Azure")) { return(new AzurePowerShellContext().ExecuteScript(powerShellEngine, script, variables, commandLineRunner)); } return(powerShellEngine.Execute(script, variables, commandLineRunner)); }
public override string GetHelpHtmlContent(ScriptIntellisenseItem item) { string cmdletName = CmdletName ?? item?.Value; if (string.IsNullOrWhiteSpace(cmdletName)) { return(null); } using var runspace = PowerShellScriptEngine.CreateRunspace(); using var ps = Automation.PowerShell.Create(); ps.Runspace = runspace; ps.AddCommand("get-help").AddParameter("Name", cmdletName).AddParameter("Full").AddCommand("out-string").AddParameter("Width", 10000); var commands = ps.Invoke(); var command = commands?.FirstOrDefault(); var result = Convert.ToString(command?.BaseObject); if (string.IsNullOrWhiteSpace(result)) { return(null); } result = HtmlEncode(result); var reHeaders = new Regex(@"(?m)(^\w[\w \t]+)"); result = reHeaders.Replace(result, "<b><u>$1</u></b>"); var reParameters = new Regex(@"(?m)^(?:[ \t]*(\-\w+(?:\s*\[?<.*?>\]?)?))\s*<br>\s*$"); result = reParameters.Replace(result, "<b>$1</b><br>\r\n"); var reCommonParameters = new Regex(@"(?m)^[ \t]*(<CommonParameters>)\s*<br>\s*$"); result = reCommonParameters.Replace(result, "<b>$1</b><br>\r\n"); result = result.Replace(" ", " "); return(result); }
public MainView() { //Load skins before InitializeComponent(), to allow skinned splash screen. LoadStartupSkin(); ShowSplashScreen(); InitializeComponent(); //Repeat from Program.cs WindowsFormsSettings.SetDPIAware(); DpiAwarenessHelper.Default.SetDpiAware(DpiAwarenessKind.PerMonitorV2); BaseForm.ApplicationIcon = this.Icon; this.AdjustSizeForMonitor(); navProject.State = NavigationPaneState.Collapsed; UIUtils.ConfigureRibbonBar(Ribbon); Ribbon.CommandLayout = (CommandLayout)(int)ApplicationSettings.Default.RibbonCommandLayout; InitializeAppMenuItems(); InitializeSkinGallery(); var skinName = UserLookAndFeel.Default.ActiveSkinName; var isSkinVector = UIUtils.IsSkinVector(skinName); skinPaletteRibbonGalleryBarItem.Visibility = isSkinVector ? BarItemVisibility.Always : BarItemVisibility.Never; UserLookAndFeel.Default.StyleChanged += LookAndFeel_StyleChanged; ((DevExpress.LookAndFeel.Design.UserLookAndFeelDefault)UserLookAndFeel.Default).StyleChangeProgress += LookAndFeel_StyleChangeProgress; barNewPyScriptDocument.Visibility = PythonScriptEngine.IsInstalled ? BarItemVisibility.Always : BarItemVisibility.Never; barNewRScriptDocument.Visibility = RScriptEngine.IsInstalled ? BarItemVisibility.Always : BarItemVisibility.Never; PowerShellScriptEngine.RefreshAvailableCommandLets(); GridFunctionFactory.RegisterFunctions(); }
public override void ShowOnlineHelp(ScriptIntellisenseItem item) { string cmdletModule = HtmlEncode(CmdletModule); string cmdletName = HtmlEncode(CmdletName ?? item?.Value); if (string.IsNullOrWhiteSpace(cmdletName)) { XtraMessageBox.Show("Cmdlet name is empty.", "Cannot show help for cmdlet", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { using var runspace = PowerShellScriptEngine.CreateRunspace(); using var ps = Automation.PowerShell.Create(); ps.Runspace = runspace; ps.AddCommand("get-help").AddParameter("Name", cmdletName).AddParameter("Online"); ps.Invoke(); } catch (Exception ex) { if (!string.IsNullOrWhiteSpace(CmdletModule)) { //Try to show on Microsoft site string url = $"https://docs.microsoft.com/en-us/powershell/module/{cmdletModule}/{CmdletName}"; System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo() { FileName = url, UseShellExecute = true }); return; } XtraMessageBox.Show(ex.Message, "Cannot show online help", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }