Run PowerShell command from command prompt (no ps1 script)

前端 未结 4 1547
花落未央
花落未央 2020-12-12 22:17

I\'m looking for a way to run just a couple PowerShell commands from the command prompt. I don\'t want to create a script for this since it\'s just a couple commands I need

4条回答
  •  一向
    一向 (楼主)
    2020-12-12 22:54

    This works from my Windows 10's cmd.exe prompt

    powershell -ExecutionPolicy Bypass -Command "Import-Module C:\Users\william\ps1\TravelBook; Get-TravelBook Hawaii"
    

    This example shows

    1. how to chain multiple commands
    2. how to import module with module path
    3. how to run a function defined in the module
    4. No need for those fancy "&".

提交回复
热议问题