Export Registry Key to CSV

0

I'm currently looking to find out all Solidworks License information on the network. I need help writing a script for powershell to look at a list of hosts that are on a csv/txt file then execute the following command saving the result in a csv format having the computer name, solidwork license registry entry.

enter image description here

This is the command I'm using this far,

Invoke-Command -ComputerName NAME -Command {Get-ItemProperty -Path HKLM:\SOFTWARE\SolidWorks\Licenses}

By default. Solidworks stores their license information on the following registry path

COMPUTERNAME\HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\Licenses\Serial Numbers\Solidworks

Chris

Posted 2018-04-20T19:03:55.897

Reputation: 1

1Import-Csv, a ForEach loop. Export-Csv - where do you have problems with? Remember [SU] is not a script writing service. Show your own coding effort. – LotPings – 2018-04-20T19:52:42.613

Answers

0

Something like this will give you a starting point:

#Get computers from text file. 1 compute per line
$myComputerList = Get-Content C:\Installs\computerList.txt

#Loop Through Array
ForEach ($computer in $myComputerList) {
    #Execute a command on the computer
    Invoke-Command -ComputerName $computer -ScriptBlock {
        #This is the command to execute
        #Grab the registry value you want and hold it in a variable
        $value = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" -Name ProductName
        #grab the machine name you're working on
        $computerName = $env:COMPUTERNAME
        #comma separate them and spit them out to a file.  This can be a UNC path on a network share
        ($computerName + "," + $value) | Out-File -FilePath C:\Installs\Output.csv -Append
    }
}

There are all sorts of additions you can make to this such as handling multiple registry values, testing whether the machine is on or not before you connect, handling access errors and uncontactable machines etc - but since this isnt a script writing service - I've just given you a brief starting out point

Fazer87

Posted 2018-04-20T19:03:55.897

Reputation: 11 177