且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在PowerShell中比较其中包含与号的字符串

更新时间:2023-11-05 11:26:04

这是

何时需要知道两种类型的&"号玩SharePoint分类法

There are two types of ampersands that you need to be aware of when playing with SharePoint Taxonomy

我们最喜欢和最爱的人

  • & ASCII码: 38
  • & ASCII Number: 38

冒名顶替者

  • & ASCII码: 65286
  • ASCII Number: 65286

阅读 Nick Hobbs ="=" nofollow noreferrer>这篇文章

当您创建一个术语时,它会将 38 和号替换为 65286 和号.

After reading this article by Nick Hobbs, it became apparent that when you create a term it replaces the 38 ampersand with a 65286 ampersand.

如果您想与您的产品进行比较,那么这将成为一个问题原始来源(电子表格,数据库等),因为它们不再是一样.

This then becomes a problem if you want to do a comparison with your original source (spreadsheet, database, etc) as they are no longer the same.

如尼克的文章所述,您可以使用 TaxonomyItem.NormalizeName 方法来创建"Taxonomy"版本的您要比较的字符串:

As detailed in Nick’s article, you can use the TaxonomyItem.NormalizeName method to create a "Taxonomy" version of your string for comparison:

尝试一下(未经真实SharePoint测试):

Try this (not tested on real SharePoint):

function getTerm($termName)
{
  foreach($term in $global:termset.Terms) {
    $termNormalized = [Microsoft.SharePoint.Taxonomy.TaxonomyItem]::NormalizeName($term.Name)
    if ($termNormalized -eq $termName) {
      return $term
    } 
  }
  return null
}