Running powershell via exchange 2007


  1.    07 Nov 2007 #1
    maquinaloca Guest

    Running powershell via exchange 2007


    I am trying to run a powershell script and I get the following error.

    [MSH] C:\Documents and Settings\admin>ls


    Directory: Microsoft.Msh.Core\FileSystem::C:\Documents and Settings\admi
    n


    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    -a--- 2/27/2006 10:35 PM 0 Sti_Trace.log
    -a--- 11/6/2007 2:10 PM 453 test.ps1
    d---- 2/27/2006 10:33 PM Desktop
    d-r-- 3/16/2006 2:11 AM Favorites
    d-r-- 3/21/2006 2:59 AM My Documents
    d-r-- 2/27/2006 10:33 PM Start Menu


    [MSH] C:\Documents and Settings\admin>$pwd\test.ps1
    Unexpected token '\test.ps1' in expression or statement.
    At line:1 char:13
    + $pwd\test.ps1 <<<<


    Can anyone tell me why this is not working.
      My System SpecsSystem Spec

  2.    07 Nov 2007 #2
    Marco Shaw [MVP] Guest

    Re: Running powershell via exchange 2007



    > [MSH] C:\Documents and Settings\admin>$pwd\test.ps1
    > Unexpected token '\test.ps1' in expression or statement.
    > At line:1 char:13
    > + $pwd\test.ps1 <<<<
    >
    >
    > Can anyone tell me why this is not working.
    PowerShell is not dealing with the backslash properly. Run it like this:

    PSH> & "$pwd\test.ps1"

    Marco

    --
    Microsoft MVP - Windows PowerShell
    http://www.microsoft.com/mvp

    PowerGadgets MVP
    http://www.powergadgets.com/mvp

    Blog:
    http://marcoshaw.blogspot.com
      My System SpecsSystem Spec

  3.    07 Nov 2007 #3
    Kiron Guest

    Re: Running powershell via exchange 2007


    You can use the call operator '&' or '.\'

    & $pwd\test.ps1
    .\test.ps1

    # the dot before the slash represents the current location

    --
    Kiron
      My System SpecsSystem Spec

  4.    07 Nov 2007 #4
    maquinaloca Guest

    Re: Running powershell via exchange 2007


    I tried the following with no luck

    [MSH] C:\Documents and Settings\admin>& "$pwd\test.ps1"
    Program 'test.ps1' failed to execute: No application is associated with the
    spe
    cified file for this operation
    At line:1 char:2
    + & <<<< "$pwd\test.ps1".
    At line:1 char:1
    + & <<<< "$pwd\test.ps1"
    [MSH] C:\Documents and Settings\admin>& $pwd\test.ps1
    Program 'test.ps1' failed to execute: No application is associated with the
    spe
    cified file for this operation
    At line:1 char:2
    + & <<<< $pwd\test.ps1.
    At line:1 char:1
    + & <<<< $pwd\test.ps1
    [MSH] C:\Documents and Settings\admin>.\test.ps1
    Program 'test.ps1' failed to execute: No application is associated with the
    spe
    cified file for this operation
    At line:1 char:10
    + .\test.ps1 <<<< .
    At line:1 char:1
    + . <<<< \test.ps1

    "Marco Shaw [MVP]" wrote:

    >

    > > [MSH] C:\Documents and Settings\admin>$pwd\test.ps1
    > > Unexpected token '\test.ps1' in expression or statement.
    > > At line:1 char:13
    > > + $pwd\test.ps1 <<<<
    > >
    > >
    > > Can anyone tell me why this is not working.
    >
    > PowerShell is not dealing with the backslash properly. Run it like this:
    >
    > PSH> & "$pwd\test.ps1"
    >
    > Marco
    >
    > --
    > Microsoft MVP - Windows PowerShell
    > http://www.microsoft.com/mvp
    >
    > PowerGadgets MVP
    > http://www.powergadgets.com/mvp
    >
    > Blog:
    > http://marcoshaw.blogspot.com
    >
      My System SpecsSystem Spec

  5.    07 Nov 2007 #5
    Brandon Shell [MVP] Guest

    Re: Running powershell via exchange 2007


    Are you using Powershell V1? The [MSH] implies you are using a beta/RC product.

    You can use Get-Host to get this.

    Brandon Shell
    ---------------
    Blog: http://www.bsonposh.com/
    PSH Scripts Project: www.codeplex.com/psobject

    m> I am trying to run a powershell script and I get the following error.
    m>
    m> [MSH] C:\Documents and Settings\admin>ls
    m>
    m> Directory: Microsoft.Msh.Core\FileSystem::C:\Documents and
    m> Settings\admi
    m> n
    m> Mode LastWriteTime Length Name
    m> ---- ------------- ------ ----
    m> -a--- 2/27/2006 10:35 PM 0 Sti_Trace.log
    m> -a--- 11/6/2007 2:10 PM 453 test.ps1
    m> d---- 2/27/2006 10:33 PM Desktop
    m> d-r-- 3/16/2006 2:11 AM Favorites
    m> d-r-- 3/21/2006 2:59 AM My Documents
    m> d-r-- 2/27/2006 10:33 PM Start Menu
    m> [MSH] C:\Documents and Settings\admin>$pwd\test.ps1
    m> Unexpected token '\test.ps1' in expression or statement.
    m> At line:1 char:13
    m> + $pwd\test.ps1 <<<<
    m> Can anyone tell me why this is not working.
    m>


      My System SpecsSystem Spec

  6.    07 Nov 2007 #6
    maquinaloca Guest

    Re: Running powershell via exchange 2007


    you are right, I notice afterwards. I change file to .msh and now all is
    working.

    "Brandon Shell [MVP]" wrote:

    > Are you using Powershell V1? The [MSH] implies you are using a beta/RC product.
    >
    > You can use Get-Host to get this.
    >
    > Brandon Shell
    > ---------------
    > Blog: http://www.bsonposh.com/
    > PSH Scripts Project: www.codeplex.com/psobject
    >
    > m> I am trying to run a powershell script and I get the following error.
    > m>
    > m> [MSH] C:\Documents and Settings\admin>ls
    > m>
    > m> Directory: Microsoft.Msh.Core\FileSystem::C:\Documents and
    > m> Settings\admi
    > m> n
    > m> Mode LastWriteTime Length Name
    > m> ---- ------------- ------ ----
    > m> -a--- 2/27/2006 10:35 PM 0 Sti_Trace.log
    > m> -a--- 11/6/2007 2:10 PM 453 test.ps1
    > m> d---- 2/27/2006 10:33 PM Desktop
    > m> d-r-- 3/16/2006 2:11 AM Favorites
    > m> d-r-- 3/21/2006 2:59 AM My Documents
    > m> d-r-- 2/27/2006 10:33 PM Start Menu
    > m> [MSH] C:\Documents and Settings\admin>$pwd\test.ps1
    > m> Unexpected token '\test.ps1' in expression or statement.
    > m> At line:1 char:13
    > m> + $pwd\test.ps1 <<<<
    > m> Can anyone tell me why this is not working.
    > m>
    >
    >
    >
      My System SpecsSystem Spec

  7.    07 Nov 2007 #7
    Brandon Shell [MVP] Guest

    Re: Running powershell via exchange 2007


    I would upgrade if I were you
    Brandon Shell
    ---------------
    Blog: http://www.bsonposh.com/
    PSH Scripts Project: www.codeplex.com/psobject

    m> you are right, I notice afterwards. I change file to .msh and now all
    m> is working.
    m>
    m> "Brandon Shell [MVP]" wrote:
    m>

    >> Are you using Powershell V1? The [MSH] implies you are using a
    >> beta/RC product.
    >>
    >> You can use Get-Host to get this.
    >>
    >> Brandon Shell
    >> ---------------
    >> Blog: http://www.bsonposh.com/
    >> PSH Scripts Project: www.codeplex.com/psobject
    >> m> I am trying to run a powershell script and I get the following
    >> error.
    >> m>
    >> m> [MSH] C:\Documents and Settings\admin>ls
    >> m>
    >> m> Directory: Microsoft.Msh.Core\FileSystem::C:\Documents and
    >> m> Settings\admi
    >> m> n
    >> m> Mode LastWriteTime Length Name
    >> m> ---- ------------- ------ ----
    >> m> -a--- 2/27/2006 10:35 PM 0 Sti_Trace.log
    >> m> -a--- 11/6/2007 2:10 PM 453 test.ps1
    >> m> d---- 2/27/2006 10:33 PM Desktop
    >> m> d-r-- 3/16/2006 2:11 AM Favorites
    >> m> d-r-- 3/21/2006 2:59 AM My Documents
    >> m> d-r-- 2/27/2006 10:33 PM Start Menu
    >> m> [MSH] C:\Documents and Settings\admin>$pwd\test.ps1
    >> m> Unexpected token '\test.ps1' in expression or statement.
    >> m> At line:1 char:13
    >> m> + $pwd\test.ps1 <<<<
    >> m> Can anyone tell me why this is not working.
    >> m>

      My System SpecsSystem Spec

Running powershell via exchange 2007

Similar Threads
Thread Forum
Running exchange powershell command from vbscript
Hi! :) I need to run one powershell command from vbscript. I have no problem running a command like Get-Command but what I need to run is an...
VB Script
Running exchange powershell command from vbscript
Hi! :) I need to run one powershell command from vbscript. I have no problem running a command like Get-Command but what I need to run is an...
PowerShell
Powershell WinRM Exchange and ILM 2007
Hi all, I find I am in need of advice. I need to run either: 1) Powershell V2 CTP3 + WinRM 2.0 + Exchange 2007 Management Shell or 2)...
PowerShell
Exchange 2007 and PowerShell
I tried an MS virtual labcast online to see quickly how Exch 2007 looks (failed to get the VHD to activate). I quickly tried to create a new...
PowerShell
Running scripts from powershell on exchange server
Hi u all, When I try to run script (filename.ps1) from monad only on the exchange server, i get the following message: "program scriptname.ps1...
PowerShell
Exchange 2007 PowerShell..
Hopefully someone here is familiar with the Exchange 2k7 PowerShell.. I'm trying to export to CSV the LastName/FirstName of all users...
PowerShell
Monad / PowerShell / Exchange 2007
Monad / PowerShell / Exchange 2007 In Exchange 2007 beta, if I replace Monad with PowerShell, then the Exchange specific commands don't appear to...
PowerShell

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 10:01.
    .