简体   繁体   English

Azure DSC 与 PowerShell 7

[英]Azure DSC with PowerShell 7

I am trying to automate DataGateway in Azure and recently in powershell 7 were released library to manage it.我正在尝试在 Azure 中自动化 DataGateway,最近在 powershell 中发布了 7 个库来管理它。 But the problem that Azure DSC working with Windows Powershell 5 and even if VM have installed powershell 7 it's not working.但是Z3A580F142203677F1F0BC3089898F63F53Z DSC与ZAEA23489CE3AA9B6406EBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB281B81B81B841B21B2A7753DA83 DA83ACF36799999999999999999999999999999999999999990.9999999990号

Can someone suggest a proper way to do it?有人可以建议一个正确的方法吗?

Enabling the Execution Policy:启用执行策略:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force

Installing the Latest Version of NuGet and PowerShellGet安装最新版本的 NuGet 和 PowerShellGet

Install-PackageProvider Nuget -MinimumVersion 2.8.5.201 -Force | Out-Null
Install-Module -Name PowerShellGet -Force -AllowClobber 

Creating the Foo Folder创建 Foo 文件夹

$LFHT = @ {
ItemType = 'Directory'
ErrorAction = 'SilentlyContinue'}


New - Item - Path C: \Foo@ LFHT | Out - Null

These commands use a PowerShell technique known as splatting.这些命令使用称为喷溅的 PowerShell 技术。 for more information, you can type:有关更多信息,您可以键入:

 Get-Help about _ splattin

Downloading the PowerShell 7 Installation Script下载 PowerShell 7 安装脚本

Set-Location C:\Foo
$URI = "https://aka.ms/install-powershell.ps1"
Invoke-RestMethod -Uri $URI | 
Out-File -FilePath C:\Foo\Install-PowerShell.ps1

Viewing Installation File Help Information查看安装文件帮助信息

Get-Help -Name C:\Foo\Install-PowerShell.ps1

Installing PowerShell 7安装 PowerShell 7

$EXTHT = @ {
UseMSI = $true
Quiet = $true
AddExplorerContextMenu = $true
EnablePSRemoting = $true}


C:\Foo\Install-PowerShell.ps1 @EXTHT

The installation script that downloads the PowerShell 7 MSI Installation package then runs this code silently.下载 PowerShell 7 MSI 安装 package 的安装脚本然后静默运行此代码。

the name of the executable program you run to bring up the PowerShell 7 console is pwsh.exe.您运行以调出 PowerShell 7 控制台的可执行程序的名称是 pwsh.exe。

Another noticeable difference is that with PowerShell 7, there are no.PS1XML files.另一个明显的区别是,对于 PowerShell 7,没有 .PS1XML 文件。

Examining the Installation Folder检查安装文件夹

Get-Childitem -Path $env:ProgramFiles\PowerShell\7 -Recurse |
Measure-Object -Property Length -Sum

Viewing Module Folder Locations查看模块文件夹位置

 $I = 0
$env:PSModulePath -split ';' |  
Foreach-Object { 
"[{0:N0}]   {1}" -f $I++, $_}

Viewing Profile File Locations:查看配置文件位置:

Inside the ISE ISE内部

$PROFILE |
Format-List -Property *Host* -Force

from Windows PowerShell Console从 Windows PowerShell 控制台

powershell -Command '$Profile|   Format-List -Property *Host*' -Force

Starting PowerShell 7启动 PowerShell 7

Open pwsh.exe, and hit Enter to open a PowerShell 7 console.打开 pwsh.exe,然后按 Enter 打开 PowerShell 7 控制台。 After you open the PowerShell 7 console, verify the version by viewing the $PSVersionTable variable打开 PowerShell 7 控制台后,通过查看 $PSVersionTable 变量来验证版本

$PSVersionTable

Viewing New Locations for Module Folders查看模块文件夹的新位置

$ModFolders = $Env:PSModulePath -split ';'
$I = 0$
ModFolders | 
ForEach-Object {"[{0:N0}]   {1}" -f $I++, $_}

Viewing New Locations for Profile Files查看配置文件的新位置

$PROFILE | Format-List -Property *Host* -Force

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM