Last active
September 6, 2015 15:14
-
-
Save csandfeld/77c28a98ca2fe8fcd078 to your computer and use it in GitHub Desktop.
@csandfeld 2015 - September Scripting Games Puzzle
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
# No semicolons, only one set of curlies, using aliases etc. to keep it as short as possible | |
ipcsv I*|%{$_|Add-Member OSVERSION (gwmi -CN $_.MACHINENAME Win32_OperatingSystem).Caption -P}|epcsv Output.csv | |
# Same as the above, but longer as I am not taking shortcuts with aliases and an incomplete filename | |
Import-Csv Input.csv | %{ $_ | Add-Member OSVERSION (Get-WmiObject -ComputerName $_.MACHINENAME Win32_OperatingSystem).Caption -PassThru } | Export-Csv Output.csv | |
# How I would have done it, had there been no limitations on lenght, semicolons | |
# and curlies. Better readability, adhearing to culture (I'm danish, so apps | |
# like Excel expect a semicolon as delimiter in a CSV file) and not outputting | |
# type information (normaly just get's in the way when using the CSV in another | |
# app) | |
Import-Csv -Path Input.csv | Select-Object -Property MACHINENAME, @{ l = 'OSVERSION' ; e = { Get-WmiObject -ComputerName $_.MACHINENAME -Class Win32_OperatingSystem | Select-Object -ExpandProperty Caption } } | Export-Csv -Path Output.csv -UseCulture -NoTypeInformation |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
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
MACHINENAME | |
localhost | |
127.0.0.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment