Windows Vista Forums

Unexpected token
  1. #1


    Ron.Disnsey Guest

    Unexpected token

    I went to the Microsoft Script Archive
    http://www.microsoft.com/technet/scr....mspx?mfr=true
    and coppied the code for "List Physical Disk Properties" to DiskProp.ps1.
    When I run it "./diskprop" I get the following error.
    ---------------
    Unexpected token '_' in expression or statement.
    At H:\PowerShell\DiskProp.ps1:2 char:44
    + Set objWMIService = GetObject("winmgmts:" _
    ---------------
    First five lines of code are
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colDiskDrives = objWMIService.ExecQuery _
    ("Select * from Win32_DiskDrive")

    What's wrong?
    Why can't I just copy the code and run it?



    Thanks,
    Ron.

      My System SpecsSystem Spec

  2. #2


    Jason Mobarak Guest

    Re: Unexpected token

    I'm not sure where the contents of DiskProp.ps1 came from but it's not
    from the web page that you cited. The code that you listed is visual
    basic, not powershell... afaik PowerShell can't run Visual Basic code.

    hth,
    -- Jason

    On Dec 14, 1:49 pm, Ron.Disnsey <Ron.Disn...@discussions.microsoft.com>
    wrote:
    > I went to the Microsoft Script Archivehttp://www.microsoft.com/technet/scriptcenter/scripts/msh/storage/dis...
    > and coppied the code for "List Physical Disk Properties" to DiskProp.ps1.
    > When I run it "./diskprop" I get the following error.
    > ---------------
    > Unexpected token '_' in expression or statement.
    > At H:\PowerShell\DiskProp.ps1:2 char:44
    > + Set objWMIService = GetObject("winmgmts:" _
    > ---------------
    > First five lines of code are
    > strComputer = "."
    > Set objWMIService = GetObject("winmgmts:" _
    > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    > Set colDiskDrives = objWMIService.ExecQuery _
    > ("Select * from Win32_DiskDrive")
    >
    > What's wrong?
    > Why can't I just copy the code and run it?
    >
    > Thanks,
    > Ron.



      My System SpecsSystem Spec

Unexpected token problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to buy a Windows Live OneCare Token if outside US? jehzlau System Security 1 29 Jun 2009
Unexpected Error: Fax Can't be received because of an unexpected e cioangel Vista print fax & scan 1 09 Jan 2009
Where to get Location ID (LID) and Delegated Authentication token (DAT) Joseph Lu Live Messenger 0 31 Oct 2008
how to get orignal token after Elevation? =?Utf-8?B?ZGlzcGFseSBuYW1l?= Vista security 2 25 Jul 2006
STS (Security Token Service) using TCP transport Cooly Martziano Indigo 0 29 Mar 2006