Windows Vista Forums

Invoke a script

  1. #1


    Dan Guest

    Invoke a script

    I have just installed Powershell on a Win2003 sp2 server.
    When I want to invoke a script in the PowerShell console I get the error
    message: "the term 'test.ps1' in not recognised as a cmdlet, …".

    What should I do and where should I look for similar problems in the future.
    I have three PowerShell books but I couldn't find this topic in any of them.



    Thank you very much.

      My System SpecsSystem Spec

  2. #2


    Shay Levi Guest

    Re: Invoke a script

    If youre console current directory shows c:\scripts then you can type
    PS c:\scripts> .\script.ps1

    If you want to invoke a script from another directory try
    PS c:\scripts> & d:\temp\script.ps1


    Shay
    http://scriptolog.blogspot.com



    > I have just installed Powershell on a Win2003 sp2 server.
    > When I want to invoke a script in the PowerShell console I get the
    > error
    > message: "the term 'test.ps1' in not recognised as a cmdlet, …".
    > What should I do and where should I look for similar problems in the
    > future.
    > I have three PowerShell books but I couldn't find this topic in any
    > of them.
    > Thank you very much.
    >




      My System SpecsSystem Spec

  3. #3


    Dan Guest

    Re: Invoke a script

    Thank you very much Shay, it works

    I wonder why on Vista it works without .\

    Thanks again, Dan

    "Shay Levi" wrote:

    > If youre console current directory shows c:\scripts then you can type
    > PS c:\scripts> .\script.ps1
    >
    > If you want to invoke a script from another directory try
    > PS c:\scripts> & d:\temp\script.ps1
    >
    >
    > Shay
    > http://scriptolog.blogspot.com
    >
    >
    >
    > > I have just installed Powershell on a Win2003 sp2 server.
    > > When I want to invoke a script in the PowerShell console I get the
    > > error
    > > message: "the term 'test.ps1' in not recognised as a cmdlet, …".
    > > What should I do and where should I look for similar problems in the
    > > future.
    > > I have three PowerShell books but I couldn't find this topic in any
    > > of them.
    > > Thank you very much.
    > >

    >
    >
    >


      My System SpecsSystem Spec

  4. #4


    Jacques Barathon [MS] Guest

    Re: Invoke a script

    "Dan" <dan@discussions.microsoft.com> wrote in message
    news:71806669-E036-4172-83E8-C4AF6C3EA24F@microsoft.com...
    > Thank you very much Shay, it works
    >
    > I wonder why on Vista it works without .\


    Either your current directory happens to be in your PATH, or you added << .
    >> to your PATH which automatically looks for executables in whatever

    current directory you are in (not recommended for safety reasons). You can
    verify that by typing:

    PS> $envath

    Hope that helps,
    Jacques


      My System SpecsSystem Spec

  5. #5


    Thomas Lee Guest

    Re: Invoke a script

    In message <71806669-E036-4172-83E8-C4AF6C3EA24F@microsoft.com>, Dan
    <dan@discussions.microsoft.com> writes
    >I wonder why on Vista it works without .\


    Powershell should work the same on Vista.

    --
    Thomas Lee
    doctordns@gmail.com
    MVP - Admin Frameworks and Security

      My System SpecsSystem Spec

  6. #6


    dreeschkind Guest

    RE: Invoke a script

    "Dan" wrote:

    > where should I look for similar problems in the future.


    The PowerShell newsgroup (you already found it) is a good place to ask
    questions like this. ;-) Also don't forget that you can search through
    the newsgroup using google groups (many common questions have been answered
    before):
    http://groups.google.com/group/micro...topics?lnk=srg

    > I have three PowerShell books but I couldn't find this topic in any of them.


    Strange. May I ask which books you are refering to?
    I can recommend Bruce Payette's book "Windows PowerShell in Action" (ISBN
    1-932394-90-7). I'm quite sure this topic is also covered in his book.

    --
    greetings
    dreeschkind

      My System SpecsSystem Spec

  7. #7


    Desmond Lee Guest

    RE: Invoke a script

    The behavior you described is a default security feature in PowerShell and
    should work the same across the board (tested on Windows XP, 2003 and 2008)
    i.e.

    C:\>.\Myscript.ps1

    C:\>D:\folder\Myscript.ps1

    HTH.

    --
    ............... All new, all fresh ..............
    http://www.leedesmond.com/weblog/



    "Dan" wrote:

    > I have just installed Powershell on a Win2003 sp2 server.
    > When I want to invoke a script in the PowerShell console I get the error
    > message: "the term 'test.ps1' in not recognised as a cmdlet, …".
    >
    > What should I do and where should I look for similar problems in the future.
    > I have three PowerShell books but I couldn't find this topic in any of them.
    >
    > Thank you very much.


      My System SpecsSystem Spec

Invoke a script

Similar Threads
Thread Thread Starter Forum Replies Last Post
Invoke PowerShell Script from Batch File Frederick R. Hutchings PowerShell 7 26 Feb 2010
How to invoke PowerShell ISE from C# code on a specific script britman PowerShell 3 12 Jan 2010
Invoke script on disk attached wormscoffer PowerShell 1 13 Mar 2009
Invoke string UNSO PowerShell 2 01 Dec 2008
Demo Invoke-MsTsClient script Alex K. Angelopoulos [MVP] PowerShell 2 13 Sep 2006