Friday, 28 November 2008

Get-Forest.ps1

<#
.SYNOPSIS
    Shows use of GetCurrentForest to return information about the forest  
.DESCRIPTION
    This script uses .NET to return name of forest. 
.NOTES
    File Name  : Get-Forest.ps1
    Author     : Thomas Lee - tfl@psp.co.uk
    Requires   : PowerShell V2
.LINK
    http://pshscripts.blogspot.com/2008/11/get-forestps1.html
.EXAMPLE
    PS c:\foo> .\Get-Forest.ps1
    You are connected to the Cookham.NET forest
#>

##
#  Start of script
##

# Get Forest name
$forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() 

# Display info
"You are connected to the {0} forest" -f $forest.name

No comments: