Solved

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

Posted on 2010-08-13
4
2,957 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now