服務(wù)器上裝了SQL Server 2014的默認(rèn)實(shí)例,以及SQL Server 2017的命名實(shí)例SQL2017
$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)型有差異。
后記:
后來(lái)再?lài)L試加載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 PSModulePath environment 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.
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
本文名稱(chēng):SQLPS不同版本的差異-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://www.chinadenli.net/article16/doiddg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站導(dǎo)航、虛擬主機(jī)、網(wǎng)頁(yè)設(shè)計(jì)公司、App開(kāi)發(fā)、品牌網(wǎng)站建設(shè)
聲明:本網(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)
猜你還喜歡下面的內(nèi)容
營(yíng)銷(xiāo)型網(wǎng)站建設(shè)知識(shí)