REST API 呼び出しを呼び出してサーバーから証明書を取得する Powershell スクリプトがあります。マシンから手動でトリガーすると、スクリプトは問題なく実行されます。ただし、次の手順を使用して開始時に実行するようにスクリプトをセットアップすると: http://blogs.technet.com/b/heyscriptingguy/archive/2014/05/14/use-powershell-to-create-job-that- runs-at-startup.aspxの場合、スクリプトはまったく実行されません。
上記の記事で説明したように、同じ StartUp フォルダーの下に .bat スクリプトをセットアップすると、正常に実行されます。
問題の解決またはデバッグに役立つポインタや提案は役に立ちます。
編集:これがスクリプトです
# Fake the Certificate Validation as we are using a HTTPS request without a real cert
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
$uri = "https://10.X.Y.Z/webapp-rest/login?&user=user1&pw=super_secure"
$res = Invoke-WebRequest -Uri $uri -Method Post
$headers = @{}
$headers.Add('Authorization', $res.Headers.Authorization)
$uri1 = "https://10.X.Y.Z/webapp-rest/certificate"
$sm = Invoke-RestMethod -Uri $uri1 -Headers $headers -ContentType application/x-x509-ca-cert -OutFile "cert.pem"
Move-Item C:\cert.pem C:\Users\Administrator\Downloads -Force