ゆっくりとPowershellを学習しています...サードパーティのAD/AMデータベース(LDAP)を照会するスクリプトを作成しています。私が必要とする特定のLDAPプロパティ名には、名前にハイフンが付きます。Powershellのコレクションで文字列インデクサーにアクセスする方法
私はこのことを考えずにC#で行うことができますが、頻繁に変更される単純なスクリプトを行うためにVisual Studioを起動したくありません。
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
.....
$results = $objSearcher.FindAll()
foreach($result in $results) {
$item = $result.Properties
$item.some-property # this fails because of '-'
$result['some-property'] # 'Unable to index into an object of type System.DirectoryServices.SearchResult.'
}
$ .. – stej
うん、それはあまりにも動作します。 –