azure automation: 'Invoke-ProcessASDatabase' is not recognized - azure

I am trying to use runbook in Azure automation account to process Azure Analysis Service cube.
I followed Microsoft blog https://learn.microsoft.com/en-us/azure/automation/automation-runbook-gallery.
However I got following error message when testing it. My runbook script is as following: Can you please help?
Runbook Script:
$SPCredential = Get-AutomationPSCredential -Name "TestCred"
$null = Invoke-ProcessASDatabase -databasename "SalesCube" -server "asazure://xx" -RefreshType "Full" -Credential $SPCredential
Write-Output "Done"
error message:
Invoke-ProcessASDatabase : The term 'Invoke-ProcessASDatabase' is not
recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:5 char:9
+ $null = Invoke-ProcessASDatabase -databasename "SalesCube" -ser ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-ProcessASDatabase:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Thank you for reporting this issue. We reported this thread to Microsoft this morning.
The following answer is coming from a Microsoft Azure manager:
An issue has been identified with the .Net version for Azure
Automation sandboxes that released a lower version then what was used
previously. An update is rolling out to support .Net 4.6 that should
resolve issues with PowerShell modules depending on a version on or
above .Net 4.5. It is currently planned to be rolled out to all
regions by next Monday (the 5th).
Hope this helps.

This appears to be an issue with Azure Automation this morning. I have a runbook that has completed successfully for weeks and today it failed with the same error message the OP reported. I've opened a support ticket with MS. If it is a widespread problem, perhaps they will have a fix soon.
--mf

Related

Get-MgApplication is not recognized as the name of a cmdlet - Power Shell

I am trying to run Contoso Monetization Code Sample Web App provided by Microsoft as a starting point for moving from paid add-in to SaaS offering. I am stuck at the very end where I am meant to be updating the Azure Active Directory Applications. I get this error
Get-MgApplication : The term 'Get-MgApplication' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
+ $webApp = Get-MgApplication -top 400|Where-Object {$_.DisplayName -eq ...+ CategoryInfo : ObjectNotFound: (Get-MgApplication:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Here is the code referencing the 'Get-MgApplication'.
$webApp = Get-MgApplication -top 400|Where-Object {$_.DisplayName -eq $webAppDisplayName}
$webAppSiteName = $armConfigJson.parameters.webAppSiteName.value
$redirectUris = "https://$webAppSiteName.azurewebsites.net/signin-oidc","https://$webAppSiteName.azurewebsites.net/"
Update-MgApplication -ApplicationId $webApp.Id -WebRedirectUris $redirectUris
I have checked online without any success to find if this module can be imported and loaded. I have also checked using the command get-Module to check if is in the power shell module folder and probable misspelled but it not there as well. Any help will be much appreciated.
You need to install the Microsoft.Graph.Beta cmdlets - https://github.com/microsoftgraph/msgraph-sdk-powershell/tree/master

Azure AD Sync Could not Load File

I'm having a really weird issue. I'm unable to import the Azure AD Sync module.
Here's what I've tried:
Import-Module ADSync
Import-Module "C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync\ADSync.psd1"
I'm getting the following error:
Import-module : Could not load file or assembly 'file:///C:\Program
Files\Microsoft Azure AD
Sync\Bin\Microsoft.Azure.ActiveDirectory.Synchronization.ProvisioningWebServiceAdapter.dll'
or one of its dependencies. An attempt was made to load a program
with an incorrect format. At line:1 char:1
+ Import-module adsync
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], BadImageFormatException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
I'm running under the following premise:
Azure AD Connect 1.2.70
Powershell 4.0
Windows Server 2012R2
The account I'm using is a Domain Admin and should have full permissions. I'm RDPing into the server. I'm also running Powershell as an Administrator. I've checked all installations and frameworks and they are either up to date or not applicable. AD sync is running just fine, I'm just trying to get the powershell CMDlets to work so that I can add them to a script I'm writing.
UPDATE: See below answers for solution. Reinstalling AAD was the solution.
Was able to import the module using below command, please try it out.
Import-Module –Name "C:\Program Files\Microsoft Azure AD Sync\Bin\ADSync" -Verbose
Additional Documentation Reference for:
Download
Version
Automatic Upgrade
Hope this helps.

Error while fetching AAD app information using Get-AzureADApplication

I am trying to fetch AAD app info using "Get-AzureADApplication" command. but getting the below error-
Get-AzureADApplication : You must call the Connect-AzureAD cmdlet before calling
any other cmdlets.
At C:\Users\v-pasahu\Desktop\Sample.ps1:18 char:11
+ if($app = Get-AzureADApplication -Filter "DisplayName eq '$($AppName) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AzureADApplication], AadNee
dAuthenticationException
+ FullyQualifiedErrorId : Microsoft.Open.Azure.AD.CommonLibrary.AadNeedAuthe
nticationException,Microsoft.Open.AzureAD16.PowerShell.GetApplication
According to the error message, you need to run the command Connect-AzureAD first.
Besides, if you do not install azure powershell module, you should install it before using azure ad powershell.
Looking at the comments you have said you want to run this in the non interactive flow. To do this you must follow the instructions here to log in as a service principal.
Alternatively depending on what you are trying to do you may find it easier to Login using the AzureRm cmdlets.

Azure Cloud Shell - The term 'Stop-AzureVM' is not recognized

I am attempting to use the Azure Cloud Shell (browser based) to manage a classic VM. When I run this command:
Stop-AzureVM -ResourceGroupName <resourceGroup> -Name <vmName>
I get this error:
Stop-AzureVM : The term 'Stop-AzureVM' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Stop-AzureVM -ResourceGroupName <resourceGroup>-Name <vmName>
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Stop-AzureVM:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Am I doing anything wrong, or is this just not supported in Cloud Shell?
By default, AzureRM Module is used. For PowerShell on Azure Cloudshell, you need to install classic ASM module. Just simply run
Install-Module Azure
Try to use Get-Module -Name Azure* to see if the ASM module is installed.
Now you can play with your Azure classic resource.
If you have more than one subscription in ASM model, you need to set the subscription first, using
Select-AzureSubscription -Default -SubscriptionName "your_subscription_name"
but that gives me Unable to load DLL 'IEFRAME.dll'
Azure cloud shell does not support use another account to login it.
Cloud Shell also securely authenticates automatically for instant
access to your resources through the Azure CLI 2.0 or Azure PowerShell
cmdlets.
As a workaround, maybe you can use cloud shell bash to stop that VM(classic).
Azure CLI 1.0 support ASM and ARM, just change mode to ASM, you can use cloud shell to manage your classic VM, like this:
azure config mode asm
azure vm list
azure vm --help //get more information about CLI 1.0
Hope this helps.

The term 'Set-AzureRmVMPlan' is not recognized as the name of a cmdlet

I am trying to create a VM on Azure using powershell script in Azure Automation. This VM is to be created from marketplace. So I need to use cmdlet 'Set-AzureRmVMPlan' in my script.
$vm = New-AzureRmVMConfig -VMName $inVMName -VMSize $vmSize
Set-AzureRmVMPlan -VM $vm -Publisher "kali-linux" -Product
"kali-linux" -Name "kali"
This script works fine when I run it from Powershell ISE however when I put this command in Azure Automation Runbook then Azure doesn't recognize this command. I get below error,
Set-AzureRmVMPlan : The term 'Set-AzureRmVMPlan' is not recognized as
the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try
again.
At restore-vhd-backups:8 char:8
CategoryInfo : ObjectNotFound: (Set-AzureRmVMPlan:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
So I further investigate and found that this command is not available in cmdlet list at page "Edit PowerShell Runbook" (see below image)
I also got to know that this cmdlet was added in Azure Powershell last year from below link
How to include "Plan information" when creating ARM VM from a captured image using Powershell?
Can someone help me on this?
So what is happening here, Azure Automation uses the old version of the Module, you have to go to Azure Automation Blade > Assets > Modules > Browse Gallery and reimport AzureRM.Profile and AzureRM.Compute.

Resources