ISESteroids Refactoring your script and other tools

In this blog post I will show some of the other great features that are available to use in ISESteroids.

Refactoring your script

One of the biggest features that ISESteroids has is the Refactor Script button. This button will when clicked rewrite your entire script for you and make it more readable. A few thing it will do is remove any unneccesary spaces, normalizing line endings, case correct for commands and parameters as well as automatically indent script blocks.

To acces this function we need to click the Toggle Auto-Formaton Addon button.

format-script-button

This will then open the Auto-Format options tab on the right side of your screen.

auto-format-options

For most scripts using the basic function works well enough since in the advances tab all options are ticked by default, however if we want more control on whats changed in our script we can use the advanced tab. On this tab we can specify exactly what the refactor button will do to our script. When we have specified what we want the button to check for we can start the process by clicking the Fix Script Now button.

refactor-options

 

Simulating the running of a script

Another function we have in ISESteroids is the simulate function. With this button we can simply run our script without any changes being made to our test system while still checking if the script will run as expected.

simulate-mode

 

Compatibility options in ISESteroids

Another great tool that I like to use are the Compatibility options. With this option we can target the versions of Powershell for which we would like to use our scripts.  We can also generate a report from this option menu to see if there are any issues that we can expect to encounter if we try and use our script with certain versions of Powershell. This tool comes quite in handy if you have any older Powershell scripts lying around that aren’t working properly or need to be updated.

compatability powershell-versions

 

Converting a script to a .exe file

A handy feature ISESteroids has is that once we are done with a script we can save our PS1 script as a .exe file. This allows us to easily publish tools to for example, clear and reload the App-v cache and provide the script in a users startmenu as a .exe file.

convert-to-exe

 

The PSSharper function

Another great tool in ISESteroids is the PSSharper function. This function will point out any errors, suggestions, information, Performance issues and ignored rules that we have in our script. Some of these issues will ofcourse be corrected with the refactor button but its nice to know if we are ignoring any best practices or if there are ways to improve our scripting.

pssharper-ignored-rulespssharper-suggestions

From the PSSharper tab on the right side of our screen we have the option to fix these issues immediately by either double clicking them or by clicking the Fix Now button to fix all selected issues.

fix-now

 

Adding a digital signature

Another nice tool in ISESteroids is that we can use it to sign our scripts with a digital signature. To do this we need to click on the add Digital Signature button on the bottom right of the screen.

add-digital-signature

We then click on Add Signature.

add-digital-signature-basic

Since we currently do not have one installed it will ask us if we want to create one. When we click on Yes it will ask us to save it.

self-signed

With this tool we can create our own self signed certificate to sign our scripts with. Using the advanced options we can ofcourse sign our script with one provided by a certificate authority or one provided by another party, for example the company you work for.

advanced-options-add-digital-signature

 

The toggle Content Sensistive Help addon

Another handy feature is the Toggle Context Sensitive Help Addon in ISESteroids. This function will show us help information based on the command we have clicked in our script. It will then show us information on the right of our screen in the help tab. This help automatically updates whenever you switch your selection.

context-sensitive-help-addon

 

Intelliselect in ISESteroids

A nice function built into ISESteroids is Intelliselect. With this function we can for example quickly comment out a piece of a command. To do this we do the following, If the cursor is in the piece of a command in the function we want to comment out you hit CTRL+Q. This will then select the command or in this case Variable.

intelliselect-1

This will then select the command or in this case Variable.

intelliselect-2

When we hit CTRL+Q again it will then select the entire function

intelliselect-5

Now we can comment it out by hitting Ctrl+Shift+B

intelliselect-4

Another thing we can do with intelliselect is change a variable without having to go through our entire script. To do this we do the following.  Select the variable you want to change and hit F2. This will highlight the variable you selected throughout your script.

intelliselect-3

Now you can just type to change the variable and it will be changed completely through your script. Nice and simple.

intelliselect-6

These are just some of the tools we have available in ISESteroids and I haven’t used them all yet. In my next post I will talk about some more features I have found and tested.

 

 

ISESteroids using Versioning

First off I would like to talk about the versioning usually when I am scripting I go through several versions of my script.  In the past I saved several in progress versions of my scripts in a separate folder just incase I messed up and ruined my script. With ISESteroids you can use the versioning function to save several versions of your scripts and if you want to easily revert back to previous versions when needed. Note: Versioning only works when you have saved the script. You cannot use it for on a script that is not saved.

To use versioning in our script we click the Toggle Script File Versioning Management Tool button.

versioning-how-to-open

After we click this button the Versioning tab opens up.

versioning-tab-open

We can now decide to use either the Auto Mode for versioning or add a new version of our script ourselves. Below you can see several of the options.

versioning-options

In this case I want to add a Major Version since I will be making some changes in my script. After I have done this i created a Minor Version as well. As soon as we have added versions you can see them in the tab on your right. It will also specify the way they are created for you, Either through the Auto Mode or through a manual addition.

versioning-tab-with-versions

We can also categorize the scripts and add notes to them to clarify our changes and to avoid any confusion with our release scripts. You do this by clicking the blue options in the version of the script. You can also delete versions of the script this way.

classification

ISESteroids will save all the revisions of your script in a zip file located in the folder where you saved your scripts.

versioning-history-zip-location

Contained in this zip file we can see all the versions of our scripts neatly ordered for ease of use.

zip-file-opened

You can easily share this zip file with your coworkers or upload it to a different location to back-up your work.

To compare the changes to our script Winmerge was included in the versioning feature as well. We can use this by clicking on the Compare button.

click-compare-button

After we do this Winmerge will open and it will highlight any differences in the different versions of our scripts. As an example I have only added a letter to Fonts. Winmerge will compare version 1.0 of our script to version 1.1.

winmerge

If we want to we can then undo our changes to Version 1.1 by clicking the  All left button

all-left-button

After we do this the changes are made and we get this message.

merge-complete

Now we only have to save the script to confirm we wanted to undo the changes.

winmerge-save

After we have saved the changes and closed Winmerge we are prompted to reload our script.

isesteroids-reload-script-after-winmerge

Now we can either delete our 1.1 version of the script to go back to version 1.0 or add another revision.

This concludes my overview of the versioning function. In my next post I will discuss the Refactor feature included in ISESteroids.

ISESteroids: Getting Started

Recently I discovered an editor for Powershell called ISESteroids. In my day to day work I try and use Powershell as much as I can. In the past I worked primarily through the ISE editor but compared to other script editors it missed some features that helps your workflow.

After looking for a editor for Powershell I discovered ISESteroids. After using the trial the past ten days my scripting has improved a lot. Partly this is due to using many of the features included in this editor. But mostly due to the refactor option in this editor.  In this blog post I will discuss how you can install the editior and how you can try the trial and see why I use ths editor for yourself.

Installation

First off we have several ways to install the editor. You can either install it through Powershell Get but you can also install it through a zip file installation. Personally I went for the zip installation you can find on this page.

Running ISESteroids

After installing it using the install.bat included in the zip file you simply open the Powershell ISE editor and type Start-Steroids

The default editor we all know and love

The default editor we all know and love

As soon as you have done this through the magic of powershell modules the ISE transforms into ISESteroids.

ISE with ISESteroids loaded in

The ISE Editor with the ISESteroids module loaded.

Now that we have ISESteroids installed I want to start ISESteroids automaticly everytime I start the Powershell ISE. Fortunately, ISESteroids allows us to easily edit the Profile Scripts that the ISE launches when starting. So we can add the Start-Steroids command to our profile script to launch the module every time we start the Powershell ISE. Note: You have to allow scripts to run on your system to be able to use a powershell profile. So remember to either sign the profile script  or set the execution policy to Unrestricted(Not recommended!)

 

To do this we have to take the following steps:

First click on File, and go to Open Profile Script, In this case I want to do it just for my current user account. So I only pick Current User (ISE)

editing-profile-script

Since I currently do not have a Profile Script I am asked to create one.

profile-script-creation

I simply add the line below and save the profile.

profile-script-with-start-steroids-command

Now when I start my Powershell ISE I automatically start ISESteroids. You can do this for all users as well, But since I am the only one using my PC I only need to do it for myself.

In my next blog post I will discuss some of the features I have used the most during my ten day trial with ISESteroids

 

Powershell script to export groupmembers to a .csv file

When working in a multidomain enviroment I sometimes want to export a list of members from a group for future reference. To do this I have written this script.

 

This script when executed prompts you to do the following:

  1. Enter a domain name for example: contoso.local
  2. Enter a group name for example Test_Group
  3. Pick a location to save the .csv file.
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
$domain = [Microsoft.VisualBasic.Interaction]::InputBox('Enter the domain name', 'Name', "$domain")
If ($domain -eq '')
{
  $domain = [Microsoft.VisualBasic.Interaction]::InputBox('Enter a valid domain name', 'Name', "$domain")
}
$group = [Microsoft.VisualBasic.Interaction]::InputBox('Enter a AD group name', 'Name', "$group")
If ($group -eq '')
{
  $group = [Microsoft.VisualBasic.Interaction]::InputBox('Enter a valid AD group name', 'Name', "$group")
}

Function Select-FolderDialog
{
  param([string]$Description = 'Select Folder',[string]$RootFolder = 'Desktop')
  $null = [System.Reflection.Assembly]::LoadWithPartialName('System.windows.forms')   
  $objForm = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog
  $objForm.Rootfolder = $RootFolder
  $objForm.Description = $Description
  $Show = $objForm.ShowDialog()
  If ($Show -eq 'OK')
  {
    Return $objForm.SelectedPath
  }
  Else
  {
    Write-Error -Message 'Operation cancelled by user.'
  }
}
$location = Select-FolderDialog

 
Get-ADGroupMember -identity "$group" -server "$domain" -recursive |
Select-Object -Property name |
Export-Csv -Path $location\$group.csv -NoTypeInformation

Wisptiss.exe causing freezes in applications packaged with App-v 5.0 SP2 and below

There are some virtualized App-V 5 applications that are having issues with wisptis.exe. This process  handles the input of pen-enabled devices like a Surface Pro 3. When an application that uses .NET Framework 4.5.2 is virtualized on the App-V 5 (SP1/SP2) client, there is severe mouse-lag or the mouse hangs completely.

Workarounds

You can revert back to .NET 4.5.1 or upgrade to .NET 4.6
If your application actually requires the .NET Framework 4.5.2 version this is obviously not an option.

Solution

Upgrade to App-V 5 SP3 or a later client. The issue is resolved in these later versions.

How to turn on hidden Primary virtual application directory (PVAD) in APP-V 5.0 SP3

The primary virtual application directory (PVAD) is hidden in App-V 5.0 SP3, but there is an option to turn it back on and make it visible during the sequencing phase. To do this we have the following options.

  • Option 1: open the sequencer.exe with the following parameter;
    –EnablePVADControl
  • Option 2: In the Registry Editor, go to;
    HKLM\SOFTWARE\Microsoft\AppV\Sequencer\Compatibility

If the Compatability subkey doesn’t exist, create it. We then create a DWORD Value named EnablePVADControl and set the value to 1. A value of 0 means that PVAD is hidden.

Welcome

Welcome to my blog. Here I will share interesting things that I encounter during my work. This will mostly have to do with App-v 4.6,App-v 5.x and SCCM and Powershell.

Powered by WordPress & Theme by Anders Norén