Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
A procedure for exporting installed hotfix details of remote computers using powershell
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 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

12 Experts available now in Live!

Get 1:1 Help Now