powershell - Foreach loop not exporting to csv -


पावरशेल स्क्रिप्ट

  $ (foreach ($ s $ sql_output) {$ ip = $ K [0] $ उपस्थित = $ k [1] लिखना आउटपुट $ आईपी, $ उपस्थित}) | निर्यात-सीएसवी डी: \ स्क्रिप्ट \ is_present.csv   

मुझे उम्मीद है कि is_present.csv की तरह

  10.10.10.10 1 10.10.10.11 1 10.10 10.12 0   

इसके बजाय यह दिखता है

  #TYPE System.DBNull   

कैसे ठीक करें?

  $ (foreach ($ s $ sql_output) {[PsCustomObject] @ {'आईपी' = $ K [0] 'वर्तमान' = $ k [1]}}) | निर्यात- Csv c: \ temp \ temp.csv -NoTypeInformation   

लूप उतना ही वैसा ही है जितना पहले था। [CScustomobject] ( को PowerShell 3.0 ) के साथ ऑब्जेक्ट बना दिया गया है और ऑब्जेक्ट के बारे में पता नहीं है इसलिए Export-Csv वस्तुओं के साथ बेहतर काम करता है। उस डेटा को लें और इसे Export-CSV के लिए अगले पाइप के माध्यम से पास करें -नौटाइव जानकारी फ़ाइल की पहली पंक्ति होने से #TYPE System.Management.Automation.PSCustomObject बंद हो जाएगा।

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -