How to get remote server variable using remote shell?
Hi, Guys
I use remote shell to manage an Exchange server. After executed following cmdlet, I import the server-side PowerShell session into my workstation's session
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchangerserver/PowerShell/ -Authentication Kerberos
Import-PSSession $Session
I can execute Exchange cmdlet. That's Ok.
Now I need to get a variable of Ex server $env:USERDNSDOMAIN. But I just get my workstation's variable.
So, how can I get remote server variable using remote shell?
Regards,
Kaneabell
April 15th, 2012 10:41pm
On Mon, 16 Apr 2012 02:41:27 +0000, Kaneabell wrote:
>
>
>Hi, Guys
>
>I use remote shell to manage an Exchange server. After executed following cmdlet, I import the server-side PowerShell session into my workstation's session $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchangerserver/PowerShell/
-Authentication Kerberos
>
>Import-PSSession $Session
>
>I can execute Exchange cmdlet. That's Ok.
>
>Now I need to get a variable of Ex server $env:USERDNSDOMAIN. But I just get my workstation's variable.
>
>So, how can I get remote server variable using remote shell?
Have you tried "invoke-command"?
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
April 15th, 2012 11:35pm
Hi Kaneabell,
please define your New-PSSessionOption and see if the parameter below is no set.
This parameter will prevent to load the Environment VARS.
-NoMachineProfile
Prevents loading the user's Windows user profile. As a result, the PSSession might be created faster, but user-specific registry settings, items such as
environment variables, and certificates are not available in the PSSession.
More information about New-PSSessionOption here
http://technet.microsoft.com/en-us/library/dd819436.aspx
Arne
Arne Tiedemann | Active Directory and Exchange specialist
April 16th, 2012 5:46am