Job failed. Object reference not set to an instance of an object
Hello:
I am trying to create a script to create a DHCP scope, the DHCP servers are in different domains, therefore it needs credentials and I use an invoke-command to authenticate and run the script, but it gives me an error
This Script
Script contents
param(
[String]$ServerName,
[String]$StartRange,
[String]$EndRange,
[String]$Gateway,
[String]$NetMask,
[PSCredential]$Credential,
[String]$LeaseDuration,
[string]$Description,
[String]$Scope,
[String]$Name
)
Invoke-Command -ComputerName $ServerName -Credential $Credential -ScriptBlock {Add-DhcpServerv4Scope -Name $using:name -LeaseDuration $using:LeaseDuration -StartRange $using:StartRange -EndRange $using:EndRange -SubnetMask $using:Netmask -State Active -Type DHCP -Verbose -Description $using:Description} -Verbose

Product: PowerShell Universal Version: 5.3.3
cf69ff2c69a54daebd775b46a808e6c6ec6f69f0.png
a7cf03c4624df1a8bef12e9385f46278cf780836.png
471d16028b88e160e03bab0fbe613537c34a8d8c.png