Tags

, , , ,

Since the majority of my upcoming posts will revolve around PowerShell, I’ve decided to post about setting up your environment.  All of the things I will discuss can be found elsewhere and I will link to some of the sources that I’ve used but I’m hoping to give enough information that anyone can repeat my steps using only this blog. Also, in case anyone has issues or is just interested to know, I am using PowerShell version 3.0.

The first thing that you will need to do is set the execution policy of your environment.  The default execution policy is Restricted, meaning you will be unable to run any PowerShell scripts.  The most restrictive setting that you can have that will still enable you to run my scripts is RemoteSigned.  You can find more information here.

  • Set-ExecutionPolicy RemoteSigned

PS_Set-ExecutionPolicy

The next step is to get a profile set up.  PowerShell is largely session dependent and most things that you want to use need to be loaded into your session before they are available.  Setting up a profile gives you the ability to load things into a session by default.  The PowerShell commands that I use to set up my profile are below and you can find more information here.

  • Test-Path $profile
  • New-Item -path $profile -type file -force
  • notepad $profile

PS_CreateProfile

Most, if not all of the things that I am going to be talking about in the future start with the AX 2012 Management Utilities.  This is something that can be installed using your AX 2012 installation media and is required to be installed on the server where you will be running these scripts.

Installing the AX 2012 Management Utilities gives you access to the Microsoft Dynamics AX 2012 Management Shell.  You can find more information here.  This is another PowerShell client with some things preloaded and some UI changes.  I prefer to use the standard PowerShell client so I preload the same things using my profile.

The script that is used by the AX 2012 Management Shell is saved by default to “C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1”.  Adding this to your profile, prefixed with a period, will call this script and load the necessary modules into your PowerShell client session the next time it is started.  An example of my profile can be found here.  This example will also be updated with future posts so make sure you only grab what is necessary for you when downloading it.

PS_ManagementUtilities

This is as far as I plan to go today. I just wanted to walk you through the steps that are prerequisites for using the PowerShell functions that I will be talking about in later posts. Also, if you plan on using the PowerShell IDE client for examining these functions, be aware that the IDE client uses a separate profile so you will need to duplicate the profile steps for the IDE client as well.