Consider the following situation:
Content MyScript.ps1
:
Param (
[String]$CountryCode,
[String]$FilesPath,
[String]$KeepassDatabase,
[String]$KeepassKeyFile,
[String]$EventLog = 'HCScripts',
[String]$EventSource,
[HashTable]$CitrixFarm = @{'Server1' = '6.5'}
)
$CountryCode
$FilesPath
$KeepassDatabase
$KeepassKeyFile
$EventLog
$EventSource
$CitrixFarm
Content of the Caller.ps1
:
Param (
$FilesPath = ".\MyScript.ps1",
$EvenntLog = 'Test',
$CountryCode = 'BNL',
$KeepasDatabase,
$KeepasKeyFile
)
$Arguments = @()
$Arguments += "-EventSource ""$AppName"""
$Arguments += "-EventLog ""$EventLog"""
$Arguments += "-FilesPath ""$((Get-Item $FilesPath).FullName)"""
$Arguments += "-CountryCode ""$CountryCode"""
$Arguments += "-KeepassDatabase ""$((Get-Item $KeepasDatabase).FullName)"""
$Arguments += "-KeepassKeyFile ""$((Get-Item $KeepasKeyFile).FullName)"""
$Arguments += "-CitrixFarm $CitrixFarm"
$StartParams = @{
Credential = $Credentials
ArgumentList = "-File ""$ScriptPath"" -verb runas" + $Arguments
WindowStyle = 'Hidden'
}
Start-Process powershell @StartParams
We can't seem to find a way to pass in the [HashTable]
for the argument $CitrixFarm
. How is it possible to add that argument. or pass it on to the script called by Start-Process
with elevated permissions and in a new PowerShell session?
When omitting the parameter $CitrixFarm
all is working fine. So the problem really is with passing the HashTable
.