我需要使報告更易讀。有第三方工具可以檢索,如果一個特定的設置是真或假,它會檢查每個用戶一次在不同的域,然後將結果一個接一個地放在我的csv的單個列中。 我需要能夠根據該用戶的域將輸出行分成不同的csv列。Windows Powershell根據字符串內容將單個柱子格式化爲幾個
$var1 = "C:\location\filewithallsettings.csv"
. C:\mytool.exe\ show setting > $var1
然後只檢索「TRUE」的:
Select-String -Path C:\filewithallsettings.csv -Pattern "enabled:true" |`
select-object -property Line|
Export-Csv -Path C:\filewithTRUEsettings.csv -Encoding UTF8 -Delimiter ";" `
-NoTypeInformation
輸出看起來像這樣一行:
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
現在我不能讓過去的這一點,但我需要以某種方式分析第二個文件字符串,並將其中的每一行放入另一個文件中的特定列中,具體取決於一個用戶的域。我再次假設選擇字符串或$ varname.contains(),但我只是不知道如何。 我的目標是像這樣的文件:
DOMAIN ANOTHERDOMAIN THIRDDOMAIN andsoon
User1 User2 User3
記得......我的工具只給一列! 預先感謝您!
編輯 我將filewithallsettings.csv的內容複製到這篇文章中。雙重用戶不相關,因爲在一個域上不能有兩個相同的地址。一個真正的用戶在不同的領域也是不相關的,我知道有一些和哪些。
[email protected] has this setting enabled:true
[email protected] has this setting enabled:false
[email protected] has this setting enabled:true
[email protected] has this setting enabled:false
[email protected] has this setting enabled:true
[email protected] has this setting enabled:false
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
沒有標題只是一個在另一個下面的行。預期的產出就是這樣,因爲我無法改變工具的工作方式。但是我認爲我可以創建另一個只有TRUE的csv,這是唯一需要檢查的。好了,這我被做上述選擇串做,我得到的文件相同的風格,這次沒有FALSEs和頭「行」
Line `
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
[email protected] has this setting enabled:true
我想在每一行進行搜索,並根據所域有它應該把整行放在一個csv在所述域的列標題下,就像我的第一篇文章。
你能否給出更多樣本輸入和輸出場景?例如,如果您在同一個域中擁有多個用戶,您想要什麼?有兩個用戶的兩個域和一個用戶的域?現在回答這個問題需要對這些問題作出假設,所以如果你能舉出更多的例子,它可能會爲每個人節省時間。也許還有一個示例輸入文件(您稱爲'filewithallsettings.csv'的文件)可能是有益的。 –
當然我嘗試: 我的工具向每個單一用戶發送一個呼叫給每個單個域,並檢索單個設置「enabled:false」或「enabled:true」(我不知道哪個設置,我很抱歉)在這樣的CSV一條線: 用戶[email protected]已啓用XXXX:真 用戶[email protected]已啓用XXXX:假 用戶[email protected]已啓用XXXX:假 用戶YYY @ firstdomain .org已啓用xxxx:真 用戶[email protected]啓用了xxxx:true – Obre1
是的我確定嘗試: 我的工具向每個單個用戶發送一個呼叫給每個單個域,並檢索單個設置「enabled:false」或「啓用:真」(我不知道哪個設置,我很抱歉),並把它作爲一行中的一行csv是這樣的: 用戶[email protected]已啓用xxxx:true 用戶[email protected]已啓用xxxx:false 用戶yyz @ firstdomain。org已啓用xxxx:false 用戶[email protected]啓用了xxxx:true 用戶[email protected]啓用了xxxx:true 並且這種情況一直持續到每個域有100到2000個用戶的第11個域 我需要fomrat它就像上面 – Obre1