Remove Azure Hybrid Connection objects

There is currently no cmdlet to easily remove an Azure Hybrid Connection object (from an App Service Plan).
So in a case you need to remove several connection objects, doing it from the protal is tedious.

This is why I created the following script:

# Login to Azure
# Select a specific subscription for the context
Get-AzureRmSubscription | Out-GridView -PassThru -Title 'Select Subscription' | Select-AzureRmSubscription
# Get all the Hybrid Connections from all namespaces in all resource groups
$hybridConnections = Get-AzureRmResource -ResourceType Microsoft.Relay/namespaces | ForEach-Object {
$resourceGroupName = $_.ResourceGroupName
Get-AzureRmRelayHybridConnection -ResourceGroupName $resourceGroupName -Namespace $namespace.Name | ForEach-Object {
$resourceName = '{0}/{1}' -f ($_.Id -split '/')[-3,-1]
Get-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Relay/Namespaces/HybridConnections `
-ApiVersion 2016-07-01 -ResourceName $resourceName | Select-Object @{N='ResourceGroupName';E={$resourceGroupName}},
# Ask which connection to delete
$hybridConnections | Out-GridView -PassThru -Title 'Select the Hybrid Connections you want to delete' | ForEach-Object {
Remove-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Relay/Namespaces/HybridConnections `
-ApiVersion 2016-07-01 -ResourceName $_.ResourceName -Force


Set the minimum TLS version to 1.2 on your AzureRM AppServices

There is currently no cmdlet to easily set the minimum TLS version on an Azure App Service. But it can be accomplished by calling the Set-AzureRMResource cmdlet with the relevant parameters

# Login to Azure
# Iterate all sites and set the Minimum TLS version to 1.2 (SSL Settings)
Get-AzureRmResource -ResourceType Microsoft.Web/sites | ForEach-Object {
$params = @{
ApiVersion = '2018-02-01'
ResourceName = '{0}/web' -f $_.Name
ResourceGroupName = $_.ResourceGroupName
PropertyObject = @{ minTlsVersion = 1.2 }
ResourceType = 'Microsoft.Web/sites/config'
Set-AzureRmResource @params -Force


Copy files to an Azure VM through PSRemoting

You may sometimes need to copy a file to a remote machine where the SMB (aka cifs) ports are closed, or the option to copy files through the RDP connection is disabled as well. Also, you may need to copy the file(s) as a step in an automated process.

If you have PowerShell 5.0 installed it’s easy as pie, since the Copy-Item cmdlet has a set of new parameters: -ToSession and -FromSession

First, create a PSSession object

$cred = Get-Credential
$sess = New-PSSession -ComputerName -Port 5986 -Credential $cred

Then, use the Copy-Item cmdlet with the –ToSession parameter and pass the PSSession object you created in the previous step:

Copy-Item -Path -Destination C:Temp -ToSession $sess

You can use the same technique to copy files from the remote VM:

Copy-Item -FromSession $sess -Path C:\Temp\ -Destination C:\Temp

Note that the ToSession and FromSession parameters are mutually exclusive parameters (are not included in the same parameter set), meaning you cannot use them to copy files directly from one session to another.