I am working on PowerShell to create term in SharePoint Online and before I create one I am trying to see if it already exists. In order to see that I am using below "GetByName" function.
$objSearchTerm = $objTermSetName.Terms.GetByName($termName) $clientContext.Load($objSearchTerm) $clientContext.ExecuteQuery()
This works if there is a term with the name but throws an exception if the term does not exist.
Exception calling "ExecuteQuery" with "0" argument(s): "Specified argument was out of the range of valid values. Parameter name: index"
I can not use PnP because I am creating child term with custom properties so please do not suggest PnP solution because PnP doesn't support that.