Win10 및 Powershell 5.0을 새로 설치했습니다. 나는 update-help를 실행했고 대부분 잘 동작한다. 그러나 Get-Command는 일반 모드인지 상승 모드인지에 관계없이 null 참조 예외를 반환합니다. 나는 또한 -noprofile을 사용하여 Run from Powershell을 실행하려고 시도했지만 사용자와 상승 모드에서 여전히 동일한 오류가 발생합니다. 여기에 몇 가지 추가 정보는 다음과 같습니다Powershell 5.0/Windows 10 Get-Command Null 참조 예외
PS Z:\> Get-WmiObject Win32_OperatingSystem | Select-Object -Property Version, ServicePackMajorVersion, ServicePackMinorVersion
Version ServicePackMajorVersion ServicePackMinorVersion
------- ----------------------- -----------------------
10.0.10586 0 0
PS Z:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.0.10586.122
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.122
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS Z:\> get-command
>> TerminatingError(Get-Command): "Object reference not set to an instance of an object."
get-command : Object reference not set to an instance of an object.
At line:1 char:1
+ get-command
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand
get-command : Object reference not set to an instance of an object.
At line:1 char:1
+ get-command
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand
PS Z:\> $error[0] | format-list * -force
PSMessageDetails :
Exception : System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.PowerShell.Commands.GetCommandCommand.IsCommandMatch(CommandInfo& current, Boolean& isDuplicate)
at Microsoft.PowerShell.Commands.GetCommandCommand.AccumulateMatchingCommands(IEnumerable`1 commandNames)
at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject :
CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceException
FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PS Z:\> $error[0].line
PS Z:\> $error[0].exception | format-list * -force
Message : Object reference not set to an instance of an object.
Data : {}
InnerException :
TargetSite : Boolean IsCommandMatch(System.Management.Automation.CommandInfo ByRef, Boolean ByRef)
StackTrace : at Microsoft.PowerShell.Commands.GetCommandCommand.IsCommandMatch(CommandInfo& current, Boolean& isDuplicate)
at Microsoft.PowerShell.Commands.GetCommandCommand.AccumulateMatchingCommands(IEnumerable`1 commandNames)
at System.Management.Automation.CommandProcessor.ProcessRecord()
HelpLink :
Source : System.Management.Automation
HResult : -2147467261
사용자와 높은 모드 모두에서 갱신 도움을 실행 한 후, 내가 PowerShell에서했던 다음 일은 내가 '돈 때문에이 문제가 발생하는 경우 SQL Power Doc 그래서 난 잘 모르겠어요 설치했다 설치 전에 Get-Command를 사용하여 호출하십시오. 이 오류없이 작동 -
Set-ExecutionPolicy RemoteSigned -Force
New-Item -type directory -path "$([Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments))\WindowsPowerShell\Modules"
Set-Location "$([Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments))\WindowsPowerShell"
내가 가져-명령에 대한 도움말을 실행합니다 :
PS Z:\> help get-command
NAME
Get-Command
SYNOPSIS
Gets all commands.
SYNTAX
Get-Command [[-ArgumentList] [<Object[]>]] [-All] [-FullyQualifiedModule [<ModuleSpecification[]>]] [-ListImported] [-Module [<String[]>]] [-Noun [<String[]>]] [-ParameterName [<String[]>]] [-ParameterType [<PSTypeName[]>]] [-ShowCommandInfo] [-Syntax] [-TotalCount
[<Int32>]] [-Verb [<String[]>]] [<CommonParameters>]
Get-Command [[-Name] [<String[]>]] [[-ArgumentList] [<Object[]>]] [-All] [-CommandType {Alias | Function | Filter | Cmdlet | ExternalScript | Application | Script | Workflow | Configuration | All}] [-FullyQualifiedModule [<ModuleSpecification[]>]] [-ListImported]
[-Module [<String[]>]] [-ParameterName [<String[]>]] [-ParameterType [<PSTypeName[]>]] [-ShowCommandInfo] [-Syntax] [-TotalCount [<Int32>]] [<CommonParameters>]
DESCRIPTION
The Get-Command cmdlet gets all commands that are installed on the computer, including cmdlets, aliases, functions, workflows, filters, scripts, and applications. Get-Command gets the commands from Windows PowerShell modules and snap-ins and commands that were
imported from other sessions. To get only commands that have been imported into the current session, use the ListImported parameter.
Without parameters, a Get-Command command gets all of the cmdlets, functions, workflows and aliases installed on the computer. A Get-Command * command gets all types of commands, including all of the non-Windows-PowerShell files in the Path environment variable
($env:path), which it lists in the "Application" command type.
A Get-Command command that uses the exact name of the command (without wildcard characters) automatically imports the module that contains the command so you can use the command immediately. To enable, disable, and configure automatic importing of modules, use the
$PSModuleAutoLoadingPreference preference variable. For more information, see about_Preference_Variables (http://go.microsoft.com/fwlink/?LinkID=113248).
Get-Command gets its data directly from the command code, unlike Get-Help, which gets its information from help topics.
In Windows PowerShell 2.0, Get-Command gets only commands in current session. It does not get commands from modules that are installed, but not imported. To limit Get-Command in Windows PowerShell 3.0 and later to commands in the current session, use the
ListImported parameter.
Starting in Windows PowerShell 5.0, results of the Get-Command cmdlet display a Version column by default; a new Version property has been added to the CommandInfo class.
RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/p/?linkid=289583
Export-PSSession
Get-Help
Get-Member
Get-PSDrive
Import-PSSession
about_Command_Precedence
REMARKS
To see the examples, type: "get-help Get-Command -examples".
For more information, type: "get-help Get-Command -detailed".
For technical information, type: "get-help Get-Command -full".
For online help, type: "get-help Get-Command -online"
사람이 분명 아무것도 보이지 않음 동안
내가이 명령을 실행, 설치? 어떤 도움을 주셔서 감사합니다.
분명히하기 : Windows 10 OS를 새로 설치했지만 수동으로 PowerShell 5.0을 설치하려고하지 않았습니까? PS 5에는 10이 나온 이래로? – gravity
맞습니다. – SFAgitator
'Modules' 디렉토리의 이름을 임시로 바꾼 다음'Get-Command'를 다시 실행하여 수정했는지 확인하는 것이 좋습니다. 당신이 모듈을 추가 한 것을 본 후에, 나는 그것이 관련이 있다고 내기하고 있습니다. 그것이 문제를 해결하지 못한다면 복원하여 알려주십시오 ...;) – gravity