2012-02-15 25 views
0

こんにちは、私は私は基本的に(SQL認証を使用)、ユーザー名とパスワードを追加できるようにしたい、このPowerShellのセキュリティで保護された文字列変換

Import-Csv C:\sl.csv |$pass = convertto-securestring "abc123"-asplaintext -force | ForEach-Object {New-Item $(Encode-Sqlname $_.Name) -ItemType Registration -Value ("server=$($_.Name);integrated security=true") -Credential (New-Object System.Management.Automation.PSCredential("sa", $pass)) } 

をやろうとしたが、この

Expressions are only allowed as the first element of a pipeline. 
At line:1 char:29 
+ Import-Csv C:\sl.csv |$pass <<<< = convertto-securestring "abc123"-asplaintext -fo 
rce | ForEach-Object {New-Item $(Encode-Sqlname $_.Name) -ItemType Registration -Value ("server=$($_.Name);integrated security=true") -Credential (New-Object System.Management.Automation.PSCredential("sa", $pass)) } 
    + CategoryInfo   : ParserError: (:) [], ParentContainsErrorRecordException 
    + FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline 

のようなエラーを取得しています私のパスワードをsecurestringに変換しようとしており、これを見て良い仕事をしていません。 Pls assist tks 私はこのリンクに行きましたが、コードは役に立ちましたが、私の登録したサーバーを右クリックしてプロパティを見たときにWindows認証モードで、SQL認証モードではないことがわかりました

答えて

0

$pass = convertto-securestring "abc123"-asplaintext -force 
Import-Csv C:\sl.csv | ForEach-Object {New-Item $(Encode-Sqlname $_.Name) -ItemType Registration -Value ("server=$($_.Name);integrated security=true") -Credential (New-Object System.Management.Automation.PSCredential("sa", $pass)) } 
+0

しかし、私は既定の接続を接続しようとするとWindows認証とSQL認証に設定されていないので、私はfalseに統合セキュリティを変更し、今私は午前SQL認証が選択されているのを見ることができますが、ユーザ名とパスワードは空白なので、saとパスワードはどこに行くのですか?私は何か間違っていますか? – JackyBoi

関連する問題