Solved

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

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Questions about DHCP migration 5 57
Powershell 'Like' Command Query 5 33
Formatting output of an AD query 3 16
Need some powershell help please 5 23
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

775 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