Repository navigation
feat(harness): preview a run with -WhatIf instead of half-running it #90
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ function Invoke-IntuneDetectionTest { | |
| .SYNOPSIS | ||
| Runs a Win32 custom detection script like Intune and returns the verdict. | ||
| #> | ||
| [CmdletBinding()] | ||
| [CmdletBinding(SupportsShouldProcess)] | ||
| [OutputType('IntuneScriptLab.DetectionResult')] | ||
| param( | ||
| [Parameter(Mandatory, Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName)] | ||
|
|
@@ -40,6 +40,12 @@ function Invoke-IntuneDetectionTest { | |
| # host exists, and x64 elsewhere | ||
| if (-not $Architecture) { $Architecture = Get-IslHostArchitecture } | ||
|
|
||
| # The script is somebody's code and is about to run: -WhatIf names it and runs nothing | ||
| $action = "Run as a Win32 detection script ($Context context, $Architecture)" | ||
| if (-not $PSCmdlet.ShouldProcess($Path, $action)) { | ||
|
Owner
Author
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. The question is asked after the arguments are checked and before the signature check, so a preview reports a bad argument as a run would and reads nothing from the script. The impact is the default, Medium: nothing asks unless the caller passes |
||
| return | ||
| } | ||
|
|
||
| $reasons = [System.Collections.Generic.List[string]]::new() | ||
| $signatureStatus = '' | ||
| $run = $null | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The install counts of the apps come from a report export job, and creating one is a POST that needs a ReadWrite scope. It is the one write this command makes to the tenant, so
-WhatIfleaves it out and the device columns of the apps stay empty, as they do with-SkipRunState. The reads are not asked about: a preview that returned nothing would be of no use here.