Skip to content

Instantly share code, notes, and snippets.

@deangrant
Last active September 6, 2015 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deangrant/09b2b2ed237ce5a94089 to your computer and use it in GitHub Desktop.
Save deangrant/09b2b2ed237ce5a94089 to your computer and use it in GitHub Desktop.
0115-September Scripting Games Puzzle.ps1
# Single line using one pair of curly brackets.
Import-Csv -Path .\Input.csv | ForEach-Object {$_ | Add-Member -MemberType NoteProperty -Name OSVERSION -Value (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $_.MACHINENAME).Caption -PassThru} | Export-Csv .\Output.csv -NoTypeInformation
# Single line using no semicolons or curly brackets if host names are specified in the CSV file to import.
Get-WmiObject -Class Win32_OperatingSystem -ComputerName (Import-Csv .\Input.csv).MachineName | Select-Object PSComputerName,Caption | ConvertTo-Csv -NoTypeInformation | Select -Skip 1 | ConvertFrom-Csv -Header MACHINENAME, OSVERSION | Export-Csv .\Output.csv -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment