Windows Vista Forums

Running scripts
  1. #1


    Marco Guest

    Running scripts

    Sorry, I am new in Powershell. I have tried to run scripts but I get the
    error message:

    The term 'directorylistwitharguments.ps1' is not recognized as a cmdlet,
    function, operable program, or script file. Verify the term and try again.

    I have changed the execution policy:
    Set-ExecutionPolicy unrestricted

    Although, I get the same error message.



    Any help will be appreciated.

    M.


      My System SpecsSystem Spec

  2. #2


    hecks@hotmail.co.uk Guest

    Re: Running scripts

    On Jul 14, 9:08 am, Marco <Ma...@discussions.microsoft.com> wrote:
    > Sorry, I am new in Powershell. I have tried to run scripts but I get the
    > error message:
    >
    > The term 'directorylistwitharguments.ps1' is not recognized as a cmdlet,
    > function, operable program, or script file. Verify the term and try again.
    >
    > I have changed the execution policy:
    > Set-ExecutionPolicy unrestricted
    >
    > Although, I get the same error message.
    >
    > Any help will be appreciated.
    >
    > M.


    A few options here (after you've checked that the script is named
    properly, of course!):

    1. If you've already navigated to your script directory, use:

    ..\directorylistwitharguments.ps1

    2. Otherwise use the full pathname:

    & "C:\Scripts\directorylistwitharguments.ps1"

    3. Or for convenience, add your scripts directory to the $envath
    like so:

    $envath += ";C:\Scripts"

    Very handy to add that line to your $profile, then you can just call
    the script from the command line with its name only:

    directorylistwitharguments

    4. That's a long name! Maybe use an alias instead? Like so:

    new-alias -name dirwa -value "C:\Scripts
    \directorylistwitharguments.ps1"

    Again, this can be added to your $profile for maximum convenience.

    -Hecks


      My System SpecsSystem Spec

  3. #3


    RichS Guest

    Re: Running scripts

    By default PowerShell does not put the current directory on the path so it
    can't find it when you just type the name

    as stated use

    ..\directorylistwitharguments.ps1

    to run from the current directory

    use

    .. .\directorylistwitharguments.ps1

    to run and leave variables in memory (dot sourcing)


    --
    Richard Siddaway
    Please note that all scripts are supplied "as is" and with no warranty
    Blog: http://richardsiddaway.spaces.live.com/
    PowerShell User Group: http://www.get-psuguk.org.uk


    "hecks@hotmail.co.uk" wrote:

    > On Jul 14, 9:08 am, Marco <Ma...@discussions.microsoft.com> wrote:
    > > Sorry, I am new in Powershell. I have tried to run scripts but I get the
    > > error message:
    > >
    > > The term 'directorylistwitharguments.ps1' is not recognized as a cmdlet,
    > > function, operable program, or script file. Verify the term and try again.
    > >
    > > I have changed the execution policy:
    > > Set-ExecutionPolicy unrestricted
    > >
    > > Although, I get the same error message.
    > >
    > > Any help will be appreciated.
    > >
    > > M.

    >
    > A few options here (after you've checked that the script is named
    > properly, of course!):
    >
    > 1. If you've already navigated to your script directory, use:
    >
    > ..\directorylistwitharguments.ps1
    >
    > 2. Otherwise use the full pathname:
    >
    > & "C:\Scripts\directorylistwitharguments.ps1"
    >
    > 3. Or for convenience, add your scripts directory to the $envath
    > like so:
    >
    > $envath += ";C:\Scripts"
    >
    > Very handy to add that line to your $profile, then you can just call
    > the script from the command line with its name only:
    >
    > directorylistwitharguments
    >
    > 4. That's a long name! Maybe use an alias instead? Like so:
    >
    > new-alias -name dirwa -value "C:\Scripts
    > \directorylistwitharguments.ps1"
    >
    > Again, this can be added to your $profile for maximum convenience.
    >
    > -Hecks
    >
    >


      My System SpecsSystem Spec

  4. #4


    Rob Campbell Guest

    Re: Running scripts

    Dot sourcing is a handy debugging tool, but be mindful of uninitialized
    variables if you run the same script more than once in the same session.
    IMHO, DAMHIKT.



    "RichS" wrote:

    > By default PowerShell does not put the current directory on the path so it
    > can't find it when you just type the name
    >
    > as stated use
    >
    > .\directorylistwitharguments.ps1
    >
    > to run from the current directory
    >
    > use
    >
    > . .\directorylistwitharguments.ps1
    >
    > to run and leave variables in memory (dot sourcing)
    >
    >
    > --
    > Richard Siddaway
    > Please note that all scripts are supplied "as is" and with no warranty
    > Blog: http://richardsiddaway.spaces.live.com/
    > PowerShell User Group: http://www.get-psuguk.org.uk
    >
    >
    > "hecks@hotmail.co.uk" wrote:
    >
    > > On Jul 14, 9:08 am, Marco <Ma...@discussions.microsoft.com> wrote:
    > > > Sorry, I am new in Powershell. I have tried to run scripts but I get the
    > > > error message:
    > > >
    > > > The term 'directorylistwitharguments.ps1' is not recognized as a cmdlet,
    > > > function, operable program, or script file. Verify the term and try again.
    > > >
    > > > I have changed the execution policy:
    > > > Set-ExecutionPolicy unrestricted
    > > >
    > > > Although, I get the same error message.
    > > >
    > > > Any help will be appreciated.
    > > >
    > > > M.

    > >
    > > A few options here (after you've checked that the script is named
    > > properly, of course!):
    > >
    > > 1. If you've already navigated to your script directory, use:
    > >
    > > ..\directorylistwitharguments.ps1
    > >
    > > 2. Otherwise use the full pathname:
    > >
    > > & "C:\Scripts\directorylistwitharguments.ps1"
    > >
    > > 3. Or for convenience, add your scripts directory to the $envath
    > > like so:
    > >
    > > $envath += ";C:\Scripts"
    > >
    > > Very handy to add that line to your $profile, then you can just call
    > > the script from the command line with its name only:
    > >
    > > directorylistwitharguments
    > >
    > > 4. That's a long name! Maybe use an alias instead? Like so:
    > >
    > > new-alias -name dirwa -value "C:\Scripts
    > > \directorylistwitharguments.ps1"
    > >
    > > Again, this can be added to your $profile for maximum convenience.
    > >
    > > -Hecks
    > >
    > >


      My System SpecsSystem Spec

Running scripts problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
running ASP scripts on Vista goluhaque Software 0 05 Sep 2009
running scripts j lunis Vista General 4 31 Jul 2008
Running scripts? Bev Vista mail 1 17 Aug 2007
Running Scripts Bev Vista mail 0 15 Aug 2007
Running remote scripts =?Utf-8?B?QmVuUA==?= PowerShell 1 01 Oct 2006