Last active
September 6, 2015 16:16
-
-
Save deangrant/09b2b2ed237ce5a94089 to your computer and use it in GitHub Desktop.
0115-September Scripting Games Puzzle.ps1
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
# 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