Create cloudPcOnPremisesConnection using powershell

Nageswara Allam 1 Reputation point
2022-05-31T10:43:53.07+00:00

Hi

i have followed as per mentioned in the MS document, but when i try to create a Azure network connection always throws an error as mentioned in below. Can someone help on this.

Import-Module Microsoft.Graph.DeviceManagement.Administration

$params = @{
"@odata.type" = "#microsoft.graph.cloudPcOnPremisesConnection"
DisplayName = "test-canary-02"
Type = "hybridAzureADJoin"
SubscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c585ffff"
SubscriptionName = "CPC customer 001 test subscription"
AdDomainName = "contoso001.com"
AdDomainUsername = "dcadmin"
OrganizationalUnit = "OU=Domain Controllers, DC=contoso001, DC=com"
ResourceGroupId = "/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c585ad47/resourceGroups/CustomerRG"
VirtualNetworkId = "/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c585ad47/resourceGroups/CustomerRG/providers/Microsoft.Network/virtualNetworks/canary01-MyVNET"
SubnetId = "/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c585ad47/resourceGroups/CustomerRG/providers/Microsoft.Network/virtualNetworks/canary01-MyVNET/subnets/canary01-Subnet"
}

New-MgDeviceManagementVirtualEndpointOnPremisesConnection -BodyParameter $params

Error message:

PS C:\Windows\system32> New-MgDeviceManagementVirtualEndpointOnPremisesConnection -BodyParameter $params
New-MgDeviceManagementVirtualEndpointOnPremisesConnection : Cannot process request due to invalid input.
At line:1 char:1

  • New-MgDeviceManagementVirtualEndpointOnPremisesConnection -BodyParame ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidOperation: ({ body = Micros...sesConnection }:<>f__AnonymousType741) [New-MgDeviceMan...nnection_Create], RestException1
  • FullyQualifiedErrorId : badRequest,Microsoft.Graph.PowerShell.Cmdlets.NewMgDeviceManagementVirtualEndpointOnPremisesConnection_Create

PS C:\Windows\system32>

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,568 questions
0 comments No comments
{count} votes