1
現在、私はユーザー名のリストを読み込んでエコーするfollow psを持っています。同じ行にエコーが出るようなpowershellループを作るにはどうすればいいですか?
ユーザ名のファイルは、次の
username1
username2
username3
psのスクリプトは私がすべてで、これはエコー(および最終的には、テキストファイルに書き込む)ために得ることを期待しています次
$userNames = (Get-Content usernames.txt)# | Sort-Object
$userID=0
$userNames.Count
echo "FROM table WHERE (userID ='"
For ($i =1; $i -le ($userNames.Count - 1); $i++)
{
echo $userNames[$userID] "' OR userID='"
$userID++
}
echo $userNames[$userNames.Count - 1] "'"
です同じ行。
FROM table WHERE (userID = 'username1' OR userID = 'username2' OR userID = 'username3'
どうすればこの問題を解決できますか?
これはまさに私が探していたトリックです。 userID = 'username1'が表示されます。どのように私は1の後にスペースを取り除くことができますか? – mhopkins321
@ mhopkins321 - 上記の私の編集を参照 – Josh