我想按照安裝 Azure Az PowerShell 模塊頁面中的說明在 Linux 上安裝 Azure Az PowerShell 模塊。如果我更改為非 root 用戶,并執行命令:
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
我明白了
Install-PackageProvider: Unhandled Exception - Message:'The type initializer for 'Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions' threw an exception.'
Name:'TypeInitializationException' Stack Trace:' at Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions.MakeSafeFileName(String input)
...
這
PS /root> $PSVersionTable.PSVersion
Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- --------------- ----------
7 2 1
PS /home/user> $env:PSModulePath
/home/user/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules
乍一看,我覺得好像存在權限問題,但我找不到根本原因。任何的想法?
提前致謝!
uj5u.com熱心網友回復:
它是由 /tmp/Microsoft.PackageManagement 的所有權引起的。只有 root 和創建它的非 root 用戶能夠安裝模塊。
洗掉此目錄可以緩解問題,但當然,僅適用于創建它的用戶。
https://github.com/OneGet/oneget/issues/400
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/409799.html
標籤:
上一篇:PowerShell通過CSV將用戶添加到AD組-腳本不添加用戶
下一篇:powershell管道運算子
