Helloworld
Helloworld

Reputation: 79

My script Deallocated vm from powershell started throwing an error from Jule, How to reWrite?

I use PowerShell Script to the start azure automation which deallocated vm on name:

$clientID = "..."
$key = "..."

$SecurePassword = $key | ConvertTo-SecureString -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $clientID, $SecurePassword

Add-AzureRmAccount -Credential $cred -Tenant "..." -ServicePrincipal

$params = @{"RESOURCEGROUPNAME" = "..."; "VMNAME" = $env:computername}
    Start-AzureRmAutomationRunbook -ResourceGroupName "..." -AutomationAccountName "..." -Name "StopAzureV2Vm" -Parameters $params

but from Jule/22 command Add-AzureRmAccount ... started throw error:

Add-AzureRmAccount : AADSTS1002016: You are using TLS version 1.0, 1.1 and/or 3DES cipher which are deprecated to improve the security posture of Azure AD. Your TenantID is: 7441e116-ef50-4bf6-a98f-1fa0671ccfb5. Please refer to https://go.microsoft.com/fwlink/?linkid=2161187 and conduct needed actions to remediate the issue. For further questions, please contact your administrator.

please help rewrite my code for new Requirements?

Upvotes: 0

Views: 327

Answers (1)

Delliganesh Sevanesan
Delliganesh Sevanesan

Reputation: 4786

You can follow the below ways to fix the issue:

  1. Add-AzureRmAccount commands are deprecated. Try to use Add-AzureAccount to avoid this error.
  2. Disable the TLS 1.0 & TLS 1.1 Protocols. Enable the Protocol**TLS 1.2** in client so that we can avoid this issue.
  3. You can include below script to fix your issue
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

Refer the MSDOC to solve the TLS 1.0 issues

Upvotes: 1

Related Questions