Skip to content

Instantly share code, notes, and snippets.

Created August 2, 2013 21:35
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 anonymous/3cbe2a48f7b1e1af4733 to your computer and use it in GitHub Desktop.
Save anonymous/3cbe2a48f7b1e1af4733 to your computer and use it in GitHub Desktop.
. .\Get-ProductKey.ps1
$InputCSV = import-csv .\Input.csv -Header Name
$OutputCSV = @()
$Keys =@()
foreach ($PC in $InputCSV)
{
$objResult = Get-ProductKey -Computername $PC.name
$checkResult = $Keys -contains $objResult.ProductKey
$Keys += $objResult.ProductKey
$objResult | Add-Member -type NoteProperty -name Duplicate -value $checkResult
$OutputCSV = $OutputCSV + $objResult
}
$OutputCSV | Select-object Computername,OSDescription,ProductKey,Duplicate | export-csv -path .\Output.csv -noType -encoding UTF8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment