이 같은 시도 :
32# (get-date).GetType().Assembly.GetCustomAttributes([Reflection.AssemblyCopyrightAttribute], $false)
Copyright TypeId
--------- ------
© Microsoft Corporation. All rights reserved. System.Reflection.AssemblyCopyrightAttribute
을
get-date
대신에 관심이있는 어셈블리의 인스턴스를 사용하십시오. 또한 검색에 관심이있는 Assembly * Attribute를 사용하십시오.
AssemblyMetadataAttribute의 특정 경우에는 .NET 4.5가 새로 추가되었습니다. PowerShell은 여전히 .NET 4.0에 있습니다.
$assembly = [Reflection.Assembly]::ReflectionOnlyLoadFrom("$pwd\ClassLibrary1.dll")
[reflection.customattributedata]::GetCustomAttributes($assembly)
밖으로 뱉어 :
AttributeType Constructor ConstructorArguments
------------- ----------- --------------------
System.Runtime.Versioning.... Void .ctor(System.String) {".NETFramework,Version=v4...
System.Reflection.Assembly... Void .ctor(System.String) {"ClassLibrary1"}
System.Reflection.Assembly... Void .ctor(System.String) {""}
System.Reflection.Assembly... Void .ctor(System.String) {""}
System.Reflection.Assembly... Void .ctor(System.String) {"CDL/TSO"}
System.Reflection.Assembly... Void .ctor(System.String) {"ClassLibrary1"}
System.Reflection.Assembly... Void .ctor(System.String) {"Copyright © CDL/TSO 2013"}
System.Reflection.Assembly... Void .ctor(System.String) {""}
System.Reflection.Assembly... Void .ctor(System.String, ... {"key1", "value1"}
System.Runtime.InteropServ... Void .ctor(Boolean) {(Boolean)False}
System.Runtime.InteropServ... Void .ctor(System.String) {"945f04e1-dae3-4de6-adf6-...
System.Reflection.Assembly... Void .ctor(System.String) {"1.0.0.0"}
System.Diagnostics.Debugga... Void .ctor(DebuggingModes) {(System.Diagnostics.Debug...
System.Runtime.CompilerSer... Void .ctor(Int32) {(Int32)8}
System.Runtime.CompilerSer... Void .ctor() {}
주 출력에 key1
ANE value1
그래서 당신은이 속성을 얻을 수있는 반사에게 유일한 컨텍스트를 사용합니다. @Keith 힐을 구축
감사하지만 난 뭔가를 많이 이미 형제의 시도했습니다. 작동하는 스 니펫 (snippet)은 어떻습니까? –
@natedog 업데이트 된 답변보기 이 스 니펫이 작동합니까? –