Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

Executing script problem

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
johndarby
Asked:
johndarby
  • 2
1 Solution
 
leonstrykerCommented:
>$strComputer

Special character like $ are not allowed in variable names in VBS.
0
 
leonstrykerCommented:
Thanks for the grade,

Leon
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now