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
ByResourceGroupNameByName (Default)
New-AzBastionShareableLink
-ResourceGroupName <String>
-Name <String>
-TargetVmId <System.Collections.Generic.List`1[System.String]>
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByResourceId
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
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
Bastion object
Type: PSBastion
Default value: None
Supports wildcards: False
DontShow: False
ByInputObject
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Name
The Bastion resource name
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: ResourceName, BastionName
Parameter sets
ByResourceGroupNameByName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceGroupName
The resource group name where Bastion resource exists
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByResourceGroupNameByName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceId
The Bastion resource ID
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByResourceId
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-TargetVmId
ID of the VMs that require generation of Bastion shareable links
Parameter properties
Type: List<T> [ String ]
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs