Due to the recent more and more like to PowerShell, in the spare time, tidy up some of the common classic examples to share to everyone:
1. Active Directory, listing domain information
#===========================================
# list Domain Information
#===========================================
$strComputer = "." # Zivsoft-lihua
$colItems = Get-wmiobject-class "Win32_ntdomain"-namespace "root\cimv2"
-computername $strComputer
foreach ($objItem in $colItems) {
Write-host "Caption:" $objItem. Caption
Write-host "Client Site Name:" $objItem. Clientsitename
Write-host "Creation Class Name:" $objItem. CreationClassName
Write-host "DC Site Name:" $objItem. Dcsitename
Write-host "Description:" $objItem. Description
Write-host "DNS Forest Name:" $objItem. DnsForestName
Write-host "Domain Controller Address:" $objItem. domaincontrolleraddress
Write-host "Domain Controller address Type:" $objItem. Domaincontrolleraddresstype
Write-host "Domain Controller Name:" $objItem. DomainControllerName
Write-host "Domain GUID:" $objItem. Domainguid
Write-host "Domain Name:" $objItem. DomainName
Write-host "DS Directory Service Flag:" $objItem. Dsdirectoryserviceflag
Write-host "DS DNS Controller Flag:" $objItem. Dsdnscontrollerflag
Write-host "DS DNS Domain Flag:" $objItem. Dsdnsdomainflag
Write-host "DS DNS Forest Flag:" $objItem. Dsdnsforestflag
Write-host "DS Global Catalog Flag:" $objItem. Dsglobalcatalogflag
Write-host "DS Kerberos distribution Center Flag:" $objItem. Dskerberosdistributioncenterflag
Write-host "DS Primary Domain Controller Flag:" $objItem. Dsprimarydomaincontrollerflag
Write-host "DS time Service Flag:" $objItem. Dstimeserviceflag
Write-host "DS writable Flag:" $objItem. Dswritableflag
Write-host "Installation Date:" $objItem. InstallDate
Write-host "Name:" $objItem. Name
Write-host "Name Format:" $objItem. NameFormat
Write-host "Primary Owner Contact:" $objItem. primaryownercontact
Write-host "Primary Owner Name:" $objItem. Primaryownername
Write-host "Roles:" $objItem. Roles
Write-host "Status:" $objItem. Status
Write-host
}