Thursday, February 8, 2018

PowerHell



So here's another rant about Microsoft inconsistency and UN-usability of their products (sorry but I cannot hold this anymore)..

Since it's been introduced years ago, Microsoft Powershell looked very promising, with its CMDLet approach to reuse scripts, not only for sysadmin tasks, but for almost everything Microsoft.

There is only one problem with it (still nowadays): inconsistency.

The reason why I say this, is because most of the times (I am serious, most of them) I try to use Powershell, I get the famous error message:

The term '[Put your Powershell Module name here]' is not recognized as the name of a cmdlet, function, script file, or operable program.


That seems like a trivial error, so the next thing to do is to install the missing module.

This generally requires a few steps:

  • Figure out which module contains the command you are trying to run (not always straightforward).
  • Figure out which version of the module contains the exact command you try to run (different versions of Powershell (several available by now) might use slightly different syntax or parameters in commands...
  • Install the module (assuming you already installed all its dependencies, otherwise it won't install).


Besides the poor documentation about the different modules for each version, etc., the main issue is that even following the above steps meticolously, won't guarantee that you can finally run your command.

In fact, it turns out that doing a quick search on my machine for "Powershell", I have more than 10 folders containing Powershell modules...

C:\Program Files\WindowsPowerShell
C:\Program Files (x86)\WindowsPowerShell
C:\Program Files\Microsoft Azure Active Directory\Powershell
C:\Program Files\Microsoft Application Insights\Status Monitor\PowerShell
C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell
C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell
C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Powershell
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\jgvvk40b.4cw\Starterkit\Extensions\powershell
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\4gsxi3yc.1xk\Starterkit\Extensions\powershell
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\uqch3mzq.qv5\Starterkit\Extensions\powershell
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\5rr1fg2l.ml1\Snippets\PowerShell

And of course each one is not visible to the others..

The obvious questions are: why each single (Microsoft) application installs yet another folder and cannot reuse a main one? And why 2 versions, 32 and 64 bit? And why the new installation can't take care of cleaning up/upgrading what's already installed?

Don't even bother answering, as nothing new here...

And on top of this PowerHell, I decided to skip my machine altogether, and rely on the "official" Microsoft Cloud Shell, which is basically Powershell baked into Azure.

Well, surprise surpise, even there, running the command "New-AzureADPolicy ..." returns the same old error:
The term 'New-AzureADPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program.


You would think that Azure Active Directory CMDLets are installed in Azure.. wrong!

At least not for the AzureADPreview one..

Fair enough, so I ran the command: Install-module AzureADPreview

No luck, same error, even after installing the right module...

Now, eventually after lots of wasted time, I managed to run the command inside Powershell ISE (yet another different way of running Powershell scripts...), and have my policy created in Azure...

But still, go figure, Microsoft...

Tuesday, February 6, 2018

Microsoft Confusion...



I mentioned before about the Azure and Microsoft Graph APIs, and the fact that Microsoft recommends to use the latter one.

In fact, every page of documentation related to the Azure Graph API contains this disclaimer:

We strongly recommend that you use  Microsoft Graph  instead of Azure AD Graph API to access Azure Active Directory resources. Our development efforts are now concentrated on Microsoft Graph and no further enhancements are planned for Azure AD Graph API. There are a very limited number of scenarios for which Azure AD Graph API might still be appropriate; for more information, see the  Microsoft Graph or the Azure AD Graph

I can see this disclaimer in articles dated back as much as June 2017.

Still, as of now (February 2018), the Microsoft Graph API only supports a tiny bunch of operations in its official version 1.0, and a few more in its beta version, while most of the operations that are supported on the Azure Graph API (soo many), are still not supported at all in the Microsoft Graph API (beta or not).

And here is another annoying detail: even though the documentation states that
Microsoft Graph currently supports two versions: v1.0 and beta.
v1.0 includes generally available APIs. Use the v1.0 version for all production apps.
beta includes APIs that are currently in preview. Because we might introduce breaking changes to our beta APIs,
we recommend that you use the beta version only to test apps that are in development; do not use beta APIs in your production apps.
In reality the v1.0 is really so limited that it cannot be used, except for a few operations.

One simple example is listing your AAD App Registrations (you can easily reproduce this from the Graph Explorer); if you run this query:

GET https://graph.microsoft.com/beta/applications

You will see the list of AAD App Registrations correctly returned as JSON

However, if you switch to the v1.0:

GET https://graph.microsoft.com/v1.0/applications

This is what you get:
{
    "error": {
        "code": "BadRequest",
        "message": "Resource not found for the segment 'applications'.",
        "innerError": {
            "request-id": "6bf2f498-fe90-464c-9b83-084d4cc316f9",
            "date": "2018-02-06T13:20:25"
        }
    }
}
So, yeah, after almost a year of using the beta and "prodcution ready" v1.0, the Microsoft Graph API is still very unusable, and the Azure Graph API remain the only reliable API to query AAD programmatically...

And unfortunately, I have to admit, this is not surprising from Microsoft...
:(

Step-by-Step Guide to Fine-Tune an AI Model

Estimated reading time: ~ 8 minutes. Key Takeaways Fine-tuning enhances the performance of pre-trained AI models for specific tasks. Both Te...