Search code examples
azurepowershellazure-automation

Invoke-AzVMRunCommand does not return the expected value when running Get-NetFirewallProfile


I am trying to use the Invoke-AzVMRunCommand on a VM in my Azure subscription.

My powershell looks like this

Invoke-AzVMRunCommand -VMName $vm.Name -ResourceGroupName $vm.ResourceGroupName -CommandId 'RunPowerShellScript' -ScriptPath $scriptPath

With the script in my $scriptPath looking like this

Get-NetFirewallProfile | ConvertTo-Csv

When running this however, the response seems to tell me that the windows firewall is enabled, even though I know for a fact it is not.

The ConvertTo-Csv is required for other parts of my script to function as needed, as Invoke-AzVMRunCommand returns a string object, which isn't too useful. Even without this however I still don't get the correct response

Does anybody know of any reason as to why this might be?


Solution

  • So the commands I was running check different areas of the registry from the GUI.

    GUI:

    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall\DomainProfile
    

    CMDLETS:

    HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile
    

    This is where the issue came from.

    If you have this issue, but sure to check both registry entries.