Last active
March 26, 2018 20:58
-
-
Save sdaaish/2e59ba059ca8a638cf128bd1bd675e3b to your computer and use it in GitHub Desktop.
Powershell CSV example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name | IP | System | Owner | Comments | |
---|---|---|---|---|---|
frodo | 192.168.1.1 | Debian | Linus | Some system | |
bilbo | 10.10.10.1 | Ubuntu | Baggins | Another system | |
gandalf | 192.168.10.7 | Windows | Treehouse | Some old manager | |
saruman | 172.16.1.9 | Windows | Sauron | Grumpy old masters | |
enya | 192.168.190.234 | Ubuntu | Elflords | Nice stuffed animal | |
frodo1 | 192.168.1.1 | Debian | Linus | Some system | |
frodo2 | 192.168.1.2 | Debian | Linus | Some system | |
frodo3 | 192.168.1.3 | Debian | Linus | Some system | |
frodo4 | 192.168.1.4 | Debian | Linus | Some system | |
frodo5 | 192.168.1.5 | Debian | Linus | Some system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$csv = Import-CSV .\data.csv | |
$linux = $csv|where { $_.Owner -like "Linus" } | |
$linux | |
$csv | |
foreach ($a in $csv) { | |
$b += $a.Owner + "," | |
} | |
#$b | |
#"$b,"| out-file .\new-data.csv -append | |
$array = @("De*an","Ubuntu","windows") | |
foreach ($element in $array){ | |
$file = "$element" + "data" + ".csv" | |
$OS = $csv | where { $_.System -like $element} | |
$result = $OS.IP -join ',' | |
$result| Out-file $file | |
} | |
$OS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment