Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Invoke-Expression from global PowerShell script

    Scheduled Pinned Locked Moved Support
    powershellbuildmaster
    2 Posts 2 Posters 132 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E Offline
      evs21_7577
      last edited by

      Hi,

      I'm trying to call stored on the server powershell script from buildmaster's global powershell script using Invoke-Expression, but getting error:

      The term 'C:\Path\To\PowerShell\script.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

      I've also tried another ways to run it, such as:
      Invoke-Expression C:\Path\To\PowerShell\script.ps1
      . C:\Path\To\PowerShell\script.ps1
      & C:\Path\To\PowerShell\script.ps1
      C:\Path\To\PowerShell\script.ps1

      Each of them cause the same error.

      Could you clarify how can I call stored on disk external ps1 script from BuildMaster's powershell script?

      Product: BuildMaster
      Version: 6.0.4

      1 Reply Last reply Reply Quote 0
      • G Offline
        gurdipsira_1_1508
        last edited by

        Are you sure you're using the right server context when calling the BuildMaster Powershell Asset? If you print out the server name in your asset using $env:computername do you get back the expected server? If I create a simple plan

        ##AH:UseTextMode
        for server $MyServer
        {
            PSCall GLOBAL::Test_Powershell_Asset;
        }
        

        Where my powershell asset is defined as this one-liner

        Invoke-Expression C:\Path\To\PowerShell\script.ps1
        

        Then I am able to run this script, no problem.

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post
        Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation