服務(wù)器上裝了SQL Server 2014的默認(rèn)實(shí)例,以及SQL Server 2017的命名實(shí)例SQL2017
銅川ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書(shū)銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書(shū)合作)期待與您的合作!
$env:PSModulePath為
%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\
在執(zhí)行Powershell命令
New-SqlAvailabilityGroup -Name $AgName -InputObject $Primary -AvailabilityReplica $Replicas -Database $DatabaseList
時(shí),報(bào)錯(cuò)如下:
去掉了SQL Server 2014的SQLPS目錄路徑
%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\
再加載SQL Server 2017默認(rèn)的SQLPS,執(zhí)行New-SqlAvailabilityGroup正常。
說(shuō)明兩個(gè)版本SQLPS里New-SqlAvailabilityGroup對(duì)應(yīng)的參數(shù)-InputObject類型有差異。
后記:
后來(lái)再嘗試加載SQL Server 2014的SQLPS模塊,針對(duì)SQL Server 2014默認(rèn)實(shí)例創(chuàng)建AG失敗。索性直接調(diào)用新裝的SqlServer模塊,可以向后兼容。
Powershell模塊安裝
#https://www.powershellgallery.com
#在線下載安裝
Install-Module -Name Powershellget -force
#離線下載安裝
#https://www.powershellgallery.com/packages/CredentialsManager/1.1
#保存模塊
Save-Module -Name CredentialsManager -Path C:\powershellgallery
#拷貝到
%ProgramFiles%/WindowsPowershell/Module/
#加載即用、用時(shí)注冊(cè)
Import-Module -Name CredentialsManager
PowerShell 2.0 uses the appropriately-named Import-Module cmdlet to import modules. When this cmdlet is run, Windows PowerShell searches for the specified module within the directories specified in the PSModulePath variable. When the specified directory is found, Windows PowerShell searches for files in the following order: module manifest files (.psd1), script module files (.psm1), binary module files (.dll). For more information about adding directories to the search, see Modifying the PSModulePath Installation Path.
Beginning in Windows PowerShell 3.0, modules are imported automatically when any cmdlet or function in the module is used in a command. This feature works on any module in a directory that this included in the value of the PSModulePathenvironment variable. If you do not save your module on a valid path however, you can still load them using the explicit Import-Module option, described above.
標(biāo)題名稱:SQLPS不同版本的差異
文章起源:http://www.rwnh.cn/article46/gspheg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開(kāi)發(fā)、云服務(wù)器、App設(shè)計(jì)、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站營(yíng)銷、定制網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)