Azure Automation Runbook - Connect-IPPSSession Fails with 'Unable to Find Type' Error
岩瀬 玲奈
0
Reputation points
To execute Connect-IPPSSession within a Runbook: powershell
$tenantId = "Tenant ID"
$clientId = "Client (Application) ID"
$clientSecret = "Client Secret"
$tokenUrl = "
$body = @{
client_id = $clientId
client_secret = $clientSecret
scope = "
grant_type = "client_credentials"
}
$response = Invoke-RestMethod -Uri $tokenUrl -Method Post -Body $body
$accessToken = $response.access_token
Connect-IPPSSession -AccessToken $accessToken -Organization <Domain Name>
Although I’m executing the above code, I receive the following error message:
System.Management.Automation.RuntimeException: Unable to find type [Microsoft.Exchange.Management.AdminApiProvider.Utility]. at System.Management.Automation.TypeOps.ResolveTypeName(ITypeName typeName, IScriptExtent errorPos) at System.Management.Automation.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) System.Management.Automation.ParameterBindingException: A parameter cannot be found that matches parameter name 'Organization'. at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException originalBindingException) at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments) at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments) at System.Management.Automation.CommandProcessor.BindCommandLineParameters() at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues) at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues) at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream) at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input) --- End of stack trace from previous location --- at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input) at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
It seems to be an error indicating that Microsoft.Exchange.Management.AdminApiProvider.Utility cannot be found.
However, I have installed the ExchangeOnlineManagement module from the gallery (Runtime version 7.2, module version 3.8.0).
When I run the same code on my local PowerShell terminal, the above error does not appear.
I suspect it may be a module-related issue, but since I haven’t been able to resolve it, I’m reaching out for advice.
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
Sign in to answer