@XinGuo-MSFT Most of that script is unnecessary. The Export-SCOMEffectiveMonitoringConfiguration cmdlet exports a CSV file. To import that file you can use the Import-CSV cmdlet with the "Delimiter '|' parameter.
$computer = "name-of-computer-goes-here"
$file = "{0}.csv" -f $computer
$dir = "drive-and-path-name-goes-here" # Do NOT include trailing "\"
$path = join-path -Path $dir -ChildPath $file
$class = Get-SCOMClass -Name "System.Computer"
Get-SCOMClassInstance -Class $class |
Where-Object { $_.DisplayName -eq $computer } |
ForEach-Object {
Export-SCOMEffectiveMonitoringConfiguration -Instance $_ -Path $path -RecurseContainedObjects
}
To import the CSV:
Import-CSV $path -Delimeter "|"