Function

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
6 months, 3 weeks ago.

  • Author
    Posts
  • #97200

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 2
    Rank: Member
    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. 🙂

The topic ‘Function’ is closed to new replies.