更新时间:2022-12-02 18:28:38
脚本有 2 个问题,第一个是我的主要问题:
There were 2 problems with the script and the 1st was my main problem:
检查脚本是否使用 签名获取 AuthenticodeSignature.在这里,您将收到 SignatureStatus 作为字符串:
Check if the script is signed with Get-AuthenticodeSignature. Here you are going to receive SignatureStatus as string:
$isSigned = Get-AuthenticodeSignature -FilePath $FilePath | select -ExpandProperty Status
如果它没有签名,你可以通过添加 -ExecutionPolicy Bypass
来启用它的执行,就像在这个 spiceworks 操作方法.为了安全起见,为您自己的脚本执行此操作!
If it is not signed, you can enable the execution of it by adding -ExecutionPolicy Bypass
like it is described in this spiceworks how-to. Do this for your own scripts, because of security !
For the writing part I used Write-Output and Out-File:
(
...
Write-Output "some text here"
...
) | Out-File -FilePath "C:\somepath\log.log