I am trying to write a script that can add/edit/delete firewall rules remotely through PSSessions in an automated fashion, meaning it initializes the parameters (ip, rule name, etc) in the beginning to be used for the rule creation.
$remoteName = "clientName"
$ruleName = "testRuleName"
$tgtIp = "192.168.1.1"
$workstation = New-PSSession -Authentication Kerberos -Credential "" -ComputerName $remoteName
From it request user credentials and I enter them and successfully establish the remote machine connection and proceed to the following:
Enter-PSSession $workstation
netsh advfirewall firewall add rule name = $ruleName dir = in localip = $tgtIp action = allow
I use this method outside of the PSSession with success. However, when I enter it in the session I receive the following error.
"One or more essential parameters were not entered. Verify the required parameters, and reenter them."
I'm rather new to PSSession so any insight on what I'm doing wrong would be appreciated.