Product, version and build: 5.4.138_032917
32 or 64 bit version of product: PowerShellStudio 2017
Operating system: Server 2016
32 or 64 bit OS: 64
PowerShell Version: 5.0
Cannot Expand and Select specify properties
This is a part of my script and i would like to got the Property/Member "Major" but the output ist null:
PS Remoting to a Exchange Server is successful
$RemoteHost = (Get-PSSession).Computername
$Exchange_Version = (Get-ExchangeServer -Identity $RemoteHost | select -ExpandProperty AdminDisplayVersion).Major
In the EMS it works, so what can i do ?
Major:
Minor:
Build:
Revision:
FilePatchLevelDescription:
ExpandProperty dosent work
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: ExpandProperty dosent work
[TOPIC MOVED TO THE POWERSHELL FORUM BY MODERATOR]
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: ExpandProperty dosent work
It is not clear what you are trying to do. You are stating that you are remoting but are getting the session then trying to us it locally.
The remote session may not be the same system as the exchange server system.
Also note that Get-PsSession may return more than one session.
The remote session may not be the same system as the exchange server system.
Also note that Get-PsSession may return more than one session.
- Supervisor
- Posts: 2
- Last visit: Thu Jul 09, 2020 5:12 am
Re: ExpandProperty dosent work
First in PowerShellStudio connect to a Exchange Server via PS Remoting, so that is successful.... The Exchange Commands are available....
Implicit Remoting:
$server = "ServerName"
$Session = New-PSSession -Name "Exchange" -ConfigurationName Microsoft.Exchange -ConnectionUri http://$server/PowerShell/ -Authentication Kerberos
Import-PSSession $Session -DisableNameChecking
Now the Problem: (I would like to check the PS Session -> Exchange Version (Major)14 or ...)
$Version = (Get-ExchangeServer -Identity ((Get-PSSession).Computername) | select -ExpandProperty AdminDisplayVersion).Major
Write-host "Version ----> $Version"
The output is null but a session is available (Get-PSSession).Computername -> Name of a ExchangeServer
The same Command in EMS:
Version -----> 14
Is there a failure in the Remoting or missing any assemblies ?
Implicit Remoting:
$server = "ServerName"
$Session = New-PSSession -Name "Exchange" -ConfigurationName Microsoft.Exchange -ConnectionUri http://$server/PowerShell/ -Authentication Kerberos
Import-PSSession $Session -DisableNameChecking
Now the Problem: (I would like to check the PS Session -> Exchange Version (Major)14 or ...)
$Version = (Get-ExchangeServer -Identity ((Get-PSSession).Computername) | select -ExpandProperty AdminDisplayVersion).Major
Write-host "Version ----> $Version"
The output is null but a session is available (Get-PSSession).Computername -> Name of a ExchangeServer
The same Command in EMS:
Version -----> 14
Is there a failure in the Remoting or missing any assemblies ?
Re: ExpandProperty dosent work
Your insistence on doing everything on one line is getting in the way of you understanding what is happening.
Jut get the object and select the property. There is no need to do all of that expanding.
Inspect the results of getting each object until you see how the object works.
Remoted objects get serialized and can behave oddly when you try to get fancy.
Jut get the object and select the property. There is no need to do all of that expanding.
Inspect the results of getting each object until you see how the object works.
Remoted objects get serialized and can behave oddly when you try to get fancy.