locked
Export remote invoke-command get-item registry setting results to .xlsx? RRS feed

  • Question

  • Good morning,

    I'm having an issue with piping results from an invoke-command for get-itemproperty on registry settings on remote servers.

    The script is supposed to create a spreadsheet with the server name in column 1 and the DisabledComponents registry setting in column 2.

    The issue is, the results for column 2 are not showing up and I wind up with just a list of server names.

    How can I pipe the results of an invoke-command to the second column of a spreadsheet?

    Code:

    $erroractionpreference = "SilentlyContinue" 
     
    # New Spreadsheet
     
    $a = New-Object -comobject Excel.Application 
    $a.visible = $True  
     
    $b = $a.Workbooks.Add() 
    $c = $b.Worksheets.Item(1) 
     
    # Create and Format Columms
     
    $c.Cells.Item(1,1) = "Server Name" 
    $c.Cells.Item(1,2) = "DisabledComponents"
    
    $d = $c.UsedRange 
    $d.Interior.ColorIndex = 37 
    $d.Font.Bold = $True 
    $d.EntireColumn.AutoFit($True) 
     
    $intRow = 2 
     
    $serverlist = get-content C:\PowerShell\Scripts\IPv6.txt 
     
    # Process List of servernames 
     
    foreach ($servername in $serverlist) 
    { 
     
    $c.Cells.Item($intRow, 1) = $servername.ToUpper() 
     
    # Get DisabledComponents Registry Settings 
     
    $DisabledComponents = Invoke-Command -computername $servername {Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\TCPIP6\Parameters -Name DisabledComponents | Format-List "DisabledComponents"}
    
    $c.Cells.Item($intRow, 2) = $DisabledComponents
     
    $intRow = $intRow + 1 
    
    } 
     
    $intRow = $intRow + 1 
    Thanks!

    Tuesday, December 23, 2014 2:57 PM

Answers

All replies