combining output from two commands

Ok, I’m trying to learn, and I usually do that by kludging pieces of other’s code together to make it work for my purposes. What I’d like to do (converting to html or not) is combine specific fields of get-fsrmquota and a query of share info into one ‘report’. while this only looks at 1 computer, I’d like to do it for a list with the option of 1 big output, or 1 output for each computer in the list ala ForEach ($system in Get-Content “c:\temp\systems.txt”
I’m sure there are syntax usage errors in this also (ie, semicolon versus comma)
Any help given is greatly appreciated.

$fileserver = Read-Host “Enter Server Name”

$Header = @"

TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
TR:Hover TD {Background-Color: #C1D5F8;}


# Quota
$quota = Get-FSRMQuota -CimSession $fileserver | select @{name='Backend Server';expression={$_.PSComputerName}},Path,@{n='Quota Size (in GB)';e={[int]($_.Size/1GB)}},@{n='GB Usage';e={[int]($_.Usage/1GB)}} #| Export-csv QuotaOutput.csv -append

# Share Permissions
# ExportShareInfo.ps1
# This script will export type 0 shares with security info, and provide a hash table of shares
# in which security info could not be found.
# SID was removed from the script. Instead, the username is used to find SID when the import is run
# EricG-thehashtable of problemshares never worked for me
$date = get-date
$datefile = get-date -uformat '%m-%d-%Y-%H%M%S'
#Store shares where security cant be found in this hash table
$problemShares = @{}
Function Get-ShareInfo($shares) {
$arrShareInfo = @()
Foreach ($share in $shares) {
write-host $
$strWMI = "\\" + $fileServer + "\root\cimv2:win32_LogicalShareSecuritySetting.Name='" + $ + "'"
$objWMI_ThisShareSec = $null
$objWMI_ThisShareSec = [wmi]$strWMI
#In case the WMI query or 'GetSecurityDescriptor' fails, we retry a few times before adding to 'problem shares'
For($i=0;($i -lt 5) -and ($objWMI_ThisShareSec -eq $null);$i++) {
sleep -milliseconds 200
$objWMI_ThisShareSec = [wmi]$strWMI
$objWMI_SD = $null
$objWMI_SD = $objWMI_ThisShareSec.invokeMethod('GetSecurityDescriptor',$null,$null)
For($j=0;($j -lt 5) -and ($objWMI_SD -eq $null);$j++) {
sleep -milliseconds 200
$objWMI_SD = $objWMI_ThisShareSec.invokeMethod('GetSecurityDescriptor',$null,$null)
If($objWMI_SD -ne $null) {
$arrShareInfo += $objWMI_SD.Descriptor.DACL | % {
$_ | select @{e={$};n='Name'},
Else {
$ProblemShares.Add($, "failed to find security info")
return $arrshareInfo

$shares = gwmi Win32_Share -computer $fileServer -filter 'type=0'
$ShareInfo = Get-ShareInfo($shares)
Write-Host " Complete" -ForegroundColor green

# not used atm.  filter out usernames of "system" and "administrators"
#  $ShareInfo | select Name,Path,Description,User,Domain,AccessMask,AceFlags,AceType | where user -ne 'system' | where user -ne 'administrators' | export-csv -noType $filename
# combine quota and share info
$combinedinfo = $quota.@{name='Backend Server';
$quota.@{name='Quota Size (in GB)';
expression={[int]($quota_.Size/1GB)}},$quota.@{n='GB Usage';

$tableinfo = New-Object -TypeName psobject -Property $combinedinfo

# output
ConvertTo-HTML -InputObject $tableinfo -Head $Header -Title "Quota Information" | Out-File "C:\temp\QuotaInfo.htm"
Invoke-Item -Path "C:\temp\quotainfo.htm"

New-Object : Cannot convert ‘System.Object[]’ to the type ‘System.Collections.IDictionary’ required by parameter ‘Property’. Specified method is not supported.
At \site-it-fs\root\DDOAdmin\Scripts\Powershell\Quota-ShareInfo\Combined_quota-shareinfo-html.ps1:97 char:54

  • $tableinfo = New-Object -TypeName psobject -Property $combinedinfo
  •                                                  ~~~~~~~~~~~~~
    • CategoryInfo : InvalidArgument: (:slight_smile: [New-Object], ParameterBindingException
    • FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.NewObjectCommand

So, have you read our HTML Reporting book (Ebooks menu)? It tackles pretty much this exact topic in a fairly methodical way - and i think it’ll mean less work for you.

The problem is that $combinedinfo isn’t a hashtable.

$combinedInfo = @{ ‘Property’ = ‘Value’
‘Property’ = ‘Value’
‘Property’ = ‘Value’

Is what I’d expect. But you’ve just supplied values, and you’ve one it as an array of objects. I’ll also recommend “Learn PowerShell Toolmaking in a Month of Lunches.” It really explains the whys and hows of what you’re after, and it’ll set you on a pth toward doing it right, in terms of making your code PowerShell-friendly.

I’ll definitely take a look. thanks for the heads up.