Function

This topic contains 1 reply, has 2 voices, and was last updated by  Joel Sallow 3 months, 4 weeks ago.

  • Author
    Posts
  • #97200

    alex olynyk
    Participant

    I want to start a Landesk remote session with powershell.

    I have a computer name parameter but i need to add https:// before the computer name and :4343 after the computer name.

    How to add this to the function?

    function Start-LDRemote {
    
         [cmdletbinding()]
    
         Param(
                 
                 [Parameter(Mandatory = $True)] 
                 [string]$computername = $env:COMPUTERNAME
    
                 )
    
    Start-Process -FilePath $computername
    
    } ; Start-LDRemote
    
  • #97205

    Joel Sallow
    Participant
    Start-Process -FilePath "https://${computername}:4343"

    In most cases, you wouldn't need the braces, but since colons are used for variable scopes, you do need them so PS doesn't think the 4343 is part of the variable itself.

    Double-quoted strings can expand variables on their own, so this should work just fine. 🙂

You must be logged in to reply to this topic.