Publish-Module is a cmdlet used to publish (upload) a module to a NuGet repository. Occasionally, this cmdlet raises strange exceptions. The reason in this case is an outdated version of nuget.exe. This application is responsible for packaging a module and saving it as .nupkg file, and this application is automatically downloaded the first time you use Publish-Module.
To correct this problem and refresh your version of nuget.exe, run this:
Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile "$env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe"
Make sure you close and restart all PowerShell sessions after this. If Publish-Module still refuses to work, you may have to run the command below (which requires Admin privileges):
Install-PackageProvider -Name NuGet -MinimumVersion 184.108.40.206 -Force