How to hard-code O365 credentials in Powershell script

I am using the PowerShell script mentioned here: http://www.sharepointdiary.com/2016/11/sharepoint-online-import-terms-to-termset-using-powershell.html to update the term store values and its working perfectly.

However, I need to schedule this Powershell to run through task scheduler so that it can run every hour. For this reason, I want to hard-code credentials that connects to SPOnline. But for some reason I am seeing below error.

enter image description here

I tried to make below change in Powershell to hard-code credentials:

#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll"  #Variables for Processing  $  AdminURL = "https://abc-admin.sharepoint.com/" $  TermGroupName= "Site Collection - abc.sharepoint.com-sites-123site" $  TermSetName="Due Diligence" $  CSVFile ="C:\Users\dm123\Downloads\TermStore.csv" $  TermHeaderInCSV ="Due Diligence"  Try {     #Get Credentials to connect     $  Username = "123@abc.com"     $  Password ="LE$  b1yuio$  !."     $  Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($  Username, $  Password)      #Setup the context     $  Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($  AdminURL)     $  Ctx.Credentials = $  Credentials      #Get the term store     $  TaxonomySession=[Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($  Ctx)     $  TaxonomySession.UpdateCache()     $  TermStore =$  TaxonomySession.GetDefaultSiteCollectionTermStore()     $  Ctx.Load($  TaxonomySession)     $  Ctx.Load($  TermStore)     $  Ctx.ExecuteQuery()      #Get Termstore data from CSV and iterate through each row     Import-Csv $  CSVFile | ForEach-Object {          #Get the Term Group         $  TermGroup=$  TermStore.Groups.GetByName($  TermGroupName)          #Get the term set         $  TermSet = $  TermGroup.TermSets.GetByName($  TermSetName)          #CSV File Header Row in Term to Add         $  TermName = $  _.$  ($  TermHeaderInCSV)          #Check if the given term exists already         $  Terms = $  TermSet.Terms         $  Ctx.Load($  Terms)         $  Ctx.ExecuteQuery()         $  Term = $  Terms | Where-Object {$  _.Name -eq $  TermName}          If(-not $  Term)         {             #Create Term Set             Write-host "Creating Term '$  TermName'" -ForegroundColor Cyan             $  Term = $  TermSet.CreateTerm($  TermName,1033,[System.Guid]::NewGuid().toString())             $  Ctx.Load($  Term)             $  Ctx.ExecuteQuery()             $  Term.TermStore.CommitAll()             $  TaxonomySession.UpdateCache()             Write-host "New Term '$  TermName' Added Successfully!" -ForegroundColor Green         }         else         {             Write-host "Term '$  TermName' Exists Already!" -ForegroundColor Yellow         }     }  } Catch {     write-host -f Red "Error Importing Term store Data!" $  _.Exception.Message } 

Can someone please help me resolve the error, I simply need to hard-code the credentials. Thanks in advance.