How to pass object to between scripts

by Jul 17, 2015

I am trying to figure out, if it is possible, how to pass a custom object between scripts.  Something is passed so I know that the command is working, but when I echo the argument, I only get the first part.

BuildObject Script

[code]$ComputerName = $env:COMPUTERNAME

$osprops = "Caption","CSDVersion","LastBootUpTime","OSArchitecture","InstallDate"
$WMIOS = Get-WmiObject Win32_OperatingSystem -ErrorAction SilentlyContinue -computername $ComputerName | Select $osprops

$csprops = "Name","UserName","Manufacturer","Model"
$wmiCS = GWMI Win32_ComputerSystem -ComputerName $ComputerName -ErrorAction SilentlyContinue | Select $csprops

$object = [PSCustomObject]@{
    Manufacturer = $wmiCS.Manufacturer
    Model = $wmiCS.Model
    OpSys = $WMIOS.Caption
    SvcPack = $WMIOS.CSDVersion
    ComputerName = $wmiCS.Name
    UserName = $wmiCS.UserName
}

$something = "Blah"
$filepath = ".CallScript.ps1"
$arglist = "-WindowStyle normal -NoLogo -NoProfile -NoExit -File $filepath $ComputerName -stuff $object -test $something"

$object
Start-Process powershell.exe -ArgumentList $arglist [/code]

Callscript.ps1

[code]param($Stuff,
      $test
    )

$Stuff.gettype()
$test.gettype()

Write-Host $stuff
Write-Host $test[/code]

My output from CallScript
IsPublic IsSerial Name                                     BaseType
——– ——– —-                                     ——–
True     True     String                                   System.Object
True     True     String                                   System.Object
@{Manufacturer=Dell
Blah

So, what it boils down too, is it possible to pass the object between scripts or do I need to have each item as a separate argument?