Category Archives: Windows

Windows tips, howtos, scripts

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

Advertisment to support michlstechblog.info

Windows Update and Windows Search do not work

Hi,

a good friend of mine came to me last week because some services of Windows Vista on his notebook did not run as expect. In detail:

  • Windows Search service starts but terminates
    • EventID 7034: The Windows Search service terminated unexpectedly.  It has done this 4 time(s).

      Windows search terminates after start
      Windows search terminates after start
    • EventID 7024: The Windows Search service terminated with service-specific error 2147749155 (0x80040D23)
    • EventID 1006: The Windows Search Service has failed to create the new search index. Internal error <4, 0x8004117f
    • EventID 9000: The Windows Search Service cannot open the Jet property store.
  • Windows Update service starts, but do not work, some errors are logged in C:\Windows\WindowsUpdate.log
    • 45c    DtaStor    FATAL: Failed to initialize datastore, error = 0xC8000247
    • 45c    AU    FATAL: Failed to get session from datastore, error = 0xC8000247
    • 45c    AU    FATAL: Failed to Unserialize from data store, error = 0xC8000247
  • No Windows Update File could installed by double clicking a msu File.
  • Cryptocraphic service do not run as expected:
    • Signature for Windows builtin programs cannot be verified, for example mmc.exe. Error Message:

      Do you want the following program to allow changes to this computer?

      UAC Message: builtin executables could not verified.
      UAC Message: builtin executables could not verified.
    • Cause: The folder c:\windows\system32\catroot2 is empty or/and some errors are logged in file C:\Windows\System32\catroot2\dberr.txt:
      CatalogDB: 21:39:37 28.02.2013: JetInit Corruption
      CatalogDB: 21:39:37 28.02.2013: catdbsvc.cpp at line #747 encountered JET error -583
      CatalogDB: 21:39:37 28.02.2013: catdbsvc.cpp at line #961 encountered JET error -583
      CatalogDB: 21:39:37 28.02.2013: catdbsvc.cpp at line #6636 encountered JET error -583
    • EventID 257: The following information was included with the event: -583 the message resource is present but the message is not found in the string/message table

It seems that all services which uses the Window Jet Database engine are affected.

Solution

Continue reading Windows Update and Windows Search do not work

Windows: Disable or enable assigning of a drive letter when plugin a removeable device

Hi,

the default setting in Windows Vista, 7 or 8 is to assign a drive letter when you plugin a removable device. But sometimes you want to prevent Windows from doing that, for example security reasons.

You can control this behaviour with the mountvol command.  The following command line disable the automatical assignment.


mountvol /N

to enable the auto assignment again execute

mountvol /E

Michael

Windows 7 & Getting drivers for obsulete printers

Hello,

yesterday a customer had the problem that he wants an old printer, a HP LaserJet 5M, to get running on 15 Windows 7 clients. Unfortunately Windows has no driver on board and the manufactorer didn’t provider anyone.

Solution:

For many old printers you can install a driver via Windows Update. Go to the Control Panel, Device & printers and add a new printer

WindowsUpdate
Add printer driver from Windows update, to get the whole drivers list from windows update may take some time.Time for a coffee.

Continue reading Windows 7 & Getting drivers for obsulete printers

Windows: Changing the power plan or a single value in a sheme

This posts descripes how to change the power plan in Windows or a single option in a sheme from the Windows command line.

First of all start a cmd command shell  with administrator rights.

To get a list of all available shemes run


c:\> powercfg /L


Existing Power Schemes (* Active)
-----------------------------------
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced) *
Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c  (High performance)
Power Scheme GUID: a1841308-3541-4fab-bc81-f71556f20b4a  (Power saver)

The most options to powercfg at the command line must be specified with the GUID. To set the “High performance” plan active determine the sheme  GUID and execute

c:\> powercfg /S 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c

Query again und you see the other plan is active

c:\> powercfg /L
Existing Power Schemes (* Active)
-----------------------------------
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)
Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c  (High performance) *
Power Scheme GUID: a1841308-3541-4fab-bc81-f71556f20b4a  (Power saver)

Let us supose we only want to modify a single option or value. For example, disable the “Allow hybrid sleep” value in sheme “Power Saver” and with AC power active. Then, you first have to query all of the content of a sheme, because we need the GUID as parameter for powercfg. The output is a long list of options, I redirect them in  a temporary file, because in the file it is easier to search for the necessary GUIDs.
Continue reading Windows: Changing the power plan or a single value in a sheme