Editar

Compartilhar via


New-AzBastionShareableLink

The Bastion Shareable Link feature lets users connect to a target resource (virtual machine or virtual machine scale set) using Azure Bastion without accessing the Azure portal.

Syntax

New-AzBastionShareableLink
   -ResourceGroupName <String>
   -Name <String>
   -TargetVmId <System.Collections.Generic.List`1[System.String]>
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzBastionShareableLink
   -ResourceId <String>
   -TargetVmId <System.Collections.Generic.List`1[System.String]>
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzBastionShareableLink
   -InputObject <PSBastion>
   -TargetVmId <System.Collections.Generic.List`1[System.String]>
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Creates a Bastion Shareable Links for all the VMs specified in the request.

Examples

Example 1

$vm = Get-AzVM -ResourceGroupName $RgName -Name $vmName
New-AzBastionShareableLink -ResourceGroupName $RgName -Name $bastionName -TargetVmId $vm.Id

{
  "vm": {
    "id": "/subscriptions/subid/resourceGroups/rgx/providers/Microsoft.Compute/virtualMachines/vm1"
  },
  "bsl": "http://bst-bastionhostid.bastion.com/api/shareable-url/tokenvm1",
  "createdAt": "2019-10-18T12:00:00.0000Z"
}

Example 2

$vm1 = Get-AzVM -ResourceGroupName $RgName -Name $vmName1
$vm2 = Get-AzVM -ResourceGroupName $RgName -Name $vmName2
$bastion = Get-AzBastion -ResourceGroupName $RgName -Name $bastionName
New-AzBastionShareableLink -InputObject $bastion -TargetVmId $vm1.Id, $vm2.Id

{
  "vm": {
    "id": "/subscriptions/subid/resourceGroups/rgx/providers/Microsoft.Compute/virtualMachines/vm1"
  },
  "bsl": "http://bst-bastionhostid.bastion.com/api/shareable-url/tokenvm1",
  "createdAt": "2019-10-18T12:00:00.0000Z"
},
{
  "vm": {
    "id": "/subscriptions/subid/resourceGroups/rgx/providers/Microsoft.Compute/virtualMachines/vm2"
  },
  "bsl": "http://bst-bastionhostid.bastion.com/api/shareable-url/tokenvm2",
  "createdAt": "2019-10-17T12:00:00.0000Z"
}

Creates a shareable link for specified VMs on a Bastion resource.

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

Bastion object

Type:PSBastion
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Name

The Bastion resource name

Type:String
Aliases:ResourceName, BastionName
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

The resource group name where Bastion resource exists

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceId

The Bastion resource ID

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-TargetVmId

ID of the VMs that require generation of Bastion shareable links

Type:List<T>[String]
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

List<T>[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]

SwitchParameter

Outputs

List<T>[[Microsoft.Azure.Commands.Network.Models.Bastion.PSBastionShareableLink, Microsoft.Azure.PowerShell.Cmdlets.Network, Version=7.5.0.0, Culture=neutral, PublicKeyToken=null]]