Do you have a scripting-related question or problem? You can send your question or problem to firstname.lastname@example.org.
I want to check a computer account's PasswordAge value so that I can determine whether a given computer account is for a machine that is no longer on the network. When I was reviewing the code in Listing 3 of the March 2000 Rem column, I realized that I could use VBScript and Active Directory Service Interfaces (ADSI) to check for the Password-Age value. In that listing, the code
Set oComputerAccount = _ GetObject("WinNT://" _ & "Olympus/Hercules$,User")
implies that I can bring up a computer account and access it as I would a user account. However, when I run the code
Set oComputerAccount = _ GetObject _ ("WinNT://IMSG/Dragon$,User") oComputerAccount.GetInfo
I get the error message Error Number: 0x80070534. C:\pwage.vbs(2, 1) No mapping between account names and security IDs was done. Do you know what the problem might be?
You can access a computer account's properties much like you can access a user account's properties. However, the IADs::GetInfo method fails when the target object is a computer account. To work around this problem, you need to use the IADs::Get method on the target property (PasswordAge, in this case). Get makes an implicit call to GetInfo because the object's local cache isn't initialized.
The script PWAge.vbs in Listing 1 demonstrates this workaround. As callout A in Listing 1 shows, the script uses Get in lieu of GetInfo. Using the IADsPropertyList::PropertyCount property both before and after Get lets you easily examine Get's effect on the local property cache. The output in Figure 1 shows that Get implicitly calls GetInfo when the local property cache is uninitialized. After the local property cache is initialized, subsequent calls to Get retrieve values from the local cache. The remaining code in PWAge.vbs translates the number of seconds representing the PasswordAge into a more readable representation.
How can I convert a large directory structure of batch (.bat) logon scripts to VBScript (.vbs) files for use with Windows Script Host (WSH)?
I'm not aware of any tool that automatically translates .bat files to .vbs files. You'll have to rely on old-fashioned knowledge combined with a touch of elbow grease to accomplish the task. However, you can reduce the amount of work in the .bat -to-.vbs conversion if you understand the different mechanisms that these file types use. Table 1 identifies several common logon script tasks followed by the typical batch file and WSH solutions. By no means is this table an exhaustive list, but it points you in the right direction.