Powershell

Windows Server 2016 上的 powershell 5.1 無法正常工作

  • November 22, 2017

我正在關注標題下的這個 Microsoft官方 Azure 實驗室Deploying Azure SQL Database by using the Azure PowerShell的練習 1 。實驗室中的 VM 機器是Windows Server 2016. 當我執行步驟 6 的以下命令時,它會提示我輸入如下所示的輸入。不知道我需要在那裡輸入什麼。注意:我從這里安裝了 Azure PowerShell 5.1 :

上述連結教程的第 6 步

PS C:\Users\Student> $pass = ConvertTo-SecureString 'Pa55w.rd1234' –AsPlainText –Force
$cred = New-Object
System.Management.Automation.PSCredential('Student',$pass)
server = New-AzureRmSqlServer –ServerName 'raztestsqlserver' -
SqlAdministratorCredentials $cred –Location 'centralus' -
ServerVersion '12.0' –ResourceGroupName 'SQLDBRG'

PS提示如下

cmdlet New-Object at command pipeline position 1
Supply values for the following parameters:
TypeName: 

這不是 Azure Power Shell 問題。

$cred = New-Object System.Management.Automation.PSCredential('Student',$pass)

複製腳本時有換行符。

在此處輸入圖像描述

該腳本應如下所示:

$pass = ConvertTo-SecureString 'Pa55w.rd1234' –AsPlainText –Force
$cred = New-Object System.Management.Automation.PSCredential('Student',$pass)
$server = New-AzureRmSqlServer –ServerName 'raztestsqlserver' -SqlAdministratorCredentials $cred –Location 'centralus' -ServerVersion '12.0' –ResourceGroupName 'SQLDBRG'

引用自:https://serverfault.com/questions/884581