MSDN subscription: Save product key and write to CSV file

Actually useless, but I like to have my keys stored locally so that I don't have to log in all the time. The MSDN does offer the option of exporting the product keys as an XML file, but I don't have Excel everywhere...

image

The XML file can be converted into a CSV file with the following Powershell script:

$keyfile = "c:\temp\KeysExport.xml"
$csvfile = "c:\temp\productkeys.csv"
$xmlfile = get-content $keyfile
$productkeys =@()
$productlist = $xmlfile.YourKey.Product_Key
foreach ($product in $productlist)
{
$productname = $product.Name
$productkey = $product.key. "#text"
$productkeys += new-object PSObject -property @{Productname="$productname";Productkey="$productkey"}
}
$productkeys
$productkeys | Export-Csv $csvfile -NoTypeInformation -Delimiter ";"

The CSV can also be opened easily with Notepad or similar and the product key can be found quickly.

343 thoughts on “MSDN-Subscription: Produkt Schlüssel sichern und in CSV-Datei schreiben”

  1. Hallo Frank,

    der Skript hat bisher wunderbar funktioniert und eine nette Übersicht erzeugt.
    Leider hat Microsoft nun das MSDN zu My VisualStudio umgezogen und die XML Datei sieht nun ein wenig anders aus.
    Sobald man also das Skript über die neue XML laufen lässt, erhält man eine leere csv Datei.
    Ist ein Update vorgesehen?

    Gruß

    Reply
    • Hi Marius,
      um die XML Datei von MyVisualStudio in eine CSV Datei zu exportieren, ist nur eine Anpassung nötig:

      Die Zeile mit:

      „$productlist = $xmlfile.YourKey.Product_Key“

      muss wie folgt geändert werden:

      „$productlist = $xmlfile.root.YourKey.Product_Key“

      Dann klappt auch wieder der Export.
      Gruß,
      Frank

      Reply

Leave a Comment