Solved

Executing script problem

Posted on 2006-06-12
2
373 Views
Last Modified: 2013-12-25
I have a script which I placed in a file named ADinfo.vbs. When I goto the command line (cmd or powershell) and execute the script, I get an error. Here is what I type:    cscript adinfo.vbs

Can you help me understand how to execute this properly?

The error returned is:   C:\adinfo.vbs(1, 1) Microsoft VBScript compilation error: Invalid character

Here is the script:

$strComputer = "."

$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
0
Comment
Question by:johndarby
  • 2
2 Comments
 
LVL 29

Accepted Solution

by:
leonstryker earned 500 total points
ID: 16890120
>$strComputer

Special character like $ are not allowed in variable names in VBS.
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 16923320
Thanks for the grade,

Leon
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now