microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
696 stars 168 forks source link

Update-MgDeviceManagementWindowAutopilotDeploymentProfile: Can not update Autopilot profile #930

Closed aslan-im closed 2 years ago

aslan-im commented 2 years ago

I have tried to update the existing AutoPilot profile, but unsuccessfully: Updating simple parameter: Update-MgDeviceManagementWindowAutopilotDeploymentProfile -WindowsAutopilotDeploymentProfileId 'e299114b-4f05-4ca7-840c-6c6d75bc7776' -ExtractHardwareHash $False

Error:
Message                     : A positional parameter cannot be found that accepts argument 'False'.
ParameterName               : False
ParameterType               :
TypeSpecified               : System.Boolean
ErrorId                     : PositionalParameterNotFound
Line                        : 1
Offset                      : 5
CommandInvocation           : System.Management.Automation.InvocationInfo
ErrorRecord                 : A positional parameter cannot be found that accepts argument 'False'.
WasThrownFromThrowStatement : False
Data                        : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException              :
TargetSite                  : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, System.Exception)
StackTrace                  :    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                                 at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
HelpLink                    :
Source                      : System.Management.Automation
HResult                     : -2146233087

However it should accept boolean as in my attempt

Also tried to update OutOfBoxExperienceSettings SkipKeyboardSelectionPage:

$Params

Name                           Value
----                           -----
WindowsAutopilotDeploymentP... e299114b-4f05-4ca7-840c-6c6d75bc7776
OutOfBoxExperienceSettings     {SkipKeyboardSelectionPage}

$Params.OutOfBoxExperienceSettings

Name                           Value
----                           -----
SkipKeyboardSelectionPage      True

Output:

Error           : Microsoft.Graph.PowerShell.Models.OdataError
StatusCode      : BadRequest
Code            : ModelValidationFailure
RequestMessage  : Method: PATCH, RequestUri: 'https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/e299114b-4f05-4ca7-840c-6c6d75bc7776', Version: 1.1, Content: <null>, Headers
                  :
                  {
                    SdkVersion: Graph-powershell-1.8.0
                    SdkVersion: Graph-dotnet-1.25.1
                    FeatureFlag: 00000047
                    Cache-Control: no-store, no-cache
                    Accept-Encoding: gzip
                  }
ResponseHeaders : {[Transfer-Encoding, System.String[]], [Vary, System.String[]], [Strict-Transport-Security, System.String[]], [request-id, System.String[]]...}
ResponseBody    : {"error":{"code":"ModelValidationFailure","message":"Exception has been thrown by the target of an invocation.","innerError":{"message":"Exception has been thrown by the target of an invocat
                  ion.","date":"2021-11-03T14:11:51","request-id":"93a3ae85-5ccc-4458-af53-e1263652052d","client-request-id":"93a3ae85-5ccc-4458-af53-e1263652052d"}}}
ClientRequestId :
RequestId       :
Message         : Exception has been thrown by the target of an invocation.
Action          :
Data            : {}
InnerException  :
TargetSite      :
StackTrace      :
HelpLink        :
Source          :
HResult         : -2146233088

Module version 1.8.0

peombwa commented 2 years ago

@aslan-im, on the first issue, -ExtractHardwareHash is a switch parameter and not a boolean.


➜ Get-Help Update-MgDeviceManagementWindowAutopilotDeploymentProfile -Parameter ExtractHardwareHash

-ExtractHardwareHash [<SwitchParameter>]
    HardwareHash Extraction for the profile

    Required?                    false
    Position?                    named
    Default value                False
    Accept pipeline input?       false
    Accept wildcard characters?  false

You'll need to use like this -ExtractHardwareHash:$false to explicitly set to false.

On the second issue (also applies to the first issue), this is a service error/unsupported feature. It looks like the API does not currently support updating a windowsAutopilotDeploymentProfile. The only supported HTTP method as per the reference docs is GET, see https://docs.microsoft.com/en-us/graph/api/resources/intune-shared-windowsautopilotdeploymentprofile?view=graph-rest-beta#methods.

I would recommend you open an API feature request at https://developer.microsoft.com/en-us/graph/support for this to be added to the service.

ghost commented 2 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

aslan-im commented 2 years ago

Hi! I have raised a request for new feature: Link