-
Notifications
You must be signed in to change notification settings - Fork 103
Add checkup for Intune #1501
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
base: main
Are you sure you want to change the base?
Add checkup for Intune #1501
Changes from all commits
41d213b
964113b
247f558
4fa6965
66f4b32
f1f5cac
6a21012
5ba03f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package checkups | ||
|
||
import ( | ||
"context" | ||
"io" | ||
) | ||
|
||
type intuneCheckup struct{} | ||
|
||
func (i *intuneCheckup) Name() string { | ||
return "" | ||
} | ||
|
||
func (i *intuneCheckup) Run(_ context.Context, _ io.Writer) error { | ||
return nil | ||
} | ||
|
||
func (i *intuneCheckup) ExtraFileName() string { | ||
return "" | ||
} | ||
|
||
func (i *intuneCheckup) Status() Status { | ||
return Informational | ||
} | ||
|
||
func (i *intuneCheckup) Summary() string { | ||
return "" | ||
} | ||
|
||
func (i *intuneCheckup) Data() any { | ||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package checkups | ||
|
||
import ( | ||
"archive/zip" | ||
"context" | ||
"fmt" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
type intuneCheckup struct { | ||
summary string | ||
} | ||
|
||
func (i *intuneCheckup) Name() string { | ||
return "Intune" | ||
} | ||
|
||
func (i *intuneCheckup) Run(ctx context.Context, extraWriter io.Writer) error { | ||
// Other areas of interest: https://learn.microsoft.com/en-us/mem/intune/remote-actions/collect-diagnostics | ||
|
||
zipWriter := zip.NewWriter(extraWriter) | ||
defer zipWriter.Close() | ||
|
||
if err := agentLogs(zipWriter); err != nil { | ||
i.summary += fmt.Sprintf("Failed to collect Intune agent logs: %v. ", err) | ||
} | ||
|
||
if err := installLogs(zipWriter); err != nil { | ||
i.summary += fmt.Sprintf("Failed to collect Intune install logs: %v. ", err) | ||
} | ||
|
||
i.summary = strings.TrimSpace(i.summary) | ||
|
||
return nil | ||
} | ||
|
||
func agentLogs(zipWriter *zip.Writer) error { | ||
agentLogsPathPattern := filepath.Join(os.Getenv("SYSTEMROOT"), "ProgramData", "Microsoft", "IntuneManagementExtension", "Logs", "*") | ||
matches, err := filepath.Glob(agentLogsPathPattern) | ||
if err != nil { | ||
return fmt.Errorf("globbing for agent logs at %s: %w", agentLogsPathPattern, err) | ||
} | ||
if len(matches) == 0 { | ||
return fmt.Errorf("no intune agent logs found at %s", agentLogsPathPattern) | ||
} | ||
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this an error? (It will run on non-intune machines) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I just added this to make it more obvious what was going on when testing -- I'll update to remove here + below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I was mostly quibbling over |
||
|
||
for _, match := range matches { | ||
if err := addFileToZip(zipWriter, match); err != nil { | ||
return fmt.Errorf("adding %s to zip: %w", match, err) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func installLogs(zipWriter *zip.Writer) error { | ||
installLogsPathPattern := filepath.Join(os.Getenv("WINDIR"), "System32", "config", "systemprofile", "AppData", "Local", "mdm", "*.log") | ||
matches, err := filepath.Glob(installLogsPathPattern) | ||
if err != nil { | ||
return fmt.Errorf("globbing for install logs at %s: %w", installLogsPathPattern, err) | ||
} | ||
if len(matches) == 0 { | ||
return fmt.Errorf("no intune install logs found at %s", installLogsPathPattern) | ||
} | ||
|
||
for _, match := range matches { | ||
if err := addFileToZip(zipWriter, match); err != nil { | ||
return fmt.Errorf("adding %s to zip: %w", match, err) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (i *intuneCheckup) ExtraFileName() string { | ||
return "intune.zip" | ||
} | ||
|
||
func (i *intuneCheckup) Status() Status { | ||
return Informational | ||
} | ||
|
||
func (i *intuneCheckup) Summary() string { | ||
return i.summary | ||
} | ||
|
||
func (i *intuneCheckup) Data() any { | ||
return nil | ||
} |
Uh oh!
There was an error while loading. Please reload this page.