Solved

Executing script problem

Posted on 2006-06-12
2
374 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

864 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

21 Experts available now in Live!

Get 1:1 Help Now