Remotely disable IPv6 with PowerShell

$adminUser = "DOMAIN\USERNAME"
$adminPwd = "PASSWORD"
$compName = "REMOTECOMPUTERNAME"
 
$secPwd = ConvertTo-SecureString $adminPwd -AsPlainText -Force
$remoteCreds = New-Object System.Management.Automation.PSCredential ($adminUser, $secPwd)
$ServerSession = New-PSSession -ComputerName $compName -Authentication CredSSP -Credential $remoteCreds
 
Invoke-Command -Session $ServerSession -ScriptBlock
{
    # Disable IPv6
    $regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters"
    New-ItemProperty -Path $regPath -Name "DisabledComponents" -Value "0xFFFFFFFF" -PropertyType "DWORD" | Out-Null
    Restart-Computer -ComputerName $env:computername -Force
}