# Error in PS Script while adding parameters

**URL:** <https://forums.powershell.org/t/error-in-ps-script-while-adding-parameters/11667>\
**Category:** PowerShell Help\
**Created:** [November 14, 2018, 3:31am UTC](https://forums.powershell.org/t/error-in-ps-script-while-adding-parameters/11667 "2018-11-14T03:31:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nagasai2904](https://avatars.discourse-cdn.com/v4/letter/n/9e8a1a/32.png) [@nagasai2904](https://forums.powershell.org/u/nagasai2904)\
**Post date:** [November 14, 2018, 3:31am UTC](https://forums.powershell.org/t/error-in-ps-script-while-adding-parameters/11667/1 "2018-11-14T03:31:17Z")

</div>

Hello,

Getting started with PS scripting and putting together few scripts that helps in my day to day work. I am receiving the below error when I try and pass few parameters in the below script. The details are as below. What am I doing wrong ?

Script I am running is below.

Param (  
[Parameter(Mandatory=$True)]  
[string]$Name,

[Parameter(Mandatory=$True)]  
[string]$Description)

New-CMAntimalwarePolicy -Name -Policy ExclusionSettings -Description -Verbose

It asks me to enter Name and Description just fine but when I hit enter again I get the below error.

New-CMAntimalwarePolicy : Missing an argument for parameter ‘Name’. Specify a parameter of type ‘System.String’ and  
try again.  
At line:9 char:25

- New-CMAntimalwarePolicy -Name -Policy ExclusionSettings -Description …
- 

```
                    ~~~~~

```

- CategoryInfo : InvalidArgument: (🙂 [New-CMAntimalwarePolicy], ParameterBindingException
- FullyQualifiedErrorId : MissingArgument,Microsoft.ConfigurationManagement.Cmdlets.EP.Commands.NewAntimalwarePoli  
cyCommand

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [November 14, 2018, 3:35am UTC](https://forums.powershell.org/t/error-in-ps-script-while-adding-parameters/11667/2 "2018-11-14T03:35:03Z")

</div>

So, the first problem here is that you’re apparently setting parameters, but never using the variables that you create.

When you are calling a function or script with arguments, you need to specify the value that you pass - so, “-Name” should be “-Name $Name” (using the parameter you created). It doesn’t get automatically passed down!

[pre]param(  
[Parameter(Mandatory=$true)]  
[string]$Name,

```
[Parameter(Mandatory=$true)]
[string]$Description

```

)

New-CMAntimalwarePolicy -Name $Name -Policy ‘ExclusionSettings’ -Description $Description -Verbose[/pre]

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/error-in-ps-script-while-adding-parameters/11667/3 "2024-05-16T20:33:43Z")

</div>


