Tag Archives: get

Windows: Get a list of Remote Desktop Logons

Hi,

if you want to know who and from which station a user logs on via remote desktop you can use the following powershell commands.
Continue reading Windows: Get a list of Remote Desktop Logons

Advertisment to support michlstechblog.info

Powershell: Accessing Applications and Services Logs

Hi,

for showing or exporting the System, Application and Security Log the command let Get-EventLog is the first choice.
Continue reading Powershell: Accessing Applications and Services Logs

C#: Get description attribute from an enum value

Hi,

in this post I will show how to read a description attribute of an enum value by reflection. Let us assume we have a enum linke this

public enum MetalBands {
	[DescriptionAttribute("This is Metallica from CA")]
	Metallica,
	[DescriptionAttribute("This is Slayer from CA")]
	Slayer,
	[DescriptionAttribute("This is Overkill from NY")]
	Overkill
};

Continue reading C#: Get description attribute from an enum value

Windows: How to determine the SID of a User or Group

Hi,

Sometimes you need the SID of a user or group. For example if you want to set permissions with icalcs in multilanguage environments. icacls needs as input the group name or the SID. If you want to set permission for the builtin groups you have to specify the group name in the current language of the operating system, i.e. “Users” for en-US and “Benutzer” for de-DE. The better choice is the SID, the SIDs for builtin groups are always the same.
Continue reading Windows: How to determine the SID of a User or Group

Windows: Script to get the NetBIOS Name of an Active Directory Domain

Hi,

just a short post :-). A powershell script to get the NetBIOS Name of an Active Directory Domain


###############################################################################
# Gets the NetBIOS Domain
# Author Michael Albert michlstechblog.info
# License: GPL v2
###############################################################################
[reflection.assembly]::LoadWithPartialName("System.DirectoryServices.Protocols")|Out-Null

if($args.count -ne 1){
    Write-Warning " Start script with fqdn as parameter"
    Write-Warning (" for example: "+$myInvocation.myCommand.name+" yourdomain.com")
    exit 1
}
$sDomainName=$args[0]
# Get AD Root
$oRootDSE = [ADSI]"LDAP://RootDSE"
$sConfig = $oRootDSE.Get("configurationNamingContext")
# AD Object AD Root
$oADSearchRoot=New-object System.DirectoryServices.DirectoryEntry("LDAP://CN=Partitions," + $sConfig)
# Search for Netbiosname of the specified domain
$sSearchString="(&(objectclass=Crossref)(dnsRoot="+$sDomainName+")(netBIOSName=*))"
$oSearch=New-Object directoryservices.DirectorySearcher($oADSearchRoot,$sSearchString)
$sNetBIOSName=($oSearch.FindOne()).Properties["netbiosname"]
# Print out
Write-Host "Domain NetBIOS Name:" $sNetBIOSName

Have fun :-)!

Michael