2017-05-04 12 views
0

次のリンクを読んだ後に私自身の問題を解決できましたが、invoke-sqlcmdを使用した後にFileSystemプロバイダが必要な理由を知っています。

ie。なぜ次invoke-sqlcmdを実行した後にファイルシステムプロバイダがUNCサーバのパスにアクセスするために必要な理由

$Doc_Folder = "\\Server.fqdn.com\c$\DocFiles" 
$DataSet = Invoke-Sqlcmd -Query $sqlQuery -ServerInstance $instanceName -username $SQLCreds.UserName -Password $pswd 
Get-ChildItem $Doc_Folder -recurse 

を失敗しないと、なぜ次の作業

$Doc_Folder = "Microsoft.PowerShell.Core\FileSystem::\\Server.fqdn.com\c$\DocFiles" 
$DataSet = Invoke-Sqlcmd -Query $sqlQuery -ServerInstance $instanceName -username $SQLCreds.UserName -Password $pswd 
Get-ChildItem $Doc_Folder -recurse 

これは私がMicrosoft.PowerShell.Core \ファイルシステムのファイルシステムプロバイダを追加することに解決策を見つけたリンクであることを行います。 ::
powershell-invoke-sqlcmd-get-childitem-cannot-call-method

答えて

2

前2016年の8月にSQLServerのに同梱のSQL Serverモジュールは、ディレクトリを変更しましたSQLSERVER:ドライブに追加します。

これを回避するには、あなたが(PSGalleryから)SQLServerのモジュールをインストールする必要がありますか、あなたは(互換性のため)古いものを使用する必要がある場合、あなたはこれを行うことができますが:

pushd 
import-module SQLPS 
popd 

復元しますモジュールがインポートされた後の現在のディレクトリ。

関連する問題