2017-10-19 1 views
0

데이터를 읽고 powershell을 사용하여 .txt 파일에 쓰려고합니다. 그러나 그 결과로 그것은 손질된다.powershell에서 데이터 서식 지정

#Get the photo path of the students 
$commandAD = $connection.CreateCommand() 

#Retreving student photo records. 
$commandAD.CommandText = "SELECT [Barcode],[ImageURL] FROM 
[iSAMS_Custom].[dbo].[vwDestinyLibrary_Student_photo1]" 
$resultPhoto = $commandAD.ExecuteReader() 
$tablePhoto = new-object "System.Data.DataTable" 
$tablePhoto.Load($resultPhoto) 

#Export Hash Table to Txt File 
$tablePhoto | Out-File c:\Users\nimmy.pk\Documents\inputphoto.txt 

어떻게 데이터를 포맷 할 수 있습니까? 당신은 아웃 - 파일에서 - 폭 매개 변수를 사용할 수 있습니다

+0

를 CSV 파일로 저장, 개체가 테이블 – guiwhatsthat

+0

처럼 지금 TXT 형식 –

답변

2

:

$tablePhoto | Out-File -Width 4096 -Path c:\Users\nimmy.pk\Documents\inputphoto.txt 
어쩌면
+0

URL에 같은 결과를 필요로 보인다 완전히 보여 주지만 모든 결과는 두 개가 아닌 한 개의 열에 표시됩니다. –

+0

열 사이의 공백을 삭제하려고했지만 작동하지 않습니다. (... ... 저는 PowerShell을 처음 사용하고 최근 학습을 시작했습니다. 누구든지 전체 결과를보기 위해 출력 파일의 서식을 지정할 수 있습니까? ? –

+0

CSV는 @guiwhat와 비슷합니다. $ tablePhoto | 내보내기 -CSV -delimiter "t"- 경로 c : \ Users \ nimmy.pk \ Documents \ inputphoto.txt –