Exchange Remoting missing information

I'm trying to build a script that will get information from Exchange

Here's an example to my problem:

When I run the $exServer = get-ExchangeServer command on an Exchange server, All values are within $exServer

When I write: $exServer.AdminDisplayVersion
I get the result:

Major : 15
Minor : 0
Build : 1156
Revision : 6
FilePatchLevelDescription :

 

When I write: $exServer.AdminDisplayVersion.Major

I get the result: 15

 

And when I try to make it remoting
The result is different:

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri Exchange_Server_Name/PowerShell -Authentication Kerberos 
$exServer = Invoke-Command -Session $session -ScriptBlock {Get-ExchengeServer}

 

When I write: $exServer.AdminDisplayVersion

I get the result: Version 15.0 (Build 1156.6)

There is no major at all

(And this is just an example)

 

I would highly appreciate the help, I have been trying to solve this for quite some time

Parents
No Data
Reply
  • That is because the value returned is the full version info, not the split / array.

    On real Exchange it does the parsing for you. I've personally never looked for this sort of break out. The full version string is all I've ever needed.

    So, though it is not broken out, it is all there.

    Major.Minor Build.Revision
    Version 15.1 (Build 669.32)

    So, if you are looking to do this as a array as if you were on the Exchange server
    remotely, then you need to manipulate that string to break it apart.

    Something like.


    $Counter = 0
    'Major : ','Minor : ','Build : ','Revision : ' | % {$Counter += 1
    $_ + [regex]::Matches((Get-ExchangeServer).AdminDisplayVersion, "\d+[?!*\d+]|[\d+[?!*\d]").value[$Counter -1]
    }

    Major : 15
    Minor : 1
    Build : 669
    Revision : 32

    Now, I used kind of a funky ForLoop here and I could have just done this:

    'Major : ' + [regex]::Matches((Get-ExchangeServer).AdminDisplayVersion, "\d+[?!*\d+]|[\d+[?!*\d]").value[0]
    'Minor : ' + [regex]::Matches((Get-ExchangeServer).AdminDisplayVersion, "\d+[?!*\d+]|[\d+[?!*\d]").value[1]
    'Build : ' + [regex]::Matches((Get-ExchangeServer).AdminDisplayVersion, "\d+[?!*\d+]|[\d+[?!*\d]").value[2]
    'Revision : ' + [regex]::Matches((Get-ExchangeServer).AdminDisplayVersion, "\d+[?!*\d+]|[\d+[?!*\d]").value[3]

    Major : 15
    Minor : 1
    Build : 669
    Revision : 32

    But I wanted to not have to repeat the RegEx multiple individual times.

    Yet, still, I am unsure why this is a thing for you, but I am sure you have your reasons. I know this does not explain why the cmdlet parse differently via local vs remote, but again, you are not missing any data. You are just not getting the same display.
Children