Comments (19)
Hi all,
We are aware of the failure of importing the module into Azure Automation, we are looking into it.
Dave
from intune-powershell-sdk.
Through the LoaderExceptions, found out that it suddenly requires the SignalR.Client version 2.4.0 .
Updated my fork to reflect this and with a new release.
https://github.com/HackershubNL/Intune-PowerShell-SDK/releases
You can use the following snippet to import it:
wget -uri "https://github.com/HackershubNL/Intune-PowerShell-SDK/releases/download/1902-AzAutomationFixPlusUpdatedDependencies/Microsoft.Graph.Intune.zip" -outfile "Microsoft.Graph.Intune.zip"
Unblock-File Microsoft.Graph.Intune.zip
Expand-Archive Microsoft.Graph.Intune.zip
Import-Module .\Microsoft.Graph.Intune\Microsoft.Graph.Intune.psd1 -Scope Local -Force
I've tested it with a brand new Automation Account and no other modules are required.
from intune-powershell-sdk.
I'm very pleased to say that we were able to work with the Azure Automation team to find a solution. This issue is now fixed in the latest version (6.1907.1.0) of the module on PowerShell Gallery!
I was able to run this script in Azure Automation:
# Import the module
Write-Host 'Installing...'
Install-Module Microsoft.Graph.Intune -Force -AcceptLicense
# Log into test tenant
Write-Host 'Logging in...'
$creds = Get-AutomationPSCredential -Name 'your-credential-name' # To create credentials in Azure Automation: https://docs.microsoft.com/en-us/azure/automation/shared-resources/credentials#creating-a-new-credential-asset
Connect-MSGraph -PSCredential $creds
# Run a simple cmdlet (no network traffic)
Write-Host 'Get current MSGraph environment parameters'
Get-MSGraphEnvironment
# Make a call to Microsoft Graph using the cmdlets
Write-Host 'List all mobile apps'
Get-IntuneMobileApp
I will close this now, but please feel free to keep discussing if there are any more issues.
from intune-powershell-sdk.
Have the same problem with the module being loaded in the powershell VSCode module. Same error as in the module load:
Import-Module : Mindestens ein Typ in der Assembly kann nicht geladen werden. Rufen Sie die LoaderExceptions-Eigenschaft ab, wenn Sie weitere Informationen benötigen.
At line:1 char:1
- Import-Module microsoft.graph.intune
-
+ CategoryInfo : NotSpecified: (:) [Import-Module], ReflectionTypeLoadException + FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand
(sorry for german error, it says something like - an assembly cannot be loaded and you should retrieve the LoaderException property to get a detailed error)
from intune-powershell-sdk.
Ran into the same issue but after poking around in the LoaderExceptions, it turned out that two assemblies were missing.
Could not load file or assembly 'Microsoft.AspNet.SignalR.Client, Version=2.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.AspNet.SignalR.Client, Version=2.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.AspNet.SignalR.Client, Version=2.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
It is a bit of a hack job and not very efficient but it runs with the following code. It will download the assemblies and the SDK, load the assemblies and then imports the module.
wget -uri "https://github.com/Microsoft/Intune-PowerShell-SDK/releases/download/1902/Intune-PowerShell-SDK_v6.1902.00758.0001-release-97194499-net471.zip" -outfile "Intune-PowerShell-SDK.zip"
wget -uri "https://www.nuget.org/api/v2/package/Microsoft.AspNet.SignalR.Client/2.2.1.0" -outfile "Microsoft.AspNet.SignalR.Client.zip"
wget -uri "https://www.nuget.org/api/v2/package/Cquential.Microsoft.Practices.ServiceLocation/1.0.0" -outfile "Cquential.Microsoft.Practices.ServiceLocation.zip"
Unblock-File Intune-PowerShell-SDK.zip
Unblock-File Microsoft.AspNet.SignalR.Client.zip
Unblock-File Cquential.Microsoft.Practices.ServiceLocation.zip
Expand-Archive Intune-PowerShell-SDK.zip
Expand-Archive Microsoft.AspNet.SignalR.Client.zip
Expand-Archive Cquential.Microsoft.Practices.ServiceLocation.zip
Add-Type -Path .\Cquential.Microsoft.Practices.ServiceLocation\lib\net35\Microsoft.Practices.ServiceLocation.dll
Add-Type -Path .\Microsoft.AspNet.SignalR.Client\lib\net45\Microsoft.AspNet.SignalR.Client.dll
try
{
Import-Module .\Intune-PowerShell-SDK\drop\outputs\build\Release\net471\Microsoft.Graph.Intune.psd1 -Scope Local -Force
}
catch
{
$_.Exception.GetBaseException().LoaderExceptions
}
$login = Get-AutomationPSCredential -Name 'YourCredentialName'
$connection = Connect-MSGraph -PSCredential $login
Get-IntuneManagedDevice
from intune-powershell-sdk.
Created a patched version which can be loaded into a runbook using Import-Module. It still refuses to be imported into an Automation Account though.
https://github.com/HackershubNL/Intune-PowerShell-SDK/releases/tag/1902-AzAutomationFix%60
wget -uri "https://github.com/HackershubNL/Intune-PowerShell-SDK/releases/download/1902-AzAutomationFix%60/Microsoft.Graph.Intune.zip" -outfile "Microsoft.Graph.Intune.zip"
Unblock-File Microsoft.Graph.Intune.zip
Expand-Archive Microsoft.Graph.Intune.zip
Import-Module .\Microsoft.Graph.Intune\Microsoft.Graph.Intune.psd1 -Scope Local -Force
from intune-powershell-sdk.
Sounds really great!! I will test it today, for new automations this will be really great, i had to recreated the functions using just Rest API for last job and it was a lot of work.
Thanks!!!
from intune-powershell-sdk.
Hi, I'm trying to get this working as well. Could we expect a fix for the Azure Automation import?
Hackershubnl, I've tried your patch but it seems to fail as well.
Import-Module : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more
information.
At line:18 char:1
+ Import-Module .\Microsoft.Graph.Intune\Microsoft.Graph.Intune.psd1 -S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], ReflectionTypeLoadException
+ FullyQualifiedErrorId :
System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand
Thanks!
from intune-powershell-sdk.
I am having a similar issue, but am not using Azure Automation.
PS C:\WINDOWS\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.503
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.503
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\WINDOWS\system32> Get-Module -Name Microsoft.Graph.Intune -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 6.1902.... Microsoft.Graph.Intune {New-ActivityHistoryItemObject, New-AlertObject, New-Alert...
PS C:\WINDOWS\system32> Import-Module -Name Microsoft.Graph.Intune
Import-Module : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more
information.
At line:1 char:1
+ Import-Module -Name Microsoft.Graph.Intune
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], ReflectionTypeLoadException
+ FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.ImportModule
Command
PS C:\WINDOWS\system32> $Error[0].Exception.GetBaseException().loaderexceptions
Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=6.2.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
from intune-powershell-sdk.
Microsoft.WindowsAzure.Storage seems to be Azure.Storage module according to the Microsoft docs. Maybe try installing it with:
Install-Module Azure.Storage
And try again. When you get another exception keep going through the LoaderExceptions to see which one is missing, find the module, install it and try again :)
from intune-powershell-sdk.
Thank you, @HackershubNL. I retried after installing Azure.Storage and its dependency AzureRM.Profile, but the error is the same when trying to import the Microsoft.Graph.Intune module. Still has an issue with the Microsoft.WindowsAzure.Storage assembly
from intune-powershell-sdk.
That's a bit of odd issue. Since it is looking for version 6.2.0 another debugging option would be to download the DLL from the NuGet gallery and importing it by hand:
- Download .nupkg file from https://www.nuget.org/api/v2/package/WindowsAzure.Storage/6.2.0
- Unblock the file otherwise the DLL won't run
- Change file extension to .zip
- Extract the DLL from windowsazure.storage.6.2.0.zip\lib\net40\
- Import into PowerShell with:
Add-Type -Path .\Microsoft.WindowsAzure.Storage.dll
- Import Intune module
from intune-powershell-sdk.
@davefalkus already a plan when this will be resolved or should we still implement some workarounds?
from intune-powershell-sdk.
I'm working with the Azure Automation team to find a solution. I'm not sure when we will get this fixed, but we're actively working on this.
In the meantime, I've put some snippets together (thanks @HackershubNL!) to workaround the issue while still using the version of the Intune PowerShell SDK in the PowerShell Gallery:
# Get SignalR.Client
wget -uri "https://www.nuget.org/api/v2/package/Microsoft.AspNet.SignalR.Client/2.4.0.0" -outfile "Microsoft.AspNet.SignalR.Client.zip"
Unblock-File Microsoft.AspNet.SignalR.Client.zip
Expand-Archive Microsoft.AspNet.SignalR.Client.zip
Add-Type -Path .\Microsoft.AspNet.SignalR.Client\lib\net45\Microsoft.AspNet.SignalR.Client.dll
# Get Practices.ServiceLocation
wget -uri "https://www.nuget.org/api/v2/package/Cquential.Microsoft.Practices.ServiceLocation/1.0.0" -outfile "Cquential.Microsoft.Practices.ServiceLocation.zip"
Unblock-File Cquential.Microsoft.Practices.ServiceLocation.zip
Expand-Archive Cquential.Microsoft.Practices.ServiceLocation.zip
Add-Type -Path .\Cquential.Microsoft.Practices.ServiceLocation\lib\net35\Microsoft.Practices.ServiceLocation.dll
# Install the module
Write-Host 'Installing...'
Install-Module Microsoft.Graph.Intune -Force -AcceptLicense
# Import the module
Write-Host 'Importing...'
try {
Import-Module Microsoft.Graph.Intune
} catch [System.Reflection.ReflectionTypeLoadException] {
$_.Exception.GetBaseException().loaderexceptions
exit
}
# Log into test tenant
Write-Host 'Logging in...'
$creds = Get-AutomationPSCredential -Name 'your-credential-name' # To create credentials in Azure Automation: https://docs.microsoft.com/en-us/azure/automation/shared-resources/credentials#creating-a-new-credential-asset
Connect-MSGraph -PSCredential $creds
# Run a simple cmdlet (no network traffic)
Write-Host 'Get current MSGraph environment parameters'
Get-MSGraphEnvironment
# Make a call to Microsoft Graph using the cmdlets
Write-Host 'List all mobile apps'
Get-IntuneMobileApp
UPDATE: @bmcder rightly mentioned that the "PowerShellGet" module needs to be installed/updated in Azure Automation. This module depends on the "PackageManagement" module, so this needs to be installed first. These modules can be installed into Azure Automation from the Modules Gallery.
More about installing Azure Automation modules: https://docs.microsoft.com/en-us/azure/automation/automation-runbook-gallery#modules-in-powershell-gallery
from intune-powershell-sdk.
The proposed workaround will not work to import the module into Azure Automation due to the lack of NuGet in that environment.
from intune-powershell-sdk.
@bmcder The NuGet executable should not be required, since we are using the wget
cmdlet to download the package and the Expand-Archive
cmdlet to extract the needed files.
Could you please share the error you are seeing?
from intune-powershell-sdk.
Thanks Rohit for making me re-check this.
It was originally failing with an error on this line...
Install-Module Microsoft.Graph.Intune -Force -AcceptLicense
...stating that -AcceptLicense was an unknown parameter. On removing that, I received a NuGet related error running the same line (apologies I don't have a copy of that error).
Today I engaged my brain and checked the history of the Install-Module command to learn that the -AcceptLicense switch was added in PowerShell v6.
So I imported the latest PowerShellGet module (today this is version 2.1.5) into the Automation Account, which required I first import the PackageManagement module (today this is version 1.4.2). After that I added the -AcceptLicense switch back in and all was good :)
from intune-powershell-sdk.
Thanks @bmcder for sharing the fix for your error! Good to know that -AcceptLicense
is only available in PowerShell v6 and above.
from intune-powershell-sdk.
FYI, this is avalible in nuget and can be downloaded with find-module "microsoft.graph.intune"|install-module"
assuming you have powershell 5 or newer.
In Azure Automation this can be selected if you use the module gallery in your azure automation account
from intune-powershell-sdk.
Related Issues (20)
- New-IntuneRoleAssignment gives badrequest
- Get-IntuneManagedDevice returns all devices in a single result
- Get-IntuneDeviceConfigurationPolicy Encrypted omasettings
- Could not create IntuneAppProtectionPolicyiOS policy when assignments are provided HOT 2
- Get-IntuneMobileApp and Get-DeviceAppManagement_MobileApps not retrieving macOS LoB Apps
- This repo is missing important files HOT 2
- Where is Disconnect-MSGraph? HOT 1
- Get-AADGroupmember doesn't work on groups that have a source of Windows Server AD HOT 1
- Exclude Microsoft Intune PowerShell from Compliance Policy
- Security & Compliance Center connection error
- Exchange Online Prerequisite Check Failure HOT 1
- Unable to Connect-msgraph using client secret or cert
- Error on Invoke-IntuneManagedDeviceSyncDevice
- Error on New-MgDeviceManagementDeviceEnrollmentConfiguration HOT 1
- H
- Connect Graph issues
- Get-IntuneMobileApp Productversion parameter shows the wrong data
- Update-mgdevicemanagementmanageddevice -devicecategory HOT 1
- 504 Gateway Timeout when using Get-IntuneManagedDevice | Get-MSGraphAllPages HOT 1
- Assignments missing from get-intunemobileapp output
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intune-powershell-sdk.