ThomasKur / IntuneDocumentation

Automatic Intune Documentation to simplify the life of admins and consultants.
GNU General Public License v3.0
339 stars 87 forks source link

Script does not login to my tenant #51

Closed CW-RKR closed 3 years ago

CW-RKR commented 3 years ago

Does not work. All ID's are redacted for security reason. I am the Global Admin of that tenant.

PS C:\temp> $p = New-IntuneDocumentationAppRegistration
PS C:\temp> $p | fl

ClientID               : 31ddbfbd-563f-
ClientSecret           : zbvSsjZcvr
ClientSecretExpiration : 18.02.2022 00:11:21
TenantId               : be398df7-

PS C:\temp> Invoke-IntuneDocumentation -FullDocumentationPath c:\temp\IntuneDoc.docx

Here I am asked for Admin consent and granted it


UPN                               TenantId
---                               --------
admin@x.onmicrosoft.com           be398df7-

Es ist nicht möglich, eine Methode für einen Ausdruck aufzurufen, der den NULL hat.
In C:\Program Files\WindowsPowerShell\Modules\IntuneDocumentation\2.0.19\Internal\Get-MobileAppsBeta.ps1:18 Zeichen:9
+         $errorResponse = $ex.Response.GetResponseStream()
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Get-IntuneAppProtectionPolicy : 400 Bad Request
{
  "error": {
    "code": "AuthenticationError",
    "message": "Error authenticating with resource",
    "innerError": {
      "date": "2021-02-17T23:13:43",
      "request-id": "128e1a31-43e3-4a0f-8c04
      "client-request-id": "128e1a31-43e3-4a0f
    }
  }
}
In C:\Program Files\WindowsPowerShell\Modules\IntuneDocumentation\2.0.19\Functions\Invoke-IntuneDocumentation.ps1:153 Zeichen:13
+     $MAMs = Get-IntuneAppProtectionPolicy | Where-Object { $_.'@odata ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : Verbindungsfehler: (@{Request=; Response=}:PSObject) [Get-DeviceAppMa...agedAppPolicies], HttpRequestException
    + FullyQualifiedErrorId : PowerShellGraphSDK_HttpRequestError,Microsoft.Intune.PowerShellGraphSDK.PowerShellCmdlets.Get_DeviceAppManagement_ManagedAppPolic
   ies

Get-IntuneAppProtectionPolicy : 400 Bad Request
{
  "error": {
    "code": "AuthenticationError",
    "message": "Error authenticating with resource",
    "innerError": {
      "date": "2021-02-17T23:13:43",
      "request-id": "2d59d983-ef55-
      "client-request-id": "2d59d983
    }
  }
}

Then I tried Invoke-ConditionalAccessDocumentation - this worked and I got a Word-File with content.


########################################################

PS C:\temp> Invoke-ConditionalAccessDocumentation -FullDocumentationPath c:\temp\CADoc.docx

Cmdlet Invoke-ConditionalAccessDocumentation an der Befehlspipelineposition 1
Geben Sie Werte für die folgenden Parameter an:
ClientId: 31ddbfbd-563f-
ClientSecret: zbvSsjZc
Tenant: be398df7-a2a8

#########################################################

Then I tried the other command with the same credetial details. This does NOT work.


PS C:\temp> Invoke-IntuneDocumentation -FullDocumentationPath c:\temp\IntuneDoc2.docx -ClientId 31ddbfbd-563f -ClientSecret zbvSsjZcvr -Tenant be398df7-a2a8
Es ist nicht möglich, eine Methode für einen Ausdruck aufzurufen, der den NULL hat.
In C:\Program Files\WindowsPowerShell\Modules\IntuneDocumentation\2.0.19\Internal\Get-MobileAppsBeta.ps1:18 Zeichen:9
+         $errorResponse = $ex.Response.GetResponseStream()
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Get-IntuneAppProtectionPolicy : 400 Bad Request
{
  "error": {
    "code": "AuthenticationError",
    "message": "Error authenticating with resource",
    "innerError": {
      "date": "2021-02-17T23:20:53",
      "request-id": "c644bc4c-
      "client-request-id": "c644bc4c-
    }
  }
}

My environment


PS C:\temp> Get-Module -ListAvailable *Azure*

    Verzeichnis: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     2.0.2.128  AzureAD                             {Add-AzureADApplicationOwner, Get-AzureADApplication, Get-AzureADApplicationExtensionProperty, Get-...
Binary     2.0.2.129  AzureADPreview                      {Add-AzureADApplicationOwner, Get-AzureADApplication, Get-AzureADApplicationExtensionProperty, Get-...

PS C:\temp> Get-Module -ListAvailable *Intune*

    Verzeichnis: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.0.19     IntuneDocumentation                 {Invoke-ConditionalAccessDocumentation, Invoke-IntuneDocumentation, New-IntuneDocumentationAppRegis...
Binary     6.1907.1.0 Microsoft.Graph.Intune              {New-AccessActionObject, New-ActivityHistoryItemObject, New-AlertHistoryStateObject, New-AlertObjec...
Manifest   4.8        WindowsAutoPilotIntune              {Get-AutopilotEvent, Get-AutopilotProfileAssignedDevice, Remove-AutopilotImportedDevice, Import-Aut...

PS C:\temp> Get-Module -ListAvailable *Graph*

    Verzeichnis: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     6.1907.1.0 Microsoft.Graph.Intune              {New-AccessActionObject, New-ActivityHistoryItemObject, New-AlertHistoryStateObject, New-AlertObjec...

PS C:\temp> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.610
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.610
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
CW-RKR commented 3 years ago

I found the issue by myself. My permissions where screwed up. After deleting the old account and login with a newly created global admin account everything worked without any problem.