AWS Windowsインスタンスのユーザーデータで実行するPowerShellスクリプトを作成しました。管理者として手動でスクリプトを実行すると、スクリプトは正常に実行され、機能します。Windows AWS EC2インスタンスのユーザーデータPowerShellでシステムアカウントレベルのPowershellモジュールが読み込まれない
しかし、私は、ユーザデータ(インスタンスの作成中)にスクリプトを送信するとき、それは例外をスローします。これは、PsGetモジュールの問題のよりEC2ではありません:これは
Cannot bind argument to parameter 'Path' because it is an empty string.
2017-04-10T18:24:25.004Z: Ec2HandleUserData: Message: Executing C:Windowssystem32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted . 'C:\Program Files\Amazon\Ec2ConfigService\Scripts\UserScript.ps1' from System account
2017-04-10T18:24:25.006Z: Ec2HandleUserData: Message: Executing User Data with PID: 1084
2017-04-10T18:24:34.639Z: Ec2HandleUserData: Message: ExitCode of User Data with PID: 1084 is 1
2017-04-10T18:24:34.642Z: Ec2HandleUserData: Message: The errors from user scripts: iex : Cannot bind argument to parameter 'Path' because it is an empty string.
At C: Program Files Amazon Ec2ConfigService Scripts UserScript.ps1:5 char:79
+ (new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1")
| ie ...
+
~~
+ CategoryInfo : InvalidData: (:) [Invoke-Expression], ParameterB
indingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAl
lowed,Microsoft.PowerShell.Commands.InvokeExpressionCommand
2017-04-10T18:24:34.642Z: Ec2HandleUserData: Message: The output from user scripts:
2017-04-10T18:24:34.642Z: Background plugin complete: Ec2HandleUserData
ワークアラウンドEC2のWindows 2012 R2 = V4.0上のシステムアカウント
PowerShellのバージョンからのモジュールのインストール/ソリューション中に発生しますシステムアカウントレベルPsGetモジュールで問題
https://github.com/psget/psget/issues/208
は間違ってパスを設定しました。 今のところ私はカスタムパス$ env:PSModulePathを読み込むようにPsGet.ps1を変更しましたが、問題なく動作します。
PsGet.Ps1ライン1615 コメントライン#アドオンPathToPSModulePath -PathToAdd:$先-PersistEnvironment:$ PersistEnvironment -Global:$グローバル
を追加しました:[環境] :: SetEnvironmentVariable( "PSModulePath"、 " ; C:{DirectoryIwantModulesToBe} \モジュール」、 "機械")
それが助けを問題なく
おかげでアレックスとシステムアカウントレベルで、動作します。
システムユーザがpowershellでinstall-modulesを呼び出すと、PsGetに問題があるようです - https://github.com/psget/psget/issues/208 – MadhuS