Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR POWERSHELL

powershell scriptblock return variable

$server1 = "dc-1"

$server2 =  'dc-2' 

$server3 =  'app' 

$computers = ( $server1, $server2, $server3 ) 


$result3 = Invoke-Command -Credential $domaincredentials -ComputerName $computers -ScriptBlock { 

$SB = {
$objht = @{} 
$objht.Testa = 'testa'
$objht.Testb = 'testb'
$objht.Testc = 'testc'
New-Object psobject -propertyh $sb
}
}

write-host $result3
Source by community.spiceworks.com #
 
PREVIOUS NEXT
Tagged: #powershell #scriptblock #return #variable
ADD COMMENT
Topic
Name
1+5 =