Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Suggestion - Add proxy support

Đang mở
#490 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
powershell
Lĩnh vực
devops, infrastructure

Hướng nghiên cứu

Bắt đầu với script Prereq và kiểm tra các lệnh gọi Invoke-WebRequest, Install-PackageProvider và Find-DscResource/Save-Module của nó. Xác định cách cung cấp các thiết lập proxy và thông tin xác thực, sau đó xác minh rằng việc cài đặt các module điều kiện tiên quyết hoạt động qua proxy mà không yêu cầu thiết lập thủ công bên ngoài script.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I was behind a proxy here and I had to change the script to add "-Proxy $Proxy -ProxyCredential $MyCreds" at the end of each "Invoke-WebRequest" cmdlet.

Same thing for "Install-PackageProvider -Name NuGet"

But then, i got error with "Find-DscResource -moduleName $modulename -RequiredVersion $moduleversion | Save-Module -Path "$PSScriptRoot\Temp\DSC"

I've search a long time and try these configuration without success :

Setting TLS 1.2 : [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Bypassing the certificate validation : [Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};
Bypassing the certificate validation by code instead of block :
#C# class to create callback
$code = @"
public class SSLHandler
{
public static System.Net.Security.RemoteCertificateValidationCallback GetSSLHandler()
{

    return new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; });
}

}
"@
#compile the class
Add-Type -TypeDefinition $code

#disable checks using new class
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = [SSLHandler]::GetSSLHandler()

No success!! but then i've found way to configure default proxy but i wasnt able to add it to the script, and I had to install the module outside of the "Prereq" script. here what I use for this to work :

$proxy = 'YER PROXY HERE' # update this
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy($proxy)
[system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true

Install-PackageProvider -Name nuget -Scope AllUsers -Confirm:$false -Force -MinimumVersion 2.8.5.201
Register-PSRepository -Default -verbose

Install-Module -Name xActiveDirectory -Scope AllUsers -Confirm:$false -Force
Install-Module -Name xDHCpServer -Scope AllUsers -Confirm:$false -Force
Install-Module -Name xDNSServer -Scope AllUsers -Confirm:$false -Force
Install-Module -Name NetworkingDSC -Scope AllUsers -Confirm:$false -Force
Install-Module -Name xPSDesiredStateConfiguration -Scope AllUsers -Confirm:$false -Force

Probably there more "code head" people who can help with this since it's ugly but working :)

Thanks again for the great script!

Ngôn ngữ chính
PowerShell
Star
1.3k
Fork
304
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/MSLab

Tất cả issue của microsoft/MSLab

Issue tương tự

Thêm issue về DevOps

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.