I am getting an error when running a PowerShell script to install defender software on my development server. The error states that "defender.ps1 is not recognized" and that there is an "err: invalid token." I believe this is because the script needs to pass through a proxy to reach the internet. Can someone guide me on how to properly pass the proxy in this script? Additionally, please let me know if there are any syntax errors that I may have missed.
$parameters = @{
Uri = "https://us-east1.cloud.twistlock.com/us-2-158262581/api/v1/scripts/defender.ps1";
Method = "Post";
Headers = @{"authorization" = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiYWJyYW5kYW5vQGF0aGVuvyJePoU" };
OutFile = "defender.ps1";
};
if ($PSEdition -eq 'Desktop') {
add-type "
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy{
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) {
return true;
}
}
";
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy;
} else {
$parameters.SkipCertificateCheck = $true;
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
Invoke-WebRequest @parameters;
.\defender.ps1 -type dockerWindows -consoleCN us-east1.cloud.twistlock.com -install