Azure PSモジュールに問題があります。 PSギャラリー経由で次をインストールしました。
Install-Module AzureRM
Install-Module Azure
(再起動)
ただし、Login-AzureRmAccount
を実行すると、次のエラーが表示されます。
Login-AzureRmAccount:「Login-AzureRmAccount」という用語は、コマンドレット、関数、スクリプトファイル、または操作可能なプログラムの名前として認識されません。名前のスペルを確認するか、パスが含まれていた場合は、パスが正しいことを確認してから再試行してください。行:1文字:1 + Login-AzureRmAccount + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:ObjectNotFound:(Login-AzureRmAccount:String)[]、CommandNotFoundException + FullyQualifiedErrorId :CommandNotFoundException
すべてのAzureモジュールがインストールされているようです。つまりGet-Module -List
を実行すると、次のようになります。
Script 3.7.0 Azure {Get-AzureAutomationCertificate, Get-AzureAutomationConnec...
Script 0.1.0 Azure.AnalysisServices {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisSe...
Script 2.7.0 Azure.Storage {Get-AzureStorageTable, New-AzureStorageTableSASToken, New...
Script 3.7.0 AzureRM {Update-AzureRM, Import-AzureRM, Uninstall-AzureRM, Instal...
Script 0.1.0 AzureRM.AnalysisServices {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnal...
Script 3.5.0 AzureRM.ApiManagement {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementS...
Script 2.7.0 AzureRM.Automation {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutoma...
Script 2.7.0 AzureRM.Backup {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerRe...
Script 2.7.0 AzureRM.Batch {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-...
Script 2.7.0 AzureRM.Cdn {Get-AzureRmCdnProfile, Get-AzureRmCdnProfileSsoUrl, New-A...
Script 0.5.0 AzureRM.CognitiveServices {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitive...
Script 2.8.0 AzureRM.Compute {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet...
Script 2.7.0 AzureRM.DataFactories {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get...
Script 2.7.0 AzureRM.DataLakeAnalytics {Get-AzureRmDataLakeAnalyticsDataSource, New-AzureRmDataLa...
Script 3.5.0 AzureRM.DataLakeStore {Get-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRm...
Script 2.7.0 AzureRM.DevTestLabs {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShu...
Script 2.7.0 AzureRM.Dns {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remo...
Script 0.1.0 AzureRM.EventHub {New-AzureRmEventHubKey, Get-AzureRmEventHubNamespace, Get...
Script 2.7.0 AzureRM.HDInsight {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefi...
Script 2.7.0 AzureRM.Insights {Get-AzureRmUsage, Get-AzureRmMetricDefinition, Get-AzureR...
Script 1.3.0 AzureRM.IotHub {Add-AzureRmIotHubKey, Get-AzureRmIotHubEventHubConsumerGr...
Script 2.7.0 AzureRM.KeyVault {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificat...
Script 2.7.0 AzureRM.LogicApp {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegr...
Script 0.12.0 AzureRM.MachineLearning {Move-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitm...
Script 0.4.0 AzureRM.Media {Sync-AzureRmMediaServiceStorageKeys, Set-AzureRmMediaServ...
Script 3.6.0 AzureRM.Network {Add-AzureRmApplicationGatewayAuthenticationCertificate, G...
Script 2.7.0 AzureRM.NotificationHubs {Get-AzureRmNotificationHub, Get-AzureRmNotificationHubAut...
Script 2.7.0 AzureRM.OperationalInsights {New-AzureRmOperationalInsightsAzureActivityLogDataSource,...
Script 2.7.0 AzureRM.PowerBIEmbedded {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowe...
Script 2.7.0 AzureRM.profile {Disable-AzureRmDataCollection, Enable-AzureRmDataCollecti...
...
誰かが助けてくれることを願っていますか? Powershell 4を搭載したWindows Server 2012 R2で実行する
よろしく
Azure PowerShellの新しいバージョンに更新する必要があります。
Install-Module AzureRM -AllowClobber
参照記事: https://docs.Microsoft.com/en-us/powershell/Azure/install-azurerm-ps
私のために、 Install-Module
が認識されず、Azure 3.7が既にインストールされていたので、答えは Windows用Azure CLI 2. でした。
Powershellスクリプトをスケジュールされたタスクとして(スケジュールされたタスクの実行用に予約されたユーザープロファイルを使用して)実行する場合、この問題が発生しました。 (Powershellバージョン5.1を使用していました。)
Get-Module -List
は、すべてのユーザーに必要なAzureRmモジュールが既にインストールされていることを示しているようです(C:\ Program Files\WindowsPowerShell\Modulesの下)。それでも、タスクユーザー用にインストールされていないように見えました。
スケジュールされたタスクにセットアップルーチンを配置して、タスクのコンテキストで次のコマンドを実行します。
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module AzureRM.Dns -Scope AllUsers -RequiredVersion 4.0.1 -AcceptLicense
(バージョン4.0.1は既にインストールされているように見えます)。
また、Install-Module PowershellGet -Force
の 'Scope'パラメーターを取得するには、Install-Module
を使用する必要がありました。これらの3つのコマンドのどれが最終的にトリックを実行したかは明確ではありませんでした。