Redeploying SSRS reports in D365FO without using Visual Studio

Since I am not a developer… especially not an X++ developer I am ususlly not entrusted with access to Visual Studio (this statement was more for dramatic effect but the truth is that I am trying to avoid it to not mess things up).

The main reason for this work around is that in some environments Visual Studio is not set up and to do that would require setting up the correct account, mapping workspaces and a whole lot more. This way is simpler:

  1. Log into the Dynamics Server
  2. Start PowerShell Elevated as Administrator
  3. Run the following command:

    K:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation “K:\AosService\PackagesLocalDirectory”

That will redeploy all of the for Dynamics 365 for Operations

Links:
https://msdax.wordpress.com/2018/04/08/deploying-ssrs-reports-to-dynamics-ax-365/

RSAT: Failed to download or overwrite attachment files – Some files maybe in use.

I had an issue today with one of my testcases in RSAT. When running it manyally from the RSAT UI it worked but when trying to run it from a PowerShell script I got this error:

Failed to download or overwrite attachment files – Some files maybe in use.

For some reason the test case uploaded duplicate files to Azure DevOps. When I ran the test in RSAT it uses the local file generated from RSAT and everything worked but when I ran it from the console it downloaded the files from DevOps, got the duplicates and for some reason failed.

The solution was to permanently delete the test case from DevOps and resync it from BPM.

Beware that that will give it another ID which will change the order of the tests.

Getting started with VS Code – for a developer wannabe – Part 1

I am a developer… in the same was as I am a gamer and a harmonica player… I really, really really want to be one… I am not good at it, but I really want to be one. I have over the years tried my hand at Powershell, Yaml, BAT- files and even good old kix scripts and much lite an amateur golfer I try to tell my self that if I just have the right tool I will really get good at this… (I really want to believe that 🙂 )

When it comes to PowerShell I have been an avid user of PowerShell ISE but since Microsoft is not doing much of anything with ISE anymore and they are pushing VS Code more and more for everything I thought what the heck… This is my noob guide to getting started with VS Code (for someone that has only used ISE).

In this post I will show you how I set it up and I will probably follow up wit other posts on how I got started.

First you need to download and install VS Code itself:

  1. Go here to download
  2. I checked the options
    Add “Open with Code” action to Windows Explorer file context meny
    Add “Open with Code” action to Windows Explorer directory context meny
    Register Code as an editor for supported file types
  3. Finish the install and Launch VS Code

When you start VS Code for the first time it will look like this. To get started with PowerShell there is at least one plugin you will need… PowerShell (unexpected right). This is used for providing snippets and high lighting code

4. Click the small cubes at the bottom of the toolbar on the left

5. Type PowerShell in the search bar, select it and press the small green install

The plugin even makes VS Code look a bit like ISE. I usually set it back to Dark (that is what coders do 🙂 )

That is it for today. I will continue with more tips and tricks for getting started with VS Code.

Bye

Johan

Downloading Microsoft Ignite Sessions

This year I was not able to visit Microsoft Ignite 2019 but since there are more than 1900 session available for on demand viewing (and I would not have had time to watch the sessions I wanted anyway) that doesn’t really matter. I can always download them and watch them at home. If you hesitate on downloading all of them you can find your sessions/products/speakers of interest on the Ignite site 

To bulk download them you will need a script. I use this one but there are others out there that you can use. For this particular script to work you will need a tool called youtube-dl (which in turn requires Microsoft Visual C++ 2010 Redistributable Package (x86) ) and ffmpeg.exe. both tools will be downloaded by the script. In order to run scripts you download (this is done your own risk… only run scripts you trust) you will also need to set the execution policy in PowerShell

I do it for just the specific window that I use:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

To download the session I use these script lines:

.\Get-EventSession.ps1 -DownloadFolder 'D:\Microsoft Ignite 2019\' -Product "*Finance*" -Event Ignite -NoSlidedecks
.\Get-EventSession.ps1 -DownloadFolder 'D:\Microsoft Ignite 2019\' -Product "Power Platform" -Event Ignite -NoSlidedecks
.\Get-EventSession.ps1 -DownloadFolder 'D:\Microsoft Ignite 2019\' -Speaker "Jeffrey Snover" -Event Ignite -NoSlidedecks
.\Get-EventSession.ps1 -DownloadFolder 'D:\Microsoft Ignite 2019\' -Speaker "Mark Russinovich" -Event Ignite -NoSlidedecks
.\Get-EventSession.ps1 -DownloadFolder 'D:\Microsoft Ignite 2019\' -Product "Not Product Specific" -Event Ignite -NoSlidedecks

There are a lot of other filter possibilities in the script that you can explore… now, get downloading

Johan

Links:
https://gallery.technet.microsoft.com/Ignite-2016-Slidedeck-and-296df316#content

Error in Environment Reprovisioning tool

I have been working with an upgrade of Dynamics 365 for Operations now for a while and found an issue when it comes to Environment Reprovisioning tool, also known as Retail Retargeting Tool. This is a tool used to fix the retail conponents in an environment after you have done a database copy to the environment from another environment. We did this as part of the upgrade to Platfor Update 10.

When we ran the tool from the command prompt in the environemnt we gor the following error:

The step completed
Executing step: 3
GlobalUpdate script for service model: RetailServer on machine: localhost
Run RetargetRetailServer.ps1
RetargetRetailServer.ps1 failed.
The step failed
The step: 3 is in failed state, you can use rerunstep command to debug the step explicitly
at Microsoft.Dynamics.AX.AXUpdateInstallerBase.RunbookExecutor.executeRunbookStepList(RunbookData runbookData, List`1 runbookStepList, String updatePackageFilePath, Boolean silent, String stepID, ExecuteStepMode executeStepMode, Boolean versionCheck, Boolean restore, Parameters parameters)
at Microsoft.Dynamics.AX.AXUpdateInstallerBase.RunbookExecutor.executeRunbook(RunbookData runbookData, String updatePackageFilePath, Boolean silent, String stepID, ExecuteStepMode executeStepMode, Boolean versionCheck, Boolean restore, Parameters parameters)
at Microsoft.Dynamics.AX.AXUpdateInstallerBase.AXUpdateInstallerBase.execute(String runbookID, Boolean silent, String updatePackageFilePath, IRunbookExecutor runbookExecutor, Boolean versionCheck, Boolean restore)
at Microsoft.Dynamics.AX.AXUpdateInstaller.Program.InstallUpdate(String[] args)
at Microsoft.Dynamics.AX.AXUpdateInstaller.Program.Main(String[] args)

So this error was not that obvious to me… So I took a look at the loggs for the Deployable package which are located in the RunbookWorkingFolder (located in the folder where you extracted the package). There I found this:

Exception : System.Management.Automation.RuntimeException: The servicing data of this box has not been migrated yet, please rerun this tool with axlocaladmin
TargetObject : The servicing data of this box has not been migrated yet, please rerun this tool with axlocaladmin

This made me think… The older environments always had an account called axlocaladmin but the newer ones does not. After some digging around in the script called RetargetRetailServer.ps1 I found this (on line 302) :

if($env:UserName -ne 'axlocaladmin')
{
    $errorMessage = "The servicing data of this box has not been migrated yet, please rerun this tool with axlocaladmin"
    Log-TimedMessage $errorMessage
    throw $errorMessage
}

I simply changed it to:

if($env:UserName -ne 'adminXXXXXXXXXX')
{
    $errorMessage = "The servicing data of this box has not been migrated yet, please rerun this tool with axlocaladmin"
    Log-TimedMessage $errorMessage
    throw $errorMessage
    
}

where adminXXXXXXXXXX is the account name for my user and the i re-ran:

AXUpdateInstaller.exe execute -runbookid=env-reprovision -rerunstep=3

And presto… it worked 🙂

Note that this is the reprovisioning tool from 8/30/2017, I have not looked at any other verisons.

/Johan

Database Syncing

Hi…

Today we are doing a DB upgrade in Dynamics 365 for Operations. One of the steps in the process includes installing a hotfix which in turn triggers a database sync. The Sync failed so I tried to find a way to run it manually and since the environment is a TEST environment it does not have Visual Studio. Powershell to the rescue:

I:\AosService\WebRoot\bin\Microsoft.Dynamics.AX.Deployment.Setup.exe -bindir "G:\AosService\PackagesLocalDirectory" -metadatadir "G:\AosService\PackagesLocalDirectory" -sqluser "axdbadmin" -sqlpwd "[PasswordForAxDBAdmin]" -sqlserver "Servername.database.windows.net" -sqldatabase "[SQLAzureDB]" -setupmode "sync" -syncmode "fullall" -isazuresql "true"

 

Links:
https://community.dynamics.com/ax/b/axilitynet/archive/2016/01/28/ax7-database-synchronization-w-o-visual-studio

Installing Security Development Tool for AX 2012 R3

Today I am installing Security Development Tool in one of our lab environments. First of all you need to download the tool from LifeCycle Services.

When you have the file msi file it is time to do the install

  1. Start by running the msi file… this is an extremely short install which seems to do nothing… but that is OK
  2. When the mis install is done start Microsoft Dynamics AX 2012 Management Shell as an elevated user and run the following

    Install-AXModel -File “c:\Program Files (x86)\Microsoft\Security Development Tool\SecurityDevelopmentTool.axmodel”

  3. Start the AX client and you will get a message that the Model store has been modified. Select Compile and Syncronize and wait for the process to complete
  4. When AX is done compiling and syncing start the AOT (by pressing Crtl + D)
  5. Browse to the Class called SysSecEntryPointmanagerSetup, right-click and select Open
  6. Restart the AX client
  7. When the client is restarted go to Administration and click Security entry point permissions

    Note: You might get an error that the tool can only be run in Single-User session mode. In that case goto Administration – Online users and disconnect all users except your own

That is all

Links:
https://technet.microsoft.com/en-us/library/hh859727.aspx

Download all Ignite sessions… Using oneget…

Hi

Today I will highlite a couple of things…

First of all: If you have not used OneGet (which comes with Windows 10) you should definately take loog at it. It lets you install software and powershell modules from different repositories on the internet (think Apt-get on Linux)

Second of all… My colleagues at AddLevel has created a PowerShell module for downloading the Ignite sessions automatically and it is available from Technet Gallery which makes it downloadable by using OneGet… Here is how you do it:

    1. Start an elevated Powershell prompt on your Windows 10 Computer
    2. Enter Find-Module CH9 | Format-List to have a look at the information about the package. If this is the first time you use Oneget, Powershell will ask you if it is OK to install the NuGet provider.

    1. If you want to install the package use: Find-Module CH9 | Install-Module
    2. Once you have installed the module, use get-command -module CH9 to fund which CMDlets are available

    1. To download all Mikael Nystroms sessions from Ignite 2015 use this:

      Get-CH9EventItem -Speaker “Mikael Nystrom” -EventName Ignite -Region NorthAmerica -Year 2015 | Save-CH9EventItem -StorePath C:\Users\johan.persson\Downloads

/Johan

Getting started with Desired State Configuration – Part 2

In the first part we got DSC up and running with some custom modules. In this part we will start using some of the built in modules. We start by creating a Configuration. In this case we want to create a configuration for a DC which means that we will need a DHCP Server. We start by installing the DHCP Role:

configuration DC
{
    
    # One can evaluate expressions to get the node list
    # E.g: $AllNodes.Where("Role -eq Web").NodeName
    node ("DC01")
    {
        # Call Resource Provider
        # E.g: WindowsFeature, File
        WindowsFeature DHCPServer
        {
           Ensure = "Present"
           Name = "DHCP"
        }
    }
}

DC

Start-DscConfiguration -Path .\DC

When the configuration is created we run it to create the .mof (the Mof file is created in a folder with the same name as the node in the folder where you are running the configuration block) file for the configuration and then we start the configuration by invoking Start-DscConfiguration.

We continue to build our configuration by using the Service Dsc module. By running:

Get-DscResource Service | select -ExpandProperty Properties

we will get more information about the module and which keywords we can use. We use this to set the State and StartupType

configuration DC
{
    
    # One can evaluate expressions to get the node list
    # E.g: $AllNodes.Where("Role -eq Web").NodeName
    node ("DC01")
    {
        # Call Resource Provider
        # E.g: WindowsFeature, File
        WindowsFeature DHCPServer
        {
           Ensure = "Present"
           Name = "DHCP"
        }

        Service DHCP
        {
            State = "Running"
            Name = "DHCPServer"
            StartupType = "Automatic"
        }
    
    }
}

DC

Start-DscConfiguration -Path .\DC

To verify that the configuration is applied  and that it has not been changed we use:

Compare-DscConfiguration -Path .\DC

If everything is OK we will see this:

PSComputerName  ResourcesInDesiredState        ResourcesNotInDesiredState     InDesiredState 
--------------  -----------------------        --------------------------     -------------- 
DC01            {[WindowsFeature]DHCPServer... {}                             True           

Try stopping the DHCP Service and run the same command again

 

PSComputerName  ResourcesInDesiredState        ResourcesNotInDesiredState     InDesiredState 
--------------  -----------------------        --------------------------     -------------- 
DC01            [WindowsFeature]DHCPServer     [Service]DHCP                  False          

As you can see we can now find configuration drift… in the next part we will look at how to enforce the configuration.

/Johan

Getting started with Desired State Configuration – Part 1

I have been thinking a long time about forcing myself to learn Desired Stat Configuration (DSC), but I haven’t gotten around to it… Now is the time

Desired State Configuration is this super cool technology that appeared in Windows Server 2012 R2 and when Microsoft st6arted talking about it the typical example was the you hade this farm of Web Servers and you wanted to ensure that they were identically configured. The problem is that most of my customers do not have a farm of web servers… so what do I use it for. Well, Microsoft is releasing these new DSC resources on a regular basis for a lot of products which means that it is getting more and more interresting. The latest resource kit is called Wave 9 and it contains the following resources:

cFileShare
xActiveDirectory
xAdcsDeployment
xAzure
xAzurePack
xBitlocker
xChrome
xComputerManagement
xCredSSP
xDatabase
xDhcpServer
xDismFeature
xDnsServer
xDscDiagnostics
xDSCResourceDesigner
xExchange
xFailOverCluster
xFirefox
xHyper-V
xInternetExplorerHomePage
xJea
xMySql
xNetworking
xPendingReboot
xPhp
xPowerShellExecutionPolicy
xPSDesiredStateConfiguration
xRemoteDesktopAdmin
xRemoteDesktopSessionHost
xSafeHarbor
xSCDPM
xSCOM
xSCSMA
xSCSPF
xSCSR
xSCVMM
xSmbShare
xSqlPs
xSQLServer
xSystemSecurity
xTimeZone
xWebAdministration
xWindowsRestore
xWindowsUpdate
xWinEventLog
xWordPress

As you can see thare are A LOT of them… some that I think are really cool are for instance TimeZone, RemoteDesktopAdmin, BitLocker and more. Note that all DCS recources starting with an X are eXperimental. So lets get started…

Prerequsites

DSC is built in to Windows Server 2012 R2 but it needs a patch KB2883200. If this patch is not installed you will net be able to see the modules you have installed.

Installing DSC Resources

There are some default resources installed by default:

File
Archive
Environment
Group
Log
Package
Registry
Script
Service
User
WaitForAll
WaitForAny
WaitForSome
WindowsFeature
WindowsOptionalFeature
WindowsProcess

If you want to install other modules (for instance Wave 9) you just download them and extract them to the folder C:\Program Files\WindowsPowerShell\Modules

Verifying the install

To verify the install run the following command

Get-DSCReource

In the next part we will look at how you actually use DSC to create server configurations

/Johan

Links

http://blogs.msdn.com/b/powershell/archive/2014/12/17/another-holiday-present-from-the-powershell-team-dsc-reskit-wave-9.aspx
http://support.microsoft.com/kb/2883200