Powershell 고급 함수는 대부분의 특정 .Net에 매핑되는 표준 데이터 형식 (문자열, int, bool, xml, 배열, 해시 테이블 등)의 매개 변수를 선언합니다. 유형.Powershell 고급 함수에서 비표준 매개 변수 데이터 형식 사용
다른 .Net 데이터 형식을 사용하는 고급 함수 매개 변수를 어떻게 선언합니까?
function Do-Something
{
[CmdletBinding()]
Param(
[System.Xml.XPathNodeList] $nodeList
)
Begin {}
Process
{
Foreach ($node in $nodeList)
{
Write-Host $node
}
}
End {}
}
# Prepare to call the function:
$xml = [xml](get-content .\employee.xml)
$nodeList = $xml.SelectNodes("//age")
# Call the function passing an XPathNodeList:
do-something $nodeList
다음과 같은 런타임 오류이 함수의 결과를 호출 :
Unable to find type [System.Xml.XPathNodeList]: make sure that the assembly
containing this type is loaded.
이이 LoadWithPartialName으로 수행 할 수 있습니다()를 예를 들어, 여기에 인위적인 예입니다? 방법?
이것이 가능하다고 가정하면 다음과 같은 부수적 인 질문이 있습니다. 비표준 유형을 사용하면 '모범 사례'에 위배되는 것입니까?
으악를 - 위의 CmdletBinding을 놓친, 키스의 완벽 . –