I am testing a process on passing in an array of items to powershell and I'm having a hard time with the ScriptBlock. I created a test function:
function TEST
{
$ScriptBlock =
{
param (
$BackupPath ="Z:\1\2\",
[array]$DBN, #= @("1", "2", "3"),
$ServerInstance = "10.10.10.10"
)
Foreach ($DBName in $DBN)
{
write-host "$($DBName)"
}}}
I then call this function:
$DBN = @("1", "2", "3")
TEST -ArgumentList (,$DBN)
I've tried various methods but it can't loop through and give me back the results. Any help on ScriptBlock inside a function like this will be useful. Thanks!