Pass parameters to script

Welcome Forums General PowerShell Q&A Pass parameters to script

Viewing 1 reply thread
  • Author
    Posts
    • #210975
      Participant
      Topics: 1
      Replies: 0
      Points: 13
      Rank: Member

      Hello everyone,

      I got 2 scripts, from the 1rst one I define some parameters and then I try to send then to the second one.

      Script one :

      $ToUpDate = “computer name”
      $updateCategory = “Critical Updates”, “Definition Updates”, “Security Updates”

      powershell “\\someServerName\INFRA\WindowsUpdate\install-windowsupdates.ps1” -Computer $ToUpDate -Updatetype $updateCategory

       

      Script two : Start with the following :

      [CmdletBinding()]

      Param(
      [parameter(Mandatory=$true,Position=1)]
      [string[]]$computer,

      [parameter(Mandatory=$true,Position=2)]
      [string[]]$Updatetype
      )

       

      I don’t know how to resolve this.

      Does some of you have a hint about it.

      Thank you very much

      Best regards

      Adrien

    • #210978
      Participant
      Topics: 4
      Replies: 2247
      Points: 5,484
      Helping Hand
      Rank: Community MVP

      You should omit the “Powershell” in your command line you use in your 1st script. You are already running a Powershell console. 😉

      When you post code or sample data or console output you should format it as code using the code tags “PRE“. Read Me Before Posting! You’ll be Glad You Did!

      Thanks

Viewing 1 reply thread
  • You must be logged in to reply to this topic.