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

automate-intune-documentation-azure/ #14

Open
utterances-bot opened this issue May 6, 2022 · 17 comments
Open

automate-intune-documentation-azure/ #14

utterances-bot opened this issue May 6, 2022 · 17 comments

Comments

@utterances-bot
Copy link

Automate Microsoft Intune As-Built Documentation on Azure DevOps | Aaron Parker

Using Azure Pipelines to automate the backup of Microsoft Intune and generate an as-built document.

https://stealthpuppy.com/automate-intune-documentation-azure/

Copy link

chield commented May 6, 2022

Hey Aaron, thanks for this article, always good to try to automate the Intune environment. In the last step of the pipeline I receive an error with the Convert markdown to PDF step.

##[error]Bash wrote one or more lines to the standard error stream.
##[error]cat:
##[error]/home/vsts/work/1/s/prod-as-built.md
##[error]: No such file or directory

Can you point me in the right direction to fix this? Thanks!

Kind regards,
Michiel

@aaronparker
Copy link
Owner

Can you see prod-as-built.md in the repo? If not, there must be an earlier error in creating the backup and the markdown or committing the files to the repository.

Copy link

chield commented May 7, 2022

Hi Aaron, thanks for the quick reply! When I remove the prod-as-built.md from the .gitignore file, it gets greated after running the pipeline (without any errors), but the .md file isn't being converted to an pdf-file. Any ideas left? ;)

Copy link

Hi Aaron, thanks for your article. I currently have an issue with the conversion of the markdown. If there are large image files in the backup I run into a RangeError. Tried shortening the lines by adding a cut command to the pipes but that didn't help. Can you suggest a solution to this problem?

@aaronparker
Copy link
Owner

@SHellSys not something I've run into. What are the image files or what configuration are they stored in?

Copy link

SHellSys commented Aug 1, 2023

I am rolling out corporate identity wallpapers on several OS (e.g. iOS Wallpaper JPEG in a configuration profile). They create a 612.000 column wide configuration block in the md file. Not just the image data but the whole configuration block is now that size, resulting in huge areas of whitespace.

Copy link

SHellSys commented Aug 1, 2023

Hi Aaron, I just fixed the problem I mentioned by adding the parameter --maxlength=5000 to the IntuneCD-startdocumentation command. I also had to mark the two conversion steps to not fail on Stderr since md-to-pdf is printing a deprecation warning to the error channel.

Copy link

ztrhgf commented Sep 20, 2023

When using provided YML for pipeline creation in Azure DevOps, the pipeline fails with:

  • branch main -> FETCH_HEAD
  • [new branch] main -> origin/main
    hint: You have divergent branches and need to specify how to reconcile them.
    hint: You can do so by running one of the following commands sometime before
    hint: your next pull:
    hint:
    hint: git config pull.rebase false # merge
    hint: git config pull.rebase true # rebase
    hint: git config pull.ff only # fast-forward only
    hint:
    hint: You can replace "git config" with "git config --global" to set a default
    hint: preference for all repositories. You can also pass --rebase, --no-rebase,
    hint: or --ff-only on the command line to override the configured default per
    hint: invocation.
    fatal: Need to specify how to reconcile divergent branches.
    ##[error]Bash exited with code '128'.

In PUBLISH section, step PULL ORIGIN.

Any ideas what is going on and how YML/pipeline should be modified to get rid of this error?

Thanks!

Copy link

ztrhgf commented Sep 20, 2023

ignore it..seems to be working on next run

@aaronparker
Copy link
Owner

In the initial Backup configuration and generate markdown phase, did the git push step complete successfully

@ztrhgf
Copy link

ztrhgf commented Sep 20, 2023

Not sure which particular pipeline step you mean? But the red error icon is only in the mentioned step.

Anyway, if some change is made in the Intune environment and new pipeline run is being invoked, the problem is fixed...But on the next run (no change in the Intune is made) I again receive this error...

I've customized the TAG name in my YML. Can this be related?

@ztrhgf
Copy link

ztrhgf commented Sep 20, 2023

Error screenshot intunecd_err

@aaronparker
Copy link
Owner

aaronparker commented Sep 20, 2023

You could try remove the Pull origin step in the Publish phase and see whether the pipeline completes OK, as the first step checks out the repo anyway.

Copy link

ztrhgf commented Sep 26, 2023

Seems this helped thanks!

Copy link

hugo-kreuk commented Dec 28, 2023

Hey Aaron, i'm very interested to get this working in my environment but I do not seem to get it up and running. I get an error when te backup starts.

Can you suggest a solution to this problem?

2023-12-28T15:19:21.8893016Z ##[section]Starting: IntuneCD backup
2023-12-28T15:19:21.8896956Z ==============================================================================
2023-12-28T15:19:21.8897074Z Task         : Bash
2023-12-28T15:19:21.8897140Z Description  : Run a Bash script on macOS, Linux, or Windows
2023-12-28T15:19:21.8897223Z Version      : 3.231.4
2023-12-28T15:19:21.8897280Z Author       : Microsoft Corporation
2023-12-28T15:19:21.8897344Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
2023-12-28T15:19:21.8897455Z ==============================================================================
2023-12-28T15:19:22.0521740Z Generating script.
2023-12-28T15:19:22.0543385Z ========================== Starting Command Output ===========================
2023-12-28T15:19:22.0548911Z [command]/usr/bin/bash /home/vsts/work/_temp/c077e5e3-4791-459d-a061-4310fc6ebafa.sh
2023-12-28T15:19:23.0591967Z Traceback (most recent call last):
2023-12-28T15:19:23.0592713Z   File "/home/vsts/.local/bin/IntuneCD-startbackup", line 8, in <module>
2023-12-28T15:19:23.0593117Z     sys.exit(start())
2023-12-28T15:19:23.0593515Z   File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/run_backup.py", line 271, in start
2023-12-28T15:19:23.0593782Z     run_backup(
2023-12-28T15:19:23.0594177Z   File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/run_backup.py", line 218, in run_backup
2023-12-28T15:19:23.0594483Z     backup_intune(results, path, output, exclude, token, prefix, append_id, args)
2023-12-28T15:19:23.0594930Z   File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/backup_intune.py", line 14, in backup_intune
2023-12-28T15:19:23.0595239Z     results.append(savebackup(path, output, exclude, token, prefix, append_id))
2023-12-28T15:19:23.0595709Z   File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/backup/Intune/backup_AppProtection.py", line 49, in savebackup
2023-12-28T15:19:23.0596025Z     assignments = get_object_assignment(profile["id"], assignment_responses)
2023-12-28T15:19:23.0596504Z   File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/intunecdlib/graph_batch.py", line 284, in get_object_assignment
2023-12-28T15:19:23.0597020Z     assignments_list = [
2023-12-28T15:19:23.0597333Z TypeError: 'NoneType' object is not iterable
2023-12-28T15:19:23.0926460Z ##[error]Bash exited with code '1'.
2023-12-28T15:19:23.0934255Z ##[error]Bash wrote one or more lines to the standard error stream.
2023-12-28T15:19:23.0936247Z ##[error]Traceback (most recent call last):
  File "/home/vsts/.local/bin/IntuneCD-startbackup", line 8, in <module>
    sys.exit(start())
  File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/run_backup.py", line 271, in start
    run_backup(
  File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/run_backup.py", line 218, in run_backup
    backup_intune(results, path, output, exclude, token, prefix, append_id, args)
  File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/backup_intune.py", line 14, in backup_intune
    results.append(savebackup(path, output, exclude, token, prefix, append_id))
  File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/backup/Intune/backup_AppProtection.py", line 49, in savebackup
    assignments = get_object_assignment(profile["id"], assignment_responses)
  File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/intunecdlib/graph_batch.py", line 284, in get_object_assignment
    assignments_list = [
TypeError: 'NoneType' object is not iterable

2023-12-28T15:19:23.0939416Z ##[section]Finishing: IntuneCD backup

Copy link

Hey Aaron, when I exclude the assignments

IntuneCD-startbackup
--mode=1
--output=json
--path="$(Build.SourcesDirectory)/prod-backup"
--exclude assignments
--append-id
workingDirectory: '$(Build.SourcesDirectory)'
failOnStderr: true

Almost everything works as expected. The pdf artifact is corrupt

@aaronparker
Copy link
Owner

@hugo-kreuk the first error looks like an issue with IntuneCD, so you may need to log an issue on the IntuneCD repo.

For the second issue, open the markdown in VSCode or similar, and see what that looks like. It will be a big file, but it might give some indication as to what the issue is. You can try a PDF conversion locally, and see what the generated file is like.

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

6 participants