Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceConfiguration_Import_FromJSON.ps1 #271

Open
davenish opened this issue May 20, 2024 · 6 comments
Open

DeviceConfiguration_Import_FromJSON.ps1 #271

davenish opened this issue May 20, 2024 · 6 comments

Comments

@davenish
Copy link

DeviceConfiguration_Import_FromJSON.ps1 is no longer working

@charliedontsurf
Copy link

Not OP but when I run DeviceConfiguration_Import_FromJSON.ps1

Please specify your user principal name for Azure Authentication: [email protected]

Checking for AzureAD module...
AzureAD PowerShell module not found, looking for AzureADPreview
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\Program
Files\WindowsPowerShell\Modules\AzureADPreview\2.0.2.183\Microsoft.IdentityModel.Clients.ActiveDirectory.dll' or one
of its dependencies. The system cannot find the file specified."
At C:\Users\Mikey\Desktop\DeviceConfiguration\DeviceConfiguration_Import_FromJSON.ps1:87 char:1

  • [System.Reflection.Assembly]::LoadFrom($adal) | Out-Null
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : FileNotFoundException
    
    

Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\Program
Files\WindowsPowerShell\Modules\AzureADPreview\2.0.2.183\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll'
or one of its dependencies. The system cannot find the file specified."
At C:\Users\redacted\Desktop\DeviceConfiguration\DeviceConfiguration_Import_FromJSON.ps1:89 char:1

  • [System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : FileNotFoundException
    
    

Cannot find type [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext]: verify that the assembly containing this type is loaded.

@andreea1987
Copy link

@charliedontsurf To fix that error just run Install-Module -Name AzureAD -RequiredVersion 2.0.2.140 and Install-Module -Name Microsoft.Graph
Now I’m getting a different error, seems like the script is incomplete.
Test-Path : Cannot bind argument to parameter 'Path' because it is an empty string. At C:\Intune\DeviceConfiguration_Import_FromJSON.ps1:317 char:21 + If (Test-Path -Path $FileName -Type Leaf) { + ~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.Test PathCommand You cannot call a method on a null-valued expression. At C:\Intune\DeviceConfiguration_Import_FromJSON.ps1:324 char:1 + $ImportPath = $ImportPath.replace('"','') + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Test-Path : Cannot bind argument to parameter 'Path' because it is an empty string. At C:\Intune\DeviceConfiguration_Import_FromJSON.ps1:326 char:16 + if(!(Test-Path "$ImportPath")){ + ~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.Test PathCommand Get-Content : Cannot bind argument to parameter 'Path' because it is an empty string. At C:\Intune\DeviceConfiguration_Import_FromJSON.ps1:337 char:17 + $JSON_Data = gc "$ImportPath" + ~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.GetC ontentCommand ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null. At C:\Intune\DeviceConfiguration_Import_FromJSON.ps1:340 char:30 + $JSON_Convert = $JSON_Data | ConvertFrom-Json | Select-Object -Proper ... + ~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [ConvertFrom-Json], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertFrom JsonCommand

@humphreysl
Copy link

I too am having the same issue. This is preventing me from importing the NCSC recommended baselines in to my Tenant. The DeviceConfiguration_Import_FromJSON.ps1 script no longer works, and I have no idea how to import their JSON profiles in to my Tenant: https://github.com/ukncsc/Device-Security-Guidance-Configuration-Packs#microsoft-endpoint-manager

@humphreysl
Copy link

I too am having the same issue. This is preventing me from importing the NCSC recommended baselines in to my Tenant. The DeviceConfiguration_Import_FromJSON.ps1 script no longer works, and I have no idea how to import their JSON profiles in to my Tenant: https://github.com/ukncsc/Device-Security-Guidance-Configuration-Packs#microsoft-endpoint-manager

FYI - Resolution

It seems the instructions are not very helpful, but if you unpick the PS Script, you will notice a comment that states to create an App Registration in Azure and provide the Client ID to the PS Script. If you use the specific AzureAD Module version listed in this thread, and then create an App Registration in Azure, set the App Registration to use the Redirect URI as per the Script, and grant the App Registration the MS Graph Permission "DeviceManagementConfiguration.ReadWrite.All" as required by the Script, you will be able to import JSON Profiles.

@dcw77
Copy link

dcw77 commented Nov 25, 2024

I too am having the same issue. This is preventing me from importing the NCSC recommended baselines in to my Tenant. The DeviceConfiguration_Import_FromJSON.ps1 script no longer works, and I have no idea how to import their JSON profiles in to my Tenant: https://github.com/ukncsc/Device-Security-Guidance-Configuration-Packs#microsoft-endpoint-manager

FYI - Resolution

It seems the instructions are not very helpful, but if you unpick the PS Script, you will notice a comment that states to create an App Registration in Azure and provide the Client ID to the PS Script. If you use the specific AzureAD Module version listed in this thread, and then create an App Registration in Azure, set the App Registration to use the Redirect URI as per the Script, and grant the App Registration the MS Graph Permission "DeviceManagementConfiguration.ReadWrite.All" as required by the Script, you will be able to import JSON Profiles.

I applied this suggested fix but it didn't change anything I still encounter an error

MethodInvocationException: C:\Users\user\OneDrive\Terraform\AVD Intune\DeviceConfiguration_Import_FromJSON.ps1:89 Line | 89 | [System.Reflection.Assembly]::LoadFrom($adal) | Out-Null | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'C:\Program Files\WindowsPowerShell\Modules\AzureADPreview\2.0.2.183\Microsoft.IdentityModel.Clients.ActiveDirectory.dll'. The | system cannot find the file specified." MethodInvocationException: C:\Users\user\OneDrive\AVD Intune\DeviceConfiguration_Import_FromJSON.ps1:91 Line | 91 | [System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'C:\Program | Files\WindowsPowerShell\Modules\AzureADPreview\2.0.2.183\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll'. The system cannot find the file specified." Cannot find type [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext]: verify that the assembly containing this type is loaded.

image

@dcw77
Copy link

dcw77 commented Nov 25, 2024

#255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants