I am trying to make a cmdlet reference as a cheat sheet while I study for the MCSA. I would like a spreadsheet that contains the cmdlet name, the module, the synopsis and the description. The problem comes in on the description side. I can use the code below to loop through my commands and build an array of name module and synopsis.
$commands_array = @() $commands = 'Enter-PSSession','Get-Command' foreach ($command in $commands) { $item = New-Object PSObject $command_help = Get-Help $command $command_description = $command_help | select -ExpandProperty description $item | Add-Member -NotePropertyName Name -NotePropertyValue $command_help.Name $item | Add-Member -NotePropertyName ModuleName -NotePropertyValue $command_help.ModuleName $item | Add-Member -NotePropertyName Synopsis -NotePropertyValue $command_help.Synopsis $commands_array += $item } $commands_array | Export-Csv -Path D:\Profile\Desktop\cmdlets.csv -NoTypeInformation
But when I throw in the description line after the synopsis
$commands_array = @() $commands = 'Enter-PSSession','Get-Command' foreach ($command in $commands) { $item = New-Object PSObject $command_help = Get-Help $command $command_description = $command_help | select -ExpandProperty description $item | Add-Member -NotePropertyName Name -NotePropertyValue $command_help.Name $item | Add-Member -NotePropertyName ModuleName -NotePropertyValue $command_help.ModuleName $item | Add-Member -NotePropertyName Synopsis -NotePropertyValue $command_help.Synopsis $item | Add-Member -NotePropertyName Description -NotePropertyValue $command_description $commands_array += $item } $commands_array | Export-Csv -Path D:\Profile\Desktop\cmdlets.csv -NoTypeInformation
The CSV file has System.Object as the value for the description field. I think the issue is that for some reason the description field is an array of text values. I cannot figure out for the life of me how to export the full description to the description field in the CSV. Ideally with the same multi-line formatting with all the pretty line breaks and such, but I would take a straight dump at this point.
Any guidance would be greatly appreciated!
Thank you much!!