Get error while running Enable-Migrations - powershell

I got below error while running Enable-Migrations on my ASP.NET MVC5 project (Powershell v5 & Visual Studio 2015). I have tried to uninstall and re-install EntityFramework (v6.1.3) but no lucky.
Does anyone know how to solve it?
Type name 'Microsoft.VisualStudio.Shell.Package' is ambiguous, it could be 'Microsoft.VisualStudio.Shell.Package, Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or 'Microsoft.VisualStudio.Shell.Package, Microsoft.VisualStudio.Shell.11.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
At C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\MSHGPU2S.W4I\Modules\NuGet\profile.ps1:126 char:5
+ $service = [Microsoft.VisualStudio.Shell.Package]::GetGlobalServi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : AmbiguousTypeReference
Type name 'NuGet.VisualStudio.IVsPackageInstallerServices' is ambiguous, it could be 'NuGet.VisualStudio.IVsPackageInstallerServices, Microsoft.VisualStudio.ApplicationInsights, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or 'NuGet.VisualStudio.IVsPackageInstallerServices, Microsoft.VisualStudio.Web.Application, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
At D:\xxx\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:1004 char:5
+ $packageInstallerServices = $componentModel.GetService([NuGet.Vis ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : AmbiguousTypeReference
You cannot call a method on a null-valued expression.
At D:\xxx\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:1006 char:5
+ $vsPackage = $packageInstallerServices.GetInstalledPackages() | ? ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At D:\xxx\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:713 char:28
+ $toolsPath = Join-Path $installPath tools
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At D:\xxx\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 char:74
+ ... [System.Reflection.Assembly]::LoadFrom((Join-Path $ToolsPath EntityF ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
You cannot call a method on a null-valued expression.
At D:\xxx\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 char:5
+ $dispatcher = $utilityAssembly.CreateInstance(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At D:\xxx\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:810 char:20
+ (Join-Path $runner.ToolsPath EntityFramework.PowerShell.dll),
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand

This is a known bug if you have any of the Windows 10 Insider Preview builds from 11099 to 14257
Official bug report https://entityframework.codeplex.com/workitem/2872

Related

PowerShell File Path for Readyshare

Specification:
OS Windows 10
SQL Server 2012
Languages and software used:
Powershell
Excel 2010
Code:
#Define locations and delimiter
$csv = "\\READYSHARE\USB_Storage\Trucking_Inc\SomeFile.csv" #Location of the source file
$xlsx = "\\READYSHARE\USB_Storage\Trucking_Inc\SomeFile2.xlsx" #Desired location of output
$delimiter = "," #Specify the delimiter used in the file
# Create a new Excel workbook with one empty sheet
$excel = New-Object -ComObject excel.application
$workbook = $excel.Workbooks.Add(1)
$worksheet = $workbook.worksheets.Item(1)
# Build the QueryTables.Add command and reformat the data
$TxtConnector = ("TEXT;" + $csv)
$Connector = $worksheet.QueryTables.add($TxtConnector,$worksheet.Range("A1"))
$query = $worksheet.QueryTables.item($Connector.name)
$query.TextFileOtherDelimiter = $delimiter
$query.TextFileParseType = 1
$query.TextFileColumnDataTypes = ,1 * $worksheet.Cells.Columns.Count
$query.AdjustColumnWidth = 1
# Execute & delete the import query
$query.Refresh()
$query.Delete()
# Save & close the Workbook as XLSX.
$Workbook.SaveAs($xlsx,51)
$excel.Quit()
Job error:
Executed as user: NT Service\SQLAgent$Server. ...l.exe -file "C:\Scripts\trasaction.ps1"Microsoft Excel cannot access the file '\READYSHARE\USB_Storage\Trucking_Inc\SomeFile2.csv'. There are several possible reasons: The file name or path does not exist. The file is being used by another program. The workbook you are trying to save has the same name as a currently open workbook. At C:\Scripts\trasaction.ps1:12 char:1 + $Workbook = $excel.Workbooks.Open($ExcelFilePath) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], COMException + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:13 char:1 + $Worksheet = $Workbook.Sheets.Item(1) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:21 char:1 + Out-File -FilePath C:\Scripts\process.txt -InputObject $Columns.Cells ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:22 char:1 + Write-Host $Columns.Cells(5,5).Value + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:161 char:1 + $eRow = $Worksheet.cells.item(1,1).entireRow + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:162 char:1 + $active = $eRow.activate() + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:163 char:1 + $active = $eRow.insert($xlShiftDown) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:164 char:1 + $Worksheet.Cells.item(1,1) = "TRANSACTION_DATE" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:165 char:1 + $Worksheet.Cells.item(1,2) = "AMOUNT" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:166 char:1 + $Worksheet.Cells.item(1,3) = "TYPE_OF_AUTHORIZATION_AND_DATE" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot call a method on a null-valued expression. At C:\Scripts\trasaction.ps1:167 char:1 + $Worksheet.Cells.item(1,4) = "CHECK_NUMBER" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull You cannot ... Process Exit Code 0. The step succeeded.
Things that were tried.
giving perminsions for the SqlServerAgent. Which readyshare will not let me do.
making the file path with powershell script name in to a bat file to be executed from the C: drive to get into the file path.
Notes:
This powershell script runs great from the command prompt by manually opening up cmd and executing. Even works great from the ISE (x86) manually.
However, when using this from a job you get the error listed above.
I have tried to get the readyshare drive to give SQLSeverAgent permissions but reverts back to original permissions. The router I have is a nightHawk router
and I didn't see any setting with in the router to give permissons either tried through Windows 10 but reverts back to original permissions.
Checked these suggestion from the message
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
None applied.
Is there any work around or option I may not know about? Need some guidance or pointer in the right direction.

powershell change category color, error message?

So i got this script, it should change the category color in office365, from powershell.................................................................
Script:
$messages = Import-Csv -Path c:\temp\messageid.csv
Connect-EXRMailbox -Mailbox "email#domain.com"
ForEach ($message in $messages){
$MessageId = $message.MessageId
$MailboxName = $message.MailboxName
$Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId
Set-EXRItemCategory MailboxName $MailboxName -Item $Item -Categories #("Green")
}
Error code:
New-Object : Exception calling ".ctor" with "1" argument(s): "The specified string is not in the form required for an e-mail address."
At line:17 char:19
+ ... stDomain = (New-Object system.net.Mail.MailAddress($MailboxName)).Hos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Exception calling "ContainsKey" with "1" argument(s): "Key cannot be null.
Parameter name: key"
At line:18 char:8
+ if ($Script:TokenCache.ContainsKey($HostDomain))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
New-Object : Exception calling ".ctor" with "1" argument(s): "The specified string is not in the form required for an e-mail address."
At line:17 char:19
+ ... stDomain = (New-Object system.net.Mail.MailAddress($MailboxName)).Hos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Exception calling "ContainsKey" with "1" argument(s): "Key cannot be null.
Parameter name: key"
At line:18 char:8
+ if ($Script:TokenCache.ContainsKey($HostDomain))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
Get-EXRAccessToken : No Access Token for MailboxName
At line:31 char:32
+ ... $AccessToken = Get-EXRAccessToken -MailboxName $MailboxName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-EXRAccessToken
Get-EndPoint : Cannot bind argument to parameter 'AccessToken' because it is null.
At line:38 char:47
+ $EndPoint = Get-EndPoint -AccessToken $AccessToken -Segment " ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-EndPoint], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Get-EndPoint
New-Object : Exception calling ".ctor" with "1" argument(s): "The specified string is not in the form required for an e-mail address."
At line:17 char:19
+ ... stDomain = (New-Object system.net.Mail.MailAddress($MailboxName)).Hos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Exception calling "ContainsKey" with "1" argument(s): "Key cannot be null.
Parameter name: key"
At line:18 char:8
+ if ($Script:TokenCache.ContainsKey($HostDomain))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
New-Object : Exception calling ".ctor" with "1" argument(s): "The specified string is not in the form required for an e-mail address."
At line:17 char:19
+ ... stDomain = (New-Object system.net.Mail.MailAddress($MailboxName)).Hos ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
Exception calling "ContainsKey" with "1" argument(s): "Key cannot be null.
Parameter name: key"
At line:18 char:8
+ if ($Script:TokenCache.ContainsKey($HostDomain))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
Get-EXRAccessToken : No Access Token for MailboxName
At line:24 char:20
+ ... $AccessToken = Get-EXRAccessToken -MailboxName $MailboxName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-EXRAccessToken
Invoke-RestPatch : Cannot bind argument to parameter 'AccessToken' because it is null.
At line:32 char:92
+ ... $RequestURL -HttpClient $HttpClient -AccessToken $AccessToken -Mailbo ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-RestPatch], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Invoke-RestPatch
My Csv file:
"MessageId","MailboxName"
"<HE1P192MB018554247E4F4A81D830F19DD1820#HE1P192MB0185.EURP192.PROD.OUTLOOK.COM>","email#domaion.com"
So my question is. Is it my code there is an error in, or is it in the Exch-Rest tool ?
Hope anyone knows how to fix this .
Have a really nice day!
"Is it my code there is an error in, or is it in the Exch-Rest tool ?"
It's you. It's almost always you. That's half of why bugs in external libraries are so hard to find :)
Where do you initialise your $Mailbox variable?
If it's from your CSV file, then you should use
$message.MailboxName
$message.MessageID

Showing error while adding element in List[int] in powershell?

$sumList= New-Object System.Collections.Generic.List[int]
$eventList = New-Object System.Collections.Generic.List[string]
$preSumList= New-Object System.Collections.Generic.List[int]
$threadInitDelay = [int]$commaSplit[++$eventIndex].Split(':')[1].Trim()
$preProcessTime = [int]$commaSplit[++$eventIndex].Split(':')[1].Trim()+[int]$commaSplit[++$eventIndex].Split(':')[1].Trim()+$commaSplit[[int]++$eventIndex].Split(':')[1].Trim()
$respTime = [int]$commaSplit[++$eventIndex].Split(':')[1].Trim();
$index =$eventList.FindIndex({param([string]$s) return $s -like 'hi'})
if($index -eq -1){
$eventList.Add($eventName)
$sumList.Add($threadInitDelay)
$respSumList.Add($respTime)
Getting this error:
Method invocation failed because [System.Int32[]] doesn't contain a method named 'Add'.
At D:\Powercel\PowershellPractice.ps1:151 char:19
+ $sumList.Add <<<< ($threadInitDelay)
+ CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.Int32[]] doesn't contain a method named 'Add'.
At D:\Powercel\PowershellPractice.ps1:152 char:23
+ $respSumList.Add <<<< ($respTime)
+ CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.Int32[]] doesn't contain a method named 'Add'.
At D:\Powercel\PowershellPractice.ps1:153 char:23
+ $respMaxTime.Add <<<< ($respTime)
+ CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.Int32[]] doesn't contain a method named 'Add'.
At D:\Powercel\PowershellPractice.ps1:155 char:19
+ $minTime.Add <<<< ($threadInitDelay)
+ CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Could you please help me out?
A possible scenario is that you were testing and actually casted those variables like the error states. The error is not wrong. Those variables are not the list types that you have in your code. I can almost reproduce this issue:
PS M:\Scripts\Inno\Output> [int[]]$sumlist = 5,5
PS M:\Scripts\Inno\Output> $sumlist.GetType().Fullname
System.Int32[]
PS M:\Scripts\Inno\Output> $sumlist.Add(5)
Exception calling "Add" with "1" argument(s): "Collection was of a fixed size."
At line:1 char:1
+ $sumlist.Add(5)
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NotSupportedException
PS M:\Scripts\Inno\Output> $sumlist = New-Object System.Collections.Generic.List[int]
While I didn't get the same error as you the point is the type of the variable didn't change even though I tried to recasted it. That is because of property of the variable explained in this answer by PetSerAl. Have a look at the command Get-Variable sumlist | ft Name,Attributes and you should see System.Management.Automation.ArgumentTypeConverterAttribute. Removing the variable and starting again I get your expected behavior.
PS M:\Scripts\Inno\Output> Remove-Variable sumlist
PS M:\Scripts\Inno\Output> $sumlist = New-Object System.Collections.Generic.List[int]
PS M:\Scripts\Inno\Output> $sumlist.Add(5)
PS M:\Scripts\Inno\Output> $sumlist.GetType().FullName
System.Collections.Generic.List`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

Powershell: FCIV script error: "Cannot find path because it does not exist"

I am new to PowerShell, so I may have missed something simple. I am trying to run a file checksum for Start-PsFCIV, outlined here.
My attempt is below, where I have also tried excluding the -Path parameter, as well as using relative/absolute paths.
PS C:\Users\Lucas\Downloads> Start-PsFCIV -Path C:\Users\Lucas\Downloads\DXSDK_Jun10.exe -HashAlgorithm SHA1
Set-Location : Cannot find path 'C:\Users\Lucas\Downloads\DXSDK_Jun10.exe' because it does not exist.
At C:\Scripts\PsFCIV_2.5.ps1:227 char:3
+ Set-Location -LiteralPath $path
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\Lucas\Downloads\DXSDK_Jun10.exe:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
Test-Path : Cannot bind argument to parameter 'LiteralPath' because it is an empty string.
At C:\Scripts\PsFCIV_2.5.ps1:280 char:32
+ if (!(Test-Path -LiteralPath $XML)) {return New-Object PsFCIV.FCIV}
+ ~~~~
+ CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
__fromxml : Input XML file is not valid FCIV XML file.
At C:\Scripts\PsFCIV_2.5.ps1:511 char:9
+ $sum = __fromxml $xml
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,__fromxml
Exception setting "VerboseForegroundColor": "Cannot convert value "-1" to type "System.Windows.Media.Color". Error: "Invalid cast from 'System.ConsoleColor' to 'System.Windows.Media.Color'.""
At C:\Scripts\PsFCIV_2.5.ps1:607 char:4
+ $host.PrivateData.VerboseForegroundColor = $Host.UI.RawUI.ForegroundColor
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
You cannot call a method on a null-valued expression.
At C:\Scripts\PsFCIV_2.5.ps1:612 char:4
+ $sum.FILE_ENTRY.Add($entry)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception setting "VerboseForegroundColor": "Cannot convert value "-1" to type "System.Windows.Media.Color". Error: "Invalid cast from 'System.ConsoleColor' to 'System.Windows.Media.Color'.""
At C:\Scripts\PsFCIV_2.5.ps1:607 char:4
+ $host.PrivateData.VerboseForegroundColor = $Host.UI.RawUI.ForegroundColor
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
How can I get this command to work? I could not find any solutions or similar problems after ~15 min search.
The first exception you get is thrown by Set-Location cmdlet that for some reason is used in the Start-PsFCIV script. Set-Location expects a folder as its -LiteralPath argument but you pass it a file instead.
As per "Useful Examples" on the PsFCIV webpage the solution is to use -Include argument. Example:
Start-PsFCIV -Path C:\tmp -Include InstallPackage.msi -XML DB.XML -HashAlgorithm SHA512
# Checks only InstallPackage.msi file in C:\tmp folder by using SHA512 hash algorithm.

MethodArgumentConversionInvalidCastArgument after version update

After updating NuGet to version 2.8.50313.31, opening the Package Manager Console displays a number of errors.
Is this a known issue with that (now current) version? Is there a fix/work-around?
If there is no fix, how does one revert to the previous version of NuGet?
New-Object : Could not load file or assembly
'System.Management.Automation, Ver sion=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its d ependencies. The
system cannot find the file specified. At
E:\dev\myProject\packages\MvcScaffolding.1.0.6\tools\registerWithMvcTooling.ps1
:143 char:27
+ $newProvider = New-Object <<<< $powerShellScaffolderProviderType($mvcSca ffoldingProvider)
+ CategoryInfo : NotSpecified: (:) [New-Object], FileNotFoundExce ption
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerS
hell.Commands.NewObjectCommand Cannot convert argument "0", with
value: "Microsoft.VisualStudio.Web.Mvc.Scaffo
lding.PowerShell.PowerShellScaffolderProvider", for "Add" to type
"Microsoft.Vi
sualStudio.Web.Mvc.Extensibility.Scaffolding.ScaffolderProvider":
"Cannot conve rt the
"Microsoft.VisualStudio.Web.Mvc.Scaffolding.PowerShell.PowerShellScaffol
derProvider" value of type
"Microsoft.VisualStudio.Web.Mvc.Scaffolding.PowerShe
ll.PowerShellScaffolderProvider" to type
"Microsoft.VisualStudio.Web.Mvc.Extens
ibility.Scaffolding.ScaffolderProvider"." At
E:\dev\myProject\packages\MvcScaffolding.1.0.6\tools\registerWithMvcTooling.ps1
:144 char:19
+ $allProviders.Add <<<< ($newProvider) | Out-Null
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument PM> New-Object : Could
not load file or assembly 'System.Management.Automation, Ver
sion=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one
of its d ependencies. The system cannot find the file specified. At
E:\dev\myProject\packages\MvcScaffolding.1.0.6\tools\registerWithMvcTooling.ps1
:143 char:27
+ $newProvider = New-Object <<<< $powerShellScaffolderProviderType($mvcSca ffoldingProvider)
+ CategoryInfo : NotSpecified: (:) [New-Object], FileNotFoundExce ption
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerS
hell.Commands.NewObjectCommand Cannot convert argument "0", with
value: "Microsoft.VisualStudio.Web.Mvc.Scaffo
lding.PowerShell.PowerShellScaffolderProvider", for "Add" to type
"Microsoft.Vi
sualStudio.Web.Mvc.Extensibility.Scaffolding.ScaffolderProvider":
"Cannot conve rt the
"Microsoft.VisualStudio.Web.Mvc.Scaffolding.PowerShell.PowerShellScaffol
derProvider" value of type
"Microsoft.VisualStudio.Web.Mvc.Scaffolding.PowerShe
ll.PowerShellScaffolderProvider" to type
"Microsoft.VisualStudio.Web.Mvc.Extens
ibility.Scaffolding.ScaffolderProvider"." At
E:\dev\myProject\packages\MvcScaffolding.1.0.6\tools\registerWithMvcTooling.ps1
:144 char:19
+ $allProviders.Add <<<< ($newProvider) | Out-Null
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument New-Object : Could not
load file or assembly 'System.Management.Automation, Ver sion=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its d
ependencies. The system cannot find the file specified. At
E:\dev\myProject\packages\MvcScaffolding.1.0.6\tools\registerWithMvcTooling.ps1
:143 char:27
+ $newProvider = New-Object <<<< $powerShellScaffolderProviderType($mvcSca ffoldingProvider)
+ CategoryInfo : NotSpecified: (:) [New-Object], FileNotFoundExce ption
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerS
hell.Commands.NewObjectCommand Cannot convert argument "0", with
value: "Microsoft.VisualStudio.Web.Mvc.Scaffo
lding.PowerShell.PowerShellScaffolderProvider", for "Add" to type
"Microsoft.Vi
sualStudio.Web.Mvc.Extensibility.Scaffolding.ScaffolderProvider":
"Cannot conve rt the
"Microsoft.VisualStudio.Web.Mvc.Scaffolding.PowerShell.PowerShellScaffol
derProvider" value of type
"Microsoft.VisualStudio.Web.Mvc.Scaffolding.PowerShe
ll.PowerShellScaffolderProvider" to type
"Microsoft.VisualStudio.Web.Mvc.Extens
ibility.Scaffolding.ScaffolderProvider"." At
E:\dev\myProject\packages\MvcScaffolding.1.0.6\tools\registerWithMvcTooling.ps1
:144 char:19
+ $allProviders.Add <<<< ($newProvider) | Out-Null
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
It turns out that MvcScaffolding.1.0.6 is no longer referenced by any project in the solution.
Removing it from the NuGet command line
Uninstall-Package MvcScaffolding
resolved the issue.
There is currently version 1.0.9 of MvcScaffolding. The issue may be resolved in that version. However, since I no longer reference that package, I did not test that.