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

Intune Bash Scripts and Settings Catalogue #67

Closed boivinx7 closed 1 year ago

boivinx7 commented 2 years ago

Hi There Great freaking module!! If someone has a idea on how to add Settings Catalogue i dont know Scripting with Word well enough. Also mac Bash script are not working, but that i might be able to fix and send a merge request.

boivinx7 commented 2 years ago

ok got the Function for Shell scripts but i have no idea how to add it to the full script i tried but its making errors.

`Function Get-DeviceShellScript(){ <# .SYNOPSIS This function is used to get the Intune PowerShell Scripts from the Graph API REST interface .DESCRIPTION The function connects to the Graph API Interface and gets the Intune PowerShell Scripts including the scripts .EXAMPLE Get-DeviceManagementScript Returns the Enrollment Status Page Configuration configured in Intune .NOTES NAME: Get-DeviceManagementScript

>

    try {
        $uri = "https://graph.microsoft.com/Beta/deviceManagement/deviceShellScripts"
        $request= (Invoke-MSGraphRequest -Url $uri -HttpMethod GET)
        $allScripts= @()

        $request.value.GetEnumerator() | ForEach-Object {

            $currentScript = Invoke-MSGraphRequest -HttpMethod GET -Url "https://graph.microsoft.com/Beta/deviceManagement/deviceShellScripts/$($PSItem.id)"

            $allScripts += [PSCustomObject]@{
                id = $currentScript.id
                displayName = $currentScript.displayName
                description = $currentScript.description
                enforceSignatureCheck = $PSItem.enforceSignatureCheck
                runAs32Bit = $PSItem.runAs32Bit
                runAsAccount = $PSItem.runAsAccount
                fileName = $PSItem.fileName
                scriptContent = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($currentScript.scriptContent))
            }
        }
        $allScripts
    } catch {
        $ex = $_.Exception
        $errorResponse = $ex.Response.GetResponseStream()
        $reader = New-Object System.IO.StreamReader($errorResponse)
        $reader.BaseStream.Position = 0
        $reader.DiscardBufferedData()
        $responseBody = $reader.ReadToEnd();
        Write-Log "Response content:`n$responseBody" -Type Error
        Write-Log "Request to $Uri failed with HTTP Status $($ex.Response.StatusCode) $($ex.Response.StatusDescription)" -Type Error
    }

}`

ThomasKur commented 1 year ago

Please use the evolved M365Documentation script which provides more options: https://www.wpninjas.ch/2021/05/automatic-intune-documentation-evolves-to-automatic-microsoft365-documentation/