我在这里碰到了一点砖墙。我编写了一个相当大的 PS 脚本,它需要 SQLServerProviderSnapin100,这一切都很顺利。
为了运行脚本,我编写了一个 BAT 文件供用户运行,这样他们就不必摆弄 execuptionpolicy,因此它设置为不受限制地调用脚本,一旦脚本完成,它将执行策略设置回受限制。
我遇到的问题是我需要 BAT 文件来检测用户是否将 SqlServerProvider100 管理单元注册到 32Bit Powershell 或 64Bit Powershell。
我知道我可以在 powershell 中运行这样的东西
$prov = get-pssnapin -registered | where-object{$_.Name -eq "Sqlserverprovidersnapin100"}
if($prov -eq $null){ <call powershell x86>}else{<call powershell 64Bit>}
但是我如何在 BAT 中做到这一点,或者我正在尝试做的事情是否可能?
我希望我对能够帮助我克服这个障碍的人有意义!:)