Problem: WMI StdRegProv Class can return junk characters when using the GetStringValue on windows 2003/XP/Vista and Windows 2008

Under a specific set of conditions, the StdRegProv GetStringValue method will return  a string of data from a random memory location.   The string value must have been created and valid data written into the key name.  Once the key name is cleared to a zero length, all subsequent reads will return the invalid data. To…

0

How to specify TimeOut for ldap bind in .Net

A few days ago, I was working with a .Net developer who was building a Directory Server (Active Directory) enabled application using the popular System.DirectoryService namespace. He was looking for some help to terminate the LDAP bind within a specified time in case there is some issue with connectivity. His test code was very was…

0

ChangePassword() and Password Complexity Violation Error Codes

This blog post attempts to describe why ChangePassword method of ADSI/System.DirectoryServices throws different error codes for same password string that violates domain password policies. If you are a seasoned ADSI developer You may have noticed ChangePassword throws two different error codes when the new password violates the Password policy. One error code is                ERROR_DS_CONSTRAINT_VIOLATION…

0

Using Powershell cmdLet “Compare-Object” to compare WMI objects

Recently I came across a scenario where one of the developers wanted to automate to produce a list of Products that are not installed on a box, compared to a reference server. He was looking for a  powershell solution for the same. If you are familiar with WMI, you may obviously want to explore the…

0

How to get the Terminal Service Account settings and Client Settings from the Terminal Server

You can use Win32_TSAccount And Win32_TSClientSetting WMI class to get the information but these classes returns some information in bit-wise operator and that needs to be convert in simple terms which are easily understandable to the user. Most of such scripts are used by the administrators in big organization and its really tough for them…

1

NetShareGetInfo in C# to read Share Permissions of a File System Object

NetShareGetInfo is a C++ API to read the information of a shared resource (File System Object – FSO). This blog shows how to use this API in C# to read Share Permissions of a shared FSO. For more information on NetShareGetinfo, please go through the below link http://msdn.microsoft.com/en-us/library/windows/desktop/bb525388(v=vs.85).aspx I was working with WMI class Win32_Share…

0

Reading all WINS IP addresses on a computer using Windows Scripting Host ( VBScript )

I recently worked with a developer who was working on a VBScript to enumerate all Windows Internet Name Service (WINS) IP addresses of a computer using the Win32_NetworkAdapterConfiguration WMI class. The developer was only able to enumerate the first two WINS IP addresses of a computer. The Win32_NetworkAdapterConfiguration class uses two properties to read WINS…

1

WScript.Quit( Value ) does not always match the error code environment variable %errorlevel% in the command processor ( batch file processing ) environment.

In the windows scripting host environment, the WScript.Quit method can be used to return an exit code to a calling process. In 99.9% of the cases, the value set with the WSCript.Quit method will be returned as expected. If you are running your script code in a command window, the value usually comes back in…

1

Using PowerShell History ( Part 2 )

In my last blog, I talked about how you can increase the history buffer limit. This is very helpful if you ever want to save the commands that you may have been working on to later incorporate into your script library. I would normally save the history to a file by using the Get-History cmdlet…


Using PowerShell History ( Part 1 )

I like trying to figure out how things work and most of the time, it is via trial and error. Then I experiment to test my understanding and discovery a few new tricks along the way. Most of the time, this discovery happens while I am in the Windows PowerShell Console. One of the things…