我有一种情况,我必须根据比较版本在脚本中做出决定。请考虑以下示例:
PS C:\>
[version]$SomeVersion='1.1.1'
[version]$OtherVersion='1.1.1.0'
PS C:\> $SomeVersion
Major Minor Build Revision
----- ----- ----- --------
1 1 1 -1
PS C:\> $OtherVersion
Major Minor Build Revision
----- ----- ----- --------
1 1 1 0
PS C:\>$SomeVersion -ge $OtherVersion
False
Run Code Online (Sandbox Code Playgroud)
比较类型为System.Version的对象时,我想省略修订版,但
我找不到任何明智的方法。
有没有?
注意-我已经尝试做过:
PS C:\> ($scriptversion |select major,minor,build) -gt ($currentVersion|select major,minor,build)
Cannot compare "@{Major=1; Minor=1; Build=1}" to "@{Major=1; Minor=1;
Build=1}" because the objects are not the same type or the object "@{Major=1;
Minor=1; Build=1}" does not implement "IComparable".
At …Run Code Online (Sandbox Code Playgroud) 尝试运行 Register-PsRepository 时出现以下错误
我试过了:
有任何想法吗?
PS C:\> Register-PSRepository -Name MyRepo -SourceLocation https://MyRepo.com/api/Myrepo -Credential $c
PackageManagement\Register-PackageSource : The property 'Name' cannot be
found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.0\PSModule.psm1:4631 char:17
Run Code Online (Sandbox Code Playgroud)