powershell start-process script fix

Job ID: 34543078

Budget: $10 – $30 AUD

I have 2 PowerShell scripts, the first one where the main code, functions etc run and create some variables dynamically, and then
some of those variables have to be passed to the second script which has to run as another user

I have no time to figure out how to pass multiple arguments so I am looking for someone to sort this out quickly.

This won't take more than 5-10 minutes if you know what you are doing. So bid logically.
see the simple examples for sc1 and sc2 below.

---------------------------------------------------------
#### sc1.ps1

#code
#function

# dynamically created variables(array, string, integer...)
$foo1 = "0001xxx00sa01"
$foo2 = "12345"
$foo3 = "red blue foo fox"
$foo4 = "C:\xxx\xxx", "d:\xxx\yyy", "d:\foo", "e:\foo3"

$Mecred = Get-Credential

Start-Process -FilePath powershell -ArgumentList "-NoExit" ,"C:\script\sc2.ps1" -Credential $Mecred

# sc2 has to run as a different account
# parse the arguments to the second script respectively
# need to change the title of the PowerShell window & keep the window open

-----------------------------------------------------------------
#### sc2.ps1

[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[string]$foo1,
[Parameter(Mandatory=$true)]
[string]$foo2,
[Parameter(Mandatory=$true)]
[string]$foo3,
[Parameter(Mandatory=$true)]
[string]$foo4
)

#code
#bla bla
function CreateaNewTarget ($foo1,$foo2,$foo3,$foo4)
{
Write-Host $foo1
Write-Host $foo2
Write-Host $foo3
Write-Host $foo4
}
CreateaNewTarget $foo1 $foo2 $foo3 $foo4
Related categories: Windows Server Powershell