Hi,
I am trying to add about 500 mac address to a policy,for now all I want to do is create the policy with the list of MAc address and disable it, so it is ready for use later. In fact I want to create a number of policies but don't yet have ip ranges or options defined.
So i tried the following script
param(
[parameter(Mandatory=$true)]
[string]
$InputFileName
)
$filename = $InputFileName
$maclist = @()
$operator = "EQ"
$condition = "OR"
# Attempt to read the entire list of MAC-addresses into an array.
# Finally, The array $maclist would look like the following for an allow list -
# @("EQ", "mac-address1", "EQ", "mac-address2", "EQ", "mac-address3" ..)
foreach ($mac in $filecontent)
{
$maclist += $operator
if($mac -ne "")
{
$maclist += $mac
}
}
try
{
Add-DhcpServerv4Policy -Name "laptops" -Description "laptop-mac" -ScopeId "10.1.1.1" -Condition $condition -MacAddress $maclist -ErrorAction Stop
}
catch{throw}
Exit
which should ask me for the input file which is a list of MAc address and create the policy for me.
How ever I get an error
Add-DhcpServerv4Policy : Please specify at least one of the optional parameters: VendorClass, UserClass, MacAddress, ClientId, RelayAgent, CircuitId, RemoteId, SubscriberId.
At C:\temp\add policy.ps1:35 char:5
+ Add-DhcpServerv4Policy -Name "laptops" -Description "laptop-mac" -ScopeId "1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (PS_DhcpServerv4Policy:root/Microsoft/...pServerv4Policy) [Add-DhcpServerv4Policy], CimException
+ FullyQualifiedErrorId : WIN32 87,Add-DhcpServerv4Policy
any help in getting this to work would be greatly appreciated.
Cheers