PowerShell Hash Tables

    #I like to use Hash tables to return a mutitude of values when using Invoke-Command 
        
    $Hotfix = Get-Hotfix | Select -ExpandProperty HotfixID

    $Services = Get-Service | Where {$_.Status -eq "Running"} | Select -ExpandProperty Name

    $Enabled_Local_Accounts=Get-WmiObject -Class Win32_UserAccount -Filter {LocalAccount ='True' and Disabled='False'} | Select -ExpandProperty Name

    $Drives=Get-PSDrive | Where{$_.Free -ne $Null} | Select -ExpandProperty Name 
    
   
#Creatre Hash and add Multiple Values 
    $MyHASH=@{
        Running_Services=$Services;
        Installed_Hotfix=$Hotfix;
        Enabled_Local_accounts=$Enabled_Local_Accounts
        Hard_Drives=$Drives
    }    

    #Access Hash Data    
    $MyHASH.Installed_Hotfix

2020 | Scott W. Head  |  Sr. Systems Admin | Certified Microsoft Windows Server Administrator