Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot validate argument on parameter 'WslInstanceName' #27

Closed
hatakawas opened this issue Jun 24, 2022 · 10 comments
Closed

Cannot validate argument on parameter 'WslInstanceName' #27

hatakawas opened this issue Jun 24, 2022 · 10 comments

Comments

@hatakawas
Copy link

When I follow the Module Activation section in README to activate in static mode, I got this error.
My command:

Install-WslIpHandler -WslInstanceName Ubuntu-20.04 -GatewayIpAddress 172.16.0.1

And the output:

Install-WslIpHandler: Cannot validate argument on parameter 'WslInstanceName'. Valid values generator return a null value.

image

Would you mind help me out there?
Thanks!

@wikiped
Copy link
Owner

wikiped commented Jun 24, 2022

This seems to be a duplicate of #25.

Could you please update to the latest version and try again?

@hatakawas
Copy link
Author

As you see, I just reinstalled it minutes ago, and error kept there.
Just check my actions and the output:

PS C:\Users> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2
PS C:\Users> [Console]::InputEncoding, [Console]::OutputEncoding | select -Exp EncodingName
Chinese Simplified (GB2312)
Chinese Simplified (GB2312)
PS C:\Users> wsl.exe --status
默认分发:Ubuntu-20.04
默认版本:2

适用于 Linux 的 Windows 子系统最后更新于 2022/6/16
WSL 自动更新启用。
Windows 更新已暂停。

内核版本: 5.10.16
PS C:\Users> ipmo Wsl-IpHandler -Force
PS C:\Users> . (join-path (split-path (gmo Wsl-IpHandler).Path) 'Scripts/Powershell/FunctionsArgumentCompleters.ps1')
PS C:\Users> wsl.exe -l | Convert-CommandOutput -SourceEncoding 'ibm850'
�?u?N Linux ?v Windows P[1|?~�RDSHr:


Ubuntu-20.04 (?×??)



PS C:\Users> wsl.exe -l | Convert-CommandOutput -DestinationEncoding 'ibm850'
?? Linux ???????? ?????:
Ubuntu-20.04 (?)
PS C:\Users> Install-WslIpHandler -WslInstanceName Ubuntu-20.04 -GatewayIpAddress 172.16.0.1
Install-WslIpHandler: Cannot validate argument on parameter 'WslInstanceName'. Valid values generator return a null value.
PS C:\Users> Install-WslIpHandler -WslInstanceName   Ubuntu-20.04 -GatewayIpAddress 172.16.0.1
Install-WslIpHandler: Cannot validate argument on parameter 'WslInstanceName'. Valid values generator return a null value.
PS C:\Users>

But while i do this:

ipmo Wsl-IpHandler; . (join-path (split-path (gmo Wsl-IpHandler).Path) 'Scripts/Powershell/FunctionsArgumentCompleters.ps1'); Get-WslInstancesNames

the console was flushed....

   at System.Management.Automation.PSModuleInfo.GetExportedTypeDefinitions()
   at System.Management.Automation.PSModuleInfo.GetExportedTypeDefinitions()
   at System.Management.Automation.AnalysisCache.CacheModuleExports(System.Management.Automation.PSModuleInfo, System.Management.Automation.ExecutionContext)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingModulePath(System.Management.Automation.PSModuleInfo, Boolean, System.Collections.Generic.IEnumerable`1<System.String>, System.String, System.Management.Automation.SessionState, ImportModuleOptions, ManifestProcessingFlags, System.Management.Automation.PSModuleInfo ByRef)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions, System.String)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName_WithTelemetry(ImportModuleOptions, System.String)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
   at System.Management.Automation.CommandProcessorBase.DoExecute()
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object)
   at System.Management.Automation.PipelineOps.InvokePipeline(System.Object, Boolean, System.Management.Automation.CommandParameterInternal[][], System.Management.Automation.Language.CommandBaseAst[], System.Management.Automation.CommandRedirection[][], System.Management.Automation.Language.FunctionContext)
   at System.Management.Automation.Interpreter.ActionCallInstruction`6[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Boolean, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
   at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon)
   at System.Management.Automation.DlrScriptCommandProcessor.RunClause(System.Action`1<System.Management.Automation.Language.FunctionContext>, System.Object, System.Object)
   at System.Management.Automation.DlrScriptCommandProcessor.Complete()
   at System.Management.Automation.CommandProcessorBase.DoComplete()
   at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object)
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()
   at System.Management.Automation.Runspaces.PipelineThread.WorkerProc()
   at System.Threading.Thread+StartHelper.Callback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Thread.StartCallback()

[process exited with code 3221225725 (0xc00000fd)]

As you can see, the terminal is terminated...lol

I've uninstalled and reinstalled it before all the struglings above.

@hatakawas
Copy link
Author

After checked the Beta UTF-8 option, the error disapeared.
image
But get new error
image

@hatakawas
Copy link
Author

Finally there!!!

Note here to help others:

  1. Checked the Beta UTF-8 option in regin settings to solve the Cannot validate argument on parameter 'WslInstanceName' problem.

  2. Removed the $_ in the /path/to/Wsl-IpHandler/Scripts/Powershell/FunctionsHostsFile.ps1 Line265, to solve the null-valued expression problem.

  3. Execute below command with Administrator in powershell:

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow

to add a filewall rule to solve the PING-failed problem.

Hope to help others. That's all.

@wikiped
Copy link
Owner

wikiped commented Jun 24, 2022

Thanks for sharing your findings.

However:

Last error that you showed regarding Get-IpAddressHostsCommentTuple failing when $null is passed was fixed in #28.
So removing $_ from the source file as you suggested will mean that you have to manage your hosts file manually.

As far as I am aware normally (i.e. "out-of-the-box") WSL2 has no blocking inbound firewall rules so ping error at the end indicates exactly what it means - that there was a problem with installation - which is to be expected if hosts file was not edited properly.

@hatakawas hatakawas reopened this Sep 15, 2022
@hatakawas
Copy link
Author

hatakawas commented Sep 15, 2022

@wikiped Hello buddy, this problem remains

image

Appreciate for your help!

@wikiped
Copy link
Owner

wikiped commented Sep 15, 2022

If you read the error you might notice that this is actually a different error, that was previously reported and fixed: #22

Can you show output of the following command:

ipmo Wsl-IpHandler -Pass | gmo | select -exp Version

@hatakawas
Copy link
Author

hatakawas commented Sep 16, 2022

image

this is the command's output.

And below is my hosts:

opyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

After this error
image

A new line added to the hosts:

172.16.0.101     Ubuntu-20.04       # Created by Wsl-IpHandler PowerShell Module

Thanks for help

@wikiped
Copy link
Owner

wikiped commented Sep 16, 2022

So the error is gone, correct?

Can you post output of the following two commands:

Get-WslStatus
Get-WslInstanceStatus -WslInstanceName Ubuntu-20.04

@hatakawas
Copy link
Author

Sorry, I was very busy recent days. I will close this issue for now.
Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants