Both of my servers (remote and local) have Powershell 3.0 installed, however running the script below on it is giving me a warning message asking to update to version 2.0. The strange thing is that (Get-Host).Version is giving me different values whether the command is executed locally or remotely (Please see notes below for example)
this is my powershell script:
$Uri = "http://" + $ExternalHost + ":5985"
$username = $Domain + "\********"
# Setup and start remote session
$pw = convertto-securestring -AsPlainText -Force -String "********"
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $pw
$session = new-pssession -ConnectionUri $Uri -credential $cred
$report = Invoke-Command -Session $session -ScriptBlock {
Add-PSSnapin -Name VeeamPSSnapIn -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
$sessionVMSummary = @()
get-vbrjob | foreach{
$session = $_.findlastsession();
if (($session -ne $NULL) -and ($_.isScheduleEnabled -eq $TRUE)) {
$Info = [Veeam.Backup.Core.CBackupTaskSession]::GetByJobSession($session.id) | select -Property ObjectName, Reason, QueuedTime, Status
$sessionDocument = New-Object PSObject -Property @{
"Name" = $session.Name
"Result" = $session.Result
"CreationTime" = $session.CreationTime
"EndTime" = $session.EndTime
"JobType" = $session.JobType
"ObjectStatus" = $Info
}
$sessionVMSummary += $sessionDocument
}
}
return $sessionVMSummary
}
and this is what $ExternalHost is returning:
"WARNING: You should update your PowerShell to PowerShell 2.0 version. <== I NEED TO GET RID OF THIS WARNING MESSAGE
[
{
"Name": ********,
"CreationTime": "\/Date(1402290392717)\/",
"ObjectStatus": {
"ObjectName": ********,
"Reason": "",
"QueuedTime": "\/Date(1402290405917)\/",
"Status": {
"value": 0,
"Value": "Success"
}
},
"Result": {
"value": 0,
"Value": "Success"
},
"EndTime": "\/Date(1402291286497)\/",
"JobType": {
"value": 0,
"Value": "Backup"
},
"PSComputerName": ********,
"RunspaceId": "ad3ea82d-48dd-4135-9648-8bf3bba75e46",
"PSShowComputerName": true
}
]
"
NOTE: Somehow I am get different build version
I get PS version 3 on the local server PS C:\Users\ea_admin> (Get-Host).Version
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
And I get PS version 1 on same server running (Get-Host).Version remotely: Invoke-Command -Session $session { return (Get-Host).Version }
"Major": 1,
"Minor": 0,
"Build": 0,
"Revision": 0,
"MajorRevision": 0,
"MinorRevision": 0,
"PSComputerName": "remote.servertest.com",
"RunspaceId": "23634ba8-bfe3-4242-8593-bed3d9aa8ad1",
"PSShowComputerName": true
QUESTION: Why am I getting different versions?