网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

SQLPS不同版本的差异-创新互联

服务器上装了SQL Server 2014的默认实例,以及SQL Server 2017的命名实例SQL2017

创新互联是一家专业提供上林企业网站建设,专注与成都网站设计、做网站、H5网站设计、小程序制作等业务。10年已为上林众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。

$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\

在执行Powershell命令

New-SqlAvailabilityGroup -Name $AgName -InputObject $Primary -AvailabilityReplica $Replicas -Database $DatabaseList

时,报错如下:

SQLPS不同版本的差异

SQLPS不同版本的差异

去掉了SQL Server 2014的SQLPS目录路径

%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules\

再加载SQL Server 2017默认的SQLPS,执行New-SqlAvailabilityGroup正常。

说明两个版本SQLPS里New-SqlAvailabilityGroup对应的参数-InputObject类型有差异。

后记:

后来再尝试加载SQL Server 2014的SQLPS模块,针对SQL Server 2014默认实例创建AG失败。索性直接调用新装的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/

#加载即用、用时注册

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.

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享文章:SQLPS不同版本的差异-创新互联
网页链接:http://bjjierui.cn/article/doiddg.html

其他资讯