Solved

Powershell - Setting the $AdminSessionADSettings.ViewEntireForest=$true parameter at startup

Posted on 2010-08-13
4
3,055 Views
Last Modified: 2012-05-10
$AdminSessionADSettings.ViewEntireForest=$true

I added the above line to my powershell profile ($profile) so that I don't have to set the scope for AD everytime I use the shell.  When I launch the shell, I get the following error:

Property 'ViewEntireForest' cannot be found on this object; make sure it exists
 and is settable.
At C:\Documents and Settings\Allen.Jones\My Documents\WindowsPowerShell\Micros
oft.PowerShell_profile.ps1:1 char:25
+ $AdminSessionADSettings.V <<<< iewEntireForest=$true

However, I can then manually type in the command after the shell is loaded.

1. Is there a way to accomplish this?
2. Why is it that the shell will accept the command manually but not at startup?

0
Comment
Question by:LN41
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:RyanAndres
ID: 33434563

$($AdminSessionADSettings.ViewEntireForest) = $true

Open in new window

0
 
LVL 1

Author Comment

by:LN41
ID: 33434669
I'm running XP pro, powershell v2, do you get the same result?

Invalid assignment expression. The left hand side of an assignment operator nee
ds to be something that can be assigned to like a variable or a property.
At C:\Documents and Settings\Allen.Jones\My Documents\WindowsPowerShell\Micros
oft.PowerShell_profile.ps1:1 char:46
+ $($AdminSessionADSettings.ViewEntireForest) =  <<<< $true
0
 
LVL 13

Expert Comment

by:soostibi
ID: 33438090
Unfortunately the profile is run before the $adminsessionadsettins variable is created. You should change the parameters of the shortcut of the EMS. The 'target' of the original one:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1'"

You should create a scriptfile similar to this yourscript.ps1:
'C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1'
$AdminSessionADSettings.ViewEntireForest=$true

And change the target of the shortcut of the EMS to:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -noexit -command pathofyourscript\yourscript.ps1

(If your path contains a space then:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -noexit -command ". 'pathofyourscript\yourscript.ps1'"
0
 
LVL 13

Accepted Solution

by:
soostibi earned 400 total points
ID: 33438106
Sorry, one period sign is missing from here:

You should create a scriptfile similar to this yourscript.ps1:
. 'C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1'
$AdminSessionADSettings.ViewEntireForest=$true
0

Featured Post

What, When and Where - Security Threats from Q1

Join Corey Nachreiner, CTO, and Marc Laliberte, Information Security Threat Analyst, on July 26th as they explore their key findings from the first quarter of 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question