Variable en sortie d'Invoke-Command
Bonjour,
Je souhaite pouvoir récupérer le ou les résultats des différentes commandes lancés dans invoke-command, je ne trouve pas comment faire.
Pour commencer simplement, comment puis je récupérer la valeur $Jeton à la sortie d' invoke-command qui passe de 0 à 1 ou 2 en fonction de la présence du fichier ou non?
Exemple:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
$OldServer = "Comput1"
$VM_Nom = "Comput2"
$Jeton = "0"
$BizInI = "D:\applicat\prog\bizerba\BIZTRACK\biztrack.ini"
$pattern = "NOM_SERVEUR_FICHIER_HF_CS=$OldServer"
$pattern1 = "NOM_SERVEUR_FICHIER_HF_CS=$VM_Nom"
$Biz = Invoke-Command -session $RemoteSession -scriptblock {
param( $VM_Nom, $OldServer, $BizInI, $Jeton, $pattern, $pattern1 )
If ( !( Test-Path $BizInI ) )
{
Write-Host "Le fichier Biztrack.ini est innaccessible ou inexistant" -ForegroundColor Red
Write-Host "Arrêt du script"
$Jeton = "2"
Exit
}
Else
{
Write-Host "Modification du champs NOM_SERVEUR du fichier Biztrack.ini" -ForegroundColor Green
( ( Get-Content $BizInI ).Replace( $pattern, $pattern1 ) ) | Set-Content $BizInI
$Jeton = "1"
}
} -ArgumentList ( $VM_Nom, $OldServer, $BizInI, $Jeton, $pattern, $pattern1 ) |