Add personal functions in powershell ise editor, Add-Ons ISE

The estimated reading time 2 minutes

Add personal functions in powershell ise editor, Add-Ons ISE

Since I always act project-related in different environments, I wondered if it is possible to extend my already adapted ISE (with ISE steroids). Again and again, I need remote powershell in the environments and had to re-integrate the commands for the remote session into my ISE each time.

That’s why I researched a bit and also found some things in ISE Steroids that brought me further. Before you should always consider which connections / functions to be deposited. In my example, this is relatively simple.

structure of menu:

| RemotePowershell

|->Exchange Online

|-> DC02

Of course, other scripts must be run to connect to Exchange Online or DC02. For this reason, I have written scripts for each menu item. But first the result:

 

With ISESeroids my ISE environment looks a bit different, but creating the menu structure works exactly the same!

The ISE menu can be customized (no one would have thought it’s possible) by powershell.

First, only the item “Remote Powershell” is created.

$parent = $psise.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add('RemotePowershell', $null, $null)

To create a sub-point within Powershell, the following command can be used.

$parent.Submenus.Add('Open-ExchangeOnline',{ Invoke-Expression "$env:HOMEPATH\Documents\WindowsPowerShell\RemotePS\ExchangeOnline.ps1"}, $null)

In my case, I’m running another Powershell script, which hides behind the button. It’s located in the same folder as the profile powershell script see Infos: Technet Blog

With “Invoke-Expression” the Powershell script is executed in the path when clicking on it. Here, of course, the execution policy should also be considered.

Now a look at the stored Powershell script, which is actually not very special either.

This is nothing special and can also be found on technet see link.

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

We can have a look on my dc connection script, too:

Within my demo environment, I have the password in plain text,  you should not do this in production environments (I know that).

Here is an excerpt from my profile script which then creates the links in ISE.

$parent = $psise.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add('RemotePowershell', $null, $null)
$parent.Submenus.Add('Open-ExchangeOnline',{ Invoke-Expression "$env:HOMEPATH\Documents\WindowsPowerShell\RemotePS\ExchangeOnline.ps1"}, $null)
$parent.Submenus.Add('Open-DC02',{ Invoke-Expression "$env:HOMEPATH\Documents\WindowsPowerShell\RemotePS\RemoteAD-DC02-demo01-it-koehler.ps1"}, $null)

Thus, every time I start the ISE my buttons are loaded into the menu and I can conveniently control Exchange Online or my local DC via Remote PowerShell.

Have fun and write comments if you like this topic or have additional information.

 

 

Print Friendly, PDF & Email
  • Was this Helpful ?
  • yes   no
0 0 votes
Article Rating
Subscribe
Notify of
guest
1 Kommentar
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
trackback
2 years ago

[…] have already integrated this in my ISE, so if you do this often, you can also read my instructions LINK The PSSession to Exchange Online is mandatory, as it loads all the necessary cmdlets. The ISE can […]