Monday, 24 November 2008


    Gets and displays the role a computer plays in a domain
    This script uses WIN32_ComputerSystem to get the rold of a
    system then displays it. This is a re-write of an MSDN sample.
    File Name  : Get-DomainRole.ps1
    Author     : Thomas Lee -
    Requires   : PowerShell V2
    PowerShell script posted to:
    MSDN sample at:
    PSH [C:\foo]: .\Get-DomainRole.PS1
    Computer "" is a:
    Member Server

# Start of Script

# Get Computer info
$Computer = Get-WmiObject -Class Win32_ComputerSystem

# Print Role:
"Computer `"{0}.{1}`" is a: " -f $Computer.Name,$computer.domain
switch ($computer.DomainRole) {
0 {"Standalone Workstation"}
1 {"Member Workstation"}
2 {"Standalone Server"}
3 {"Member Server"}
4 {"Backup Domain Controller"}
5 {"Primary Domain Controller"}
#End of script

No comments: