Showing posts with label Windows PowerShell ISE. Show all posts
Showing posts with label Windows PowerShell ISE. Show all posts

Monday, October 22, 2018

How do you display Commands pane in Windows PowerShell?

You often want to look at all commands available shown in the commands pane.
By default it may not be shown when you launch PowerShell and perhaps this is what you see.


PS_CommandsPane_0


You can display the command pane using the View menu as shown.


PS_CommandsPane_1


Click Show Command Add-on. Now the command pane is added as shown.


PS_CommandsPane_2


You can also use the Object Model code to display the Command pane as shown.


PS_CommandsPane_3

Friday, July 20, 2018

How do you run a C# Console Application using PowerShell?

How do you run C# Console Application using PowerShell?

Microsoft.PowerShell.Utility module has a cmdlet, Add-Type. Add-Type can be used to execute the code from PowerShell command shell.

The Add-Type has a large number of parameters and using these Add-Type will define and generate the class. If you specify source code, Add-Type compiles the source code and generates an in-memory assembly that contains the .NET Framework types.

Here are some of the parameters of Add-Type from Microsoft documentation here.

Add-Type
   [-CodeDomProvider ]
   [-CompilerParameters ]
   [-TypeDefinition]
   [-Language ]
   [-ReferencedAssemblies ]
   [-OutputAssembly ]
   [-OutputType ]
   [-PassThru]
   [-IgnoreWarnings]
   []


Here is an example of using the source code in a here-string.


Now we use this string in TypeDefinition that takes a String as follows:

Add-Type -TypeDefinition $Source

Now the code is executed using the following:

[Joinstring]::Add("Jay"," Krishnaswamy"

Here is the code in Windows PowerShell ISE.