programing

[시스템] 유형을 찾을 수 없습니다.PowerShell의 Web.HttpUtility]

sourcejob 2023. 5. 24. 22:07
반응형

[시스템] 유형을 찾을 수 없습니다.PowerShell의 Web.HttpUtility]

PowerShell을 사용하여 Microsoft Translator 응용 프로그램에 대한 액세스 토큰을 가져오려고 하지만 다음 오류로 인해 프로세스의 특정 명령이 실패합니다.

Unable to find type [System.Web.HttpUtility]

이 오류를 수신하기 전에 MSDN 페이지의 코드를 복사하여 PowerShell ISE에 붙여넣고 자리 표시자 값을 실제 자격 증명으로 교체했습니다.

# ...
$ClientID = '<Your Value Here From Registered Application>'
$client_Secret = ‘<Your Registered Application client_secret>'

# If ClientId or Client_Secret has special characters, UrlEncode before sending request
$clientIDEncoded = [System.Web.HttpUtility]::UrlEncode($ClientID)
$client_SecretEncoded = [System.Web.HttpUtility]::UrlEncode($client_Secret)
# ...

이것이 작동하려면 어떤 코드를 추가해야 합니까?

로드해야 합니다.System.Web집회의사용Add-Type그런 cmdlet,

PS C:\> [System.Web.HttpUtility]::UrlEncode("www.google.com")
Unable to find type [System.Web.HttpUtility].

PS C:\> Add-Type -AssemblyName System.Web
PS C:\> [System.Web.HttpUtility]::UrlEncode("www.google.com")
www.google.com

언급URL : https://stackoverflow.com/questions/38408729/unable-to-find-type-system-web-httputility-in-powershell

반응형