Background:
I have a powershell script:script1 that takes in a sourceDirectory and two destinations (call them dest1Directory and dest2Directory).
The sourceDirectory is structured like this:
\Source\dest1\STUFF1
and
\Source\dest2\STUFF2
script1 calls another script:script2, foreach STUFF (so script2 may be run 10 times for example), providing script2 with the necessary destination parameter, which creates backups of all of the contents "STUFF" is replacing on dest1Directory and dest2Directory, and then copies all of STUFF to the corresponding destination.
Script1:
foreach ($folder in $STUFF1)
{
& $script2 -stuffParameter $folder -destDrive $dest1Directory -backUpDrive $BackUpDirectory
}
The issue I'm having is:
I'm calling script1 from a visual studio website and would like script2 to output all of the backup directory paths it creates so I have references to them for later. I have tried this inside of script2:
$returnRollBackObj = New-Object Object
Add-Member -memberType NoteProperty -name "RollBackLocation" -value $folderobj -inputObject $returnRollBackObj
return $returnRollBackObj
But it doesn't seem to return the objects since they are subscript calls. I don't know how to return an undefined number of these objects from script1 so I'm at a loss. Can someone help me out?