Closed deepc2020 closed 1 year ago
Hello Same Problem,
With write-M365Doccsv also the Problem
Out-File: C:\Program Files\WindowsPowerShell\Modules\M365Documentation\3.1.2\Internal\Output\Write-DocumentationCsvSection.ps1:22 Line | 22 | … eInformation -Delimiter ";" | Out-File -FilePath "$CsvPath\$Path.csv" |
~~~~~~~~~~~ | Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch. : 'D:\ITninnja\202111171804-Autopilot Profiles-AHAZ_ Autopilot profile 20210805_15:16:21.csv'
I think its a culture Problem because of swiss german the time has ": " in filenames whats forbidden .
Many thanks the idea is great
@deepc2020 do you have more information regarding your problem? Normally this just works. Are you using a normal PowerShell console or Core?
Same issue. Able to output to JSON or CSV successfully.
Can confirm the Export to word is still broken
I tested the word export last week, first try worked. I was able to get a docx with all of the info I was looking for. Fast forward to this week and the same commands are producing empty word documents... I have no idea what changed or why it would suddenly stop working.
I have tried using a normal PowerShell 5 console, PS7, and PS Core (on ubuntu).
What I noticed is that the data is there in the "$doc" powershell object. Its when you try to convert it to the word doc with Write-M365DocWord
that it fails for some reason. I can export it with the data using Write-M365DocJson
.
Here are the commands I am using:
Connect and authenticate to the cloud servers.
Connect-M365Doc
Generate a report for the "Intune Component" of MS365:
$doc = Get-M365Doc -Components Intune -ExcludeSections "MobileAppDetailed"
Output the documentation to a word file:
$doc | Write-M365DocWord -FullDocumentationPath "$env:USERPROFILE\Downloads\$($doc.CreationDate.ToString("yyyyMMddHHmm"))-Intune-Documentation.docx"
I was planning to use this module to automate monthly reports in Markdown format in a Github repository. This GH action works, but I run into the problem of getting an empty word document. Manually attempting the commands in PS5, PS7, and PS Core all end with the same empty docx template.
Here's the GH action I was using:
name: Audit Intune Policies
on:
workflow_dispatch:
jobs:
Intune_Audit:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set Variables
id: vars
shell: bash
run: |
echo "datetime=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
- name: Audit Powershell
id: pwsh
shell: pwsh
run: |
# Check correct repo was checked out
if ($github.event.repository.full_name -ne $github.repository) {
# throwing causes the step to fail
throw "something fishy's going on, repos don't match"
}
# Create folders for logs and modules
mkdir "$pwd/logs"
mkdir "$pwd/modules"
# The Get-M365Doc command later tries to write to the TEMP directory for the user which does not exist with pwsh on linux.
# We can work around this by assigning a path for the logs manually
$Env:TEMP = "$pwd/logs"
# Install dependencies
Set-PSRepository PSGallery -InstallationPolicy Trusted
Find-Module -Name 'MSAL.PS' -Repository 'PSGallery' | Save-Module -Path "$pwd/modules"
Find-Module -Name 'PSWriteWord' -Repository 'PSGallery' | Save-Module -Path "$pwd/modules"
Find-Module -Name 'M365Documentation' -Repository 'PSGallery' | Save-Module -Path "$pwd/modules"
Import-Module -FullyQualifiedName "$pwd/modules/MSAL.PS"
Import-Module -FullyQualifiedName "$pwd/modules/PSWriteWord"
Import-Module -FullyQualifiedName "$pwd/modules/M365Documentation"
# Connect to M365 using App registration
Connect-M365Doc -ClientId '${{ secrets.CLIENTID }}' -ClientSecret (ConvertTo-SecureString '${{ secrets.CLIENTSECRET }}' -AsPlainText -Force) -TenantId '${{ secrets.TENANTID }}'
# Generate report
$doc = Get-M365Doc -Components Intune -ExcludeSections "MobileAppDetailed"
# Output to word file
$doc | Write-M365DocWord -FullDocumentationPath "./Audits/Intune/${{ env.datetime }}-Intune-Audit.docx"
- name: Convert to Markdown
id: pandoc
uses: docker://pandoc/core:2.9
with:
args: >- # allows you to break string into multiple lines
-f docx
-t gfm
./Audits/Intune/${{ env.datetime }}-Intune-Audit.docx
-o ./Audits/Intune/${{ env.datetime }}-Intune-Audit.md
- name: Commit Files
id: commit
run: |
git config --local user.email "action@github.com"
git config --local user.name "github-actions"
git add ./Audits/Intune/${{ env.datetime }}-Intune-Audit.md ./Audits/Intune/${{ env.datetime }}-Intune-Audit.docx
if [-z "$(git status --porcelain)"]; then
echo "::set-output name=push::false"
else
git commit -m "Add changes" -a
echo "::set-output name=push::true"
fi
shell: bash
- name: Push changes
if: steps.commit.outputs.push == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Strange that you get an empty docx, I can't reproduce it at the moment. But will release a new version in the next days which fixes a few things. perhaps it solves also this issue. I'm also working on a Direct Export to Markdown...
Check new released version https://www.powershellgallery.com/packages/M365Documentation/3.2.0
First, thank you very much for this cool tool!
Unfortunately when i try to to generate a Word file, i get only the empty template file, json and csv are working as expected. Are there any special requirements like office or powershell version?