Author Posts

May 20, 2014 at 12:25 pm

Hello, I'm getting this error when I try to run Get-Content.
Get-Content : Cannot bind argument to parameter 'Path' because it is an empty array.
At line:1 char:1
+ Get-Content
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyArrayNotAllowed,Microsoft.PowerShell.Commands.GetContentCommand

I first noticed the problem when I tried using Show-Command. The error for that is:
get-command : Object reference not set to an instance of an object.
At line:1 char:3
+ @(get-command -CommandType Cmdlet,Function,Script,ExternalScript,Work ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Command], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.GetCommandCommand

I get the same errors using console or ISE. Same thing using elevated for both. Any thoughts???

May 20, 2014 at 12:30 pm

Sorry, I forgot to add that I also tried opening the console with the -NoProfile option. I still receive the error.

May 20, 2014 at 12:38 pm

The Get-Content cmdlet gets the contents of a file. The Path parameter is a mandatory parameter and must be specified otherwise you'll receive that error:


PS C:\> help Get-Content -Parameter path

-Path 
    Specifies the path to an item. Get-Content gets the content of the item. Wildcards are permitted. The parameter
    name ("Path" or "FilePath") is optional.

    Required?                    true
    Position?                    1
    Default value
    Accept pipeline input?       true (ByPropertyName)
    Accept wildcard characters?  true

PS C:\>

May 20, 2014 at 12:49 pm

Mike, thanks for the quick reply. Unfortuneatly, I pasted the wrong command. It's Get-Command, not Get-Content. Hate when I do that. You can see the error I get with Show-Command after my typo earlier. Here's the error for Get-Command:

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

May 20, 2014 at 1:23 pm

If you run Get-Command on a particular cmdlet, do you receive the same error? Example:


Get-Command -Name Get-Module

If that runs without error, give this a try to see if it's cmdlets in a particular module that's causing the issue:


Get-Module -ListAvailable | ForEach-Object {
    Write-Output "*** Module Name: $($_.Name) ***"
    Get-Command -Module $_.Name
}

May 20, 2014 at 1:28 pm

Roger,

Please check out my post on another thread where we are discussing the Get-Command error as well. The Microsoft KB article might be relevant if you have SQL Server 2008/2008 R2 components installed.

PowerShell Repair?

Best,
Daniel

May 21, 2014 at 4:53 am

Daniel, I have SQL Server Express 2012 installed. I'll double check this though just in case. Thanks

Mike, the command, as you suggested, "Get-Command -name Get-Module", works. I tried "Show-Command Get-Module" and the worked as well. However, if I try Get-Command or Show-Command with no parameters, I still get the error.