<# .SYNOPSIS Gets and displays the role a computer plays in a domain .DESCRIPTION This script uses WIN32_ComputerSystem to get the rold of a system then displays it. This is a re-write of an MSDN sample. .NOTES File Name : Get-DomainRole.ps1 Author : Thomas Lee - tfl@psp.co.uk Requires : PowerShell V2 .LINK PowerShell script posted to: http://pshscripts.blogspot.com/2008/11/get-domainroleps1.html MSDN sample at: http://pshscripts.blogspot.com/2008/11/get-domainroleps1.html .EXAMPLE PSH [C:\foo]: .\Get-DomainRole.PS1 Computer "COOKHAM8.cookham.net" 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
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Monday, 24 November 2008
Get-DomainRole.ps1
Labels:
powershell,
PowerShell scripts,
win32_operatingsystem,
wmi
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment