troubleshooting Question

Property cannot be found on a hashtable passed in from another script

Avatar of Alan Varga
Alan VargaFlag for United States of America asked on
Powershell* hashtable
8 Comments1 Solution409 ViewsLast Modified:
I can't believe how difficult it is to find how to parse and use parameters passed in from another script!  I've been at this for almost 5 hours.

There are plenty of articles on how to create a hashtable, and some on how to pass a hashtable to another script, but nothing on what to do with the hashtable once the target script receives it.

This is an excerpt from "Test 1A-sending script.ps1"
$parms = @{
    ComputerName = 'mike';
    ComputerId = 'SYS 001'
}

#Display hashtable
$parms.Keys
$parms.Values

$filePath = ".\Test 1B-receiving script.ps1"
$commandLine = "-NoExit & `'$filePath`' $parms"
Write-Host `n$commandLine -f Cyan

Start-Process Powershell.exe -ArgumentList $commandLine

and this is an excerpt from "Test 1B-receiving script.ps1"
Param(
    $parms2
)

Write-Host "Made it to test 1B."
Write-Host $parms2 -ForegroundColor Yellow
Write-Host $parms2.ComputerName -ForegroundColor Gray

Here are the results of running the sending script, which appear in a separate window for the receiving script:
Made it to test 1B.
System.Collections.Hashtable
The property 'ComputerName' cannot be found on this object.  Verify that the property exists.
At: C:\Workshop\PowerShell-work\Passing arguments\Test 1B-receiving script.ps1:61 char:1
+Write-Host $parms2.ComputerName -ForegroundColor Gray
ASKER CERTIFIED SOLUTION
Ben Personick (Previously QCubed)
Lead SaaS Infrastructure Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros