我正在尝试在 Azure 中自动化 DataGateway,最近在 powershell 7 中发布了库来管理它。但是 Azure DSC 与 Windows Powershell 5 一起使用的问题,即使 VM 已经安装了 powershell 7,它也无法正常工作。
有人可以建议一个正确的方法吗?
我正在尝试在 Azure 中自动化 DataGateway,最近在 powershell 7 中发布了库来管理它。但是 Azure DSC 与 Windows Powershell 5 一起使用的问题,即使 VM 已经安装了 powershell 7,它也无法正常工作。
有人可以建议一个正确的方法吗?
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force
Install-PackageProvider Nuget -MinimumVersion 2.8.5.201 -Force | Out-Null
Install-Module -Name PowerShellGet -Force -AllowClobber
$LFHT = @ {
ItemType = 'Directory'
ErrorAction = 'SilentlyContinue'}
New - Item - Path C: \Foo@ LFHT | Out - Null
这些命令使用称为 splatting 的 PowerShell 技术。有关更多信息,您可以键入:
Get-Help about _ splattin
Set-Location C:\Foo
$URI = "https://aka.ms/install-powershell.ps1"
Invoke-RestMethod -Uri $URI |
Out-File -FilePath C:\Foo\Install-PowerShell.ps1
Get-Help -Name C:\Foo\Install-PowerShell.ps1
$EXTHT = @ {
UseMSI = $true
Quiet = $true
AddExplorerContextMenu = $true
EnablePSRemoting = $true}
C:\Foo\Install-PowerShell.ps1 @EXTHT
下载 PowerShell 7 MSI 安装包的安装脚本然后静默运行此代码。
为调出 PowerShell 7 控制台而运行的可执行程序的名称是 pwsh.exe。
另一个明显的区别是 PowerShell 7 没有 .PS1XML 文件。
Get-Childitem -Path $env:ProgramFiles\PowerShell\7 -Recurse |
Measure-Object -Property Length -Sum
$I = 0
$env:PSModulePath -split ';' |
Foreach-Object {
"[{0:N0}] {1}" -f $I++, $_}
ISE内部
$PROFILE |
Format-List -Property *Host* -Force
从 Windows PowerShell 控制台
powershell -Command '$Profile| Format-List -Property *Host*' -Force
打开 pwsh.exe,然后按 Enter 打开 PowerShell 7 控制台。打开 PowerShell 7 控制台后,通过查看 $PSVersionTable 变量来验证版本
$PSVersionTable
$ModFolders = $Env:PSModulePath -split ';'
$I = 0$
ModFolders |
ForEach-Object {"[{0:N0}] {1}" -f $I++, $_}
$PROFILE | Format-List -Property *Host* -Force