Here's a script that will populate all the keys in HKEY_CLASSES_ROOT in alphabetical order in an excel spreadsheet:
$oexcel = new-object -comobject Excel.Application
$Workbook = $oexcel.Workbooks.Add()
$oexcel.Visible = $true
$regkey = [Microsoft.Win32.Registry]::ClassesRoot
$Names = $regkey.GetSubKeyNames()
[string]$n
[array]$myvar = [System.Array]::CreateInstance([string], 26)
$myvar[0] = "A"
$myvar[1] = "B"
$myvar[2] = "C"
$myvar[3] = "D"
$myvar[4] = "E"
$myvar[5] = "F"
$myvar[6] = "G"
$myvar[7] = "H"
$myvar[8] = "I"
$myvar[9] = "J"
$myvar[10] = "K"
$myvar[11] = "L"
$myvar[12] = "M"
$myvar[13] = "N"
$myvar[14] = "O"
$myvar[15] = "P"
$myvar[16] = "Q"
$myvar[17] = "R"
$myvar[18] = "S"
$myvar[19] = "T"
$myvar[20] = "U"
$myvar[21] = "V"
$myvar[22] = "W"
$myvar[23] = "X"
$myvar[24] = "Y"
$myvar[25] = "Z"
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$workbook.Worksheets.Add()
$sheet = $workbook.worksheets.Item(1)
$sheet.name = "A"
$sheet = $workbook.worksheets.Item(2)
$sheet.name = "B"
$sheet = $workbook.worksheets.Item(3)
$sheet.name = "C"
$sheet = $workbook.worksheets.Item(4)
$sheet.name = "D"
$sheet = $workbook.worksheets.Item(5)
$sheet.name = "E"
$sheet = $workbook.worksheets.Item(6)
$sheet.name = "F"
$sheet = $workbook.worksheets.Item(7)
$sheet.name = "G"
$sheet = $workbook.worksheets.Item(8)
$sheet.name = "H"
$sheet = $workbook.worksheets.Item(9)
$sheet.name = "I"
$sheet = $workbook.worksheets.Item(10)
$sheet.name = "J"
$sheet = $workbook.worksheets.Item(11)
$sheet.name = "K"
$sheet = $workbook.worksheets.Item(12)
$sheet.name = "L"
$sheet = $workbook.worksheets.Item(13)
$sheet.name = "M"
$sheet = $workbook.worksheets.Item(14)
$sheet.name = "N"
$sheet = $workbook.worksheets.Item(15)
$sheet.name = "O"
$sheet = $workbook.worksheets.Item(16)
$sheet.name = "P"
$sheet = $workbook.worksheets.Item(17)
$sheet.name = "Q"
$sheet = $workbook.worksheets.Item(18)
$sheet.name = "R"
$sheet = $workbook.worksheets.Item(19)
$sheet.name = "S"
$sheet = $workbook.worksheets.Item(20)
$sheet.name = "T"
$sheet = $workbook.worksheets.Item(21)
$sheet.name = "U"
$sheet = $workbook.worksheets.Item(22)
$sheet.name = "V"
$sheet = $workbook.worksheets.Item(23)
$sheet.name = "W"
$sheet = $workbook.worksheets.Item(24)
$sheet.name = "X"
$sheet = $workbook.worksheets.Item(25)
$sheet.name = "Y"
$sheet = $workbook.worksheets.Item(26)
$sheet.name = "Z"
for($x=0;$x -lt $myvar.GetLength(0);$x++)
{
$sheet = $workbook.worksheets.Item($x+1)
$y = 0
foreach($Name in $Names)
{
$pos = $Name.IndexOf($myvar[$x])
if($pos -eq 0)
{
$sheet.cells.item($y+1,1) = $Name
$y=$y+1
}
}
$oexcel.Columns.HorizontalAlignment = -4131
$iret = $oexcel.Columns.AutoFit()
}
No comments:
Post a Comment