Using the "Button - Start-Job" control set in Powershell studio, I'm trying to work on how to retrieve a variable I am setting in a Start-Job command, code looks like the following...
$Job1 = @{
Name = 'Job1'
JobScript = {
Param ($global:usercred)
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://ServerName.domain.com/PowerShell -Credential $global:usercred -Authentication Kerberos
Import-Module (Import-PSSession $s -AllowClobber -DisableNameChecking) -DisableNameChecking
$DAG07 = (Get-MailboxDatabase | where { $_.MasterServerOrAvailabilityGroup -eq "USADAG07" }).count
$DAG08 = (Get-MailboxDatabase | where { $_.MasterServerOrAvailabilityGroup -eq "USADAG08" }).count
for ($i = 0; $i -lt 50; $i++) { Start-Sleep -Milliseconds 100 }
}
ArgumentList = $global:usercred
CompletedScript = {
Param ($Job)
????????????
}
UpdateScript = {
Param ($Job)
}
}
I am not sure what to use in the CompleteScript block to call the 2 variables $DAG07 and $DAG08 from the JobScript.