error while build in jenkins; error whilw instaling nuget packages - asp.net-mvc

Heading
PS C:\WINDOWS\system32> Install-Package NuGet.CommandLine -Version 6.0.0
Install-Package : A parameter cannot be found that matches parameter name 'Version'.
At line:1 char:35
Install-Package NuGet.CommandLine -Version 6.0.0
~~~~~~~~
CategoryInfo : InvalidArgument: (:) [Install-Package], ParameterBindingException
FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Related

if I exit the project and enter again the migration does not find the Context anymore

If I leave the project and enter again and make some changes to the Model and then do the migration again, it gives me this problem, why does this happen???
"
Add-Migration MyText -Context MyContext
Add-Migration : Cannot find a parameter that matches the parameter name 'Context'.
No line:1 caractere:50
Add-Migration MyText -Context MyContext...
~~~~~~~~
CategoryInfo : InvalidArgument: (:) [Add-Migration], ParameterBindingException
FullyQualifiedErrorId : NamedParameterNotFound,Add-Migration
"

Get-PSRepository, powershell warning: "Unable to find module repositories" while trying to install Docker in WindowsServer2016

I want to install Docker and so I tried the below command which gave an error
PS C:\Windows\system32> Install-Module -Name DockerMsftProvider
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'DockerMsftProvider'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\ WindowsPowerShell\ Modules\ PowerShellGet\ 1.0.0.1\ PSModule .psm1:1772 char:21 $null = PackageManagement\Install-Package #PSBoundParameters CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : NoMatchFoundForCriteria, Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
even Install-Module -Name DockerMsftProvider -Repository PSGallery -Force gave the same error.
I tried the below resources and still its the same. I am not able to register a PSRepository. Only when this is installed I can install Docker in Windows Server. I spent hours to solve this still at 0% progress. Registering the PSRepository (Register-PSRepository -Default -InstallationPolicy Trusted) went fine without any errors but still its not visible.
Any possible help to solve this?
https://copdips.com/2018/05/setting-up-powershell-gallery-and-nuget-gallery-for-powershell.html
WARNING: Unable to find module repositories
Unable to find module providers
https://www.powershellgallery.com/packages/PowerShellGet/2.2.1
https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=Windows-Server#prerequisites
Try running this, do you still get an error?
[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
Install-Module -Name DockerMsftProvider -Scope AllUsers

Error when using Tags during certificate import through Azure PowerShell

Issue description: (Please see below screen dump for reference)
Failure using Tag with Import-AzureKeyVaultCertificate cmdlet.
The certificate would be imported into key vault okay even though I got the error message (as shown below).
However, I am not able to retrieve the certificate using Get-AzureKeyVaultCertificate cmdlet, even though I could use Get-AzureKeyVaultSecret cmdlet (Tags displayed correctly).
Additional info
• If I remove Tags from Azure portal or re-import the certificate without -Tag, I will still get the same error (Unable to cast object).
• If I delete the cert and re-import the certificate without Tags, everything is working great.
Assistance needed:
I am using 5.1.2 Azure PowerShell. Please advise what am I missing. Thanks.
PS C:\Users\tonychou> $certificateTag = #{
type = "certificate";
subjectname = "rsppe-microsoft-com";
alternatename = "dss";
environment = "Test"
};
PS C:\Users\tonychou> $certificatePasswordSecuredString = ConvertTo-SecureString $certificatePassword -AsPlainText -Force;
Import-AzureKeyVaultCertificate -VaultName $kvName -CertificateName $certInCertName -FilePath $certificatePfxFile -Password $certificatePasswordSecuredString -Tag $certificateTag;
Import-AzureKeyVaultCertificate : Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.String,System.String]' to type 'System.Collections.Hashtable'.
At line:2 char:1
+ Import-AzureKeyVaultCertificate -VaultName $kvName -CertificateName $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Import-AzureKeyVaultCertificate], InvalidCastException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.ImportAzureKeyVaultCertificate
PS C:\Users\tonychou> $certInCertificate = Get-AzureKeyVaultCertificate -VaultName $kvName -Name $certInCertName;
Get-AzureKeyVaultCertificate : Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.String,System.String]' to type 'System.Collections.Hashtable'.
At line:1 char:22
+ ... rtificate = Get-AzureKeyVaultCertificate -VaultName $kvName -Name $ce ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureKeyVaultCertificate], InvalidCastException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.GetAzureKeyVaultCertificate
PS C:\Users\tonychou> $certInSecret = Get-AzureKeyVaultSecret -VaultName $kvName -Name $certInCertName;
PS C:\Users\tonychou> $certInCertificate
PS C:\Users\tonychou> $certInSecret
SecretValue : System.Security.SecureString
SecretValueText : MIIXegIBAzCCFzoGCSqGSIb3DQEHAaCCFysEghcnMIIXIzCCBgQGCSqGSIb3DQEHAaCCBfUEggXxMIIF7TCCBekGCyqGSIb3DQEMCgECoIIE9jCCBPIwHAYKKoZIhvcNAQwBAzAOBAgn0z9KUgiVSwICB9AEggTQ+38U79mo15qmAm7r0IgpGlveZFMHwqYt/LmEZOUyTKXv6GWHxkSoy/+dsa2XkVFruWas5WgqksMuwxY
43kum42JCzSHIkEzAbiN3zZNZWM7JDLaXBooR2bpOR49fdGdy44RmQjFGkU7w2cYLMjB+WSBQ9tt2xw4W1fJnv4d3vO44BQ/c2n1aHBZjmobdSrIDtpK8h+aiZyUrNix6wlifthI884h09rlF6ipBDicbgLn4NbpYPzfZlpa304fU9c7h0j/IDpdOi2zZOVT2Q3oc9ouMuSaKBC9CKE3Q99UBwyX/tZjM/A/uuW5nh3KQZ8
IJciW7/odBt3b9venZOHHbAZDns5iIzwop3hzSEDbQTqQ3hffdFEyUexHsq5AP2syveZYWlIrDpe9YJVB
PS C:\Users\tonychou> Get-Module -ListAvailable | ?{$_.Name -eq "Azure"}
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 5.1.2 Azure {Get-AzureAutomationCertificate, Get-AzureAutomationConnection, New-AzureAutomationConnection, Remove-AzureAutomationConnection...}
We suggest moving to Powershell version 6.0.0 and above

TFS Build Solution failure: UnauthorizedAccess Microsoft.PowerShell.Commands.ImportModuleCommand

I'm attempting to set up our first build agent for TFS 2017 On-Premise. I've taken a 2012 R2 server, installed the agent and Visual Studio 2017. The agent appears in TFS with the correct capabilities. I've taken one of the default templates for building ASP.net projects and made the minimum changes possible to it. On the first run, I can see the first few steps of getting sources and updating NuGet packages complete successfully. However the build solution step fails, and I'm struggling to understand what the issue may be.
The build log shows the following:
2017-11-15T13:16:10.3583612Z ##[section]Starting: Build solution
2017-11-15T13:16:10.3583612Z ==============================================================================
2017-11-15T13:16:10.3583612Z Task : Visual Studio Build
2017-11-15T13:16:10.3583612Z Description : Build with MSBuild and set the Visual Studio version property
2017-11-15T13:16:10.3583612Z Version : 1.119.0
2017-11-15T13:16:10.3583612Z Author : Microsoft Corporation
2017-11-15T13:16:10.3583612Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613727)
2017-11-15T13:16:10.3583612Z ==============================================================================
2017-11-15T13:16:10.8588602Z Import-Module : AuthorizationManager check failed.
2017-11-15T13:16:10.8588602Z At line:1 char:453
2017-11-15T13:16:10.8588602Z + . ([scriptblock]::Create('if (!$PSHOME) { $null = Get-Item -LiteralPath ''variab ...
2017-11-15T13:16:10.8588602Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-11-15T13:16:10.8588602Z + CategoryInfo : SecurityError: (:) [Import-Module], PSSecurityException
2017-11-15T13:16:10.8588602Z + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
2017-11-15T13:16:10.9677474Z Invoke-VstsTaskScript : The term 'Invoke-VstsTaskScript' is not recognized as the name of a cmdlet, function, script
2017-11-15T13:16:10.9677474Z file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
2017-11-15T13:16:10.9677474Z and try again.
2017-11-15T13:16:10.9677474Z At line:1 char:786
2017-11-15T13:16:10.9677474Z + ... tlyContinue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create('. ''\\ ...
2017-11-15T13:16:10.9677474Z + ~~~~~~~~~~~~~~~~~~~~~
2017-11-15T13:16:10.9677474Z + CategoryInfo : ObjectNotFound: (Invoke-VstsTaskScript:String) [], CommandNotFoundException
2017-11-15T13:16:10.9677474Z + FullyQualifiedErrorId : CommandNotFoundException
2017-11-15T13:16:10.9677474Z
2017-11-15T13:16:10.9989971Z ##[error]Exit code 1 returned from process: file name 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe', arguments '-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ([scriptblock]::Create('if (!$PSHOME) { $null = Get-Item -LiteralPath ''variable:PSHOME'' } else { Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1'')) ; Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1'')) }')) 2>&1 | ForEach-Object { Write-Verbose $_.Exception.Message -Verbose } ; Import-Module -Name '\\hidden-unc-path\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.119.0\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1' -ArgumentList #{ NonInteractive = $true } -ErrorAction Stop ; $VerbosePreference = 'SilentlyContinue' ; $DebugPreference = 'SilentlyContinue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create('. ''\\hidden-unc-path\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.119.0\VSBuild.ps1'''))"'.
2017-11-15T13:16:10.9989971Z ##[section]Finishing: Build solution
Looks like your PowerShell execution mode is set to require signed scripts to execute. The agent requires local unsigned scripts to run:
From an admin PowerShell console, run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
- scope LocalMachine
Then restart the agent.

Running PowerShell script for Exchange 2010 remotely using WMIC

In general I'm trying to create mailbox on Exchange Server 2010 remotely using wmic. I have a following environment setup:
Systems are not in the same domain.
System 1 (from where I execute): running Windows 7 x64 System 2 (target system with Exchange on board): running Windows Server 2008 R2. There I have PowerShell script called addmailbox.ps1:
$secure_pwsd = convertto-securestring TESTPASSWORD -asplaintext -force
New-Mailbox -UserPrincipalName TESTMAILBOX#MYDOMAIN.com -Alias SOMEALIAS -Name SOMENAME -OrganizationalUnit Users -Password $secure_pwsd -FirstName SOMEFIRSTNAME -LastName SOMELASTNAME -DisplayName "LASTNAME FIRSTNAME" -ResetPasswordOnNextLogon $false
exit
If I run the script locally from System 2 it works fine, mailbox created as expected, so I tried to run it remotely from System 1 like this
wmic /node:IP /user:DOMAIN\Administrator /password:PASS process call create 'powershell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; C:\scripts\addmailbox.ps1"'
WMIC reported that the remote process created successfully. On System 2 in task manager I can see that the process is running and child PowerShell process also spawned, but both processes are not completed. I suppose PowerShell wait for user input or something. To test, I added the key "-noninteractive" to executing command and catch the following errors
VERBOSE: Connecting to HOSTNAME
[HOSTNAME] Connecting to remote server failed with the following error message : A specified logon session does
not exist. It may already have been terminated. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportExc
eption
+ FullyQualifiedErrorId : PSSessionOpenFailed
Failed to connect to any Exchange Server in the current site.
Read-Host : Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
At C:\Program Files\Microsoft\Exchange Server\V14\bin\ConnectFunctions.ps1:47 char:18
+ $fqdn=read-host <<<< -prompt "Please enter the Server FQDN where you want to connect"
+ CategoryInfo : InvalidOperation: (:) [Read-Host], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ReadHostCommand
VERBOSE: Connecting to
New-PSSession : Cannot bind parameter 'ConnectionUri'. Cannot convert value "http:///powershell?serializationLevel=Full
" to type "System.Uri". Error: "Invalid URI: The hostname could not be parsed."
At C:\Program Files\Microsoft\Exchange Server\V14\bin\ConnectFunctions.ps1:229 char:43
+ $session = new-pssession -connectionURI <<<< "http://$fqdn/powershell?serializationLevel=Full" -ConfigurationName Microsoft.Exchange -SessionOption $so #-erroraction silentlycontinue
+ CategoryInfo : InvalidArgument: (:) [New-PSSession], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.NewPSSessionCommand
The term 'New-Mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\scripts\addmailbox.ps1:3 char:12
+ New-Mailbox <<<< -UserPrincipalName TESTMAILBOX#MYDOMAIN.com -Alias SOMEALIAS -Name SOMENAME -OrganizationalUnit Users -Password $secure_pwsd -FirstName SOMEFIRSTNAME -LastName SOMELASTNAME -DisplayName "LASTNAME FIRSTNAME" -ResetPasswordOnNextLogon $false
+ CategoryInfo : ObjectNotFound: (New-Mailbox:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I repeat that these commands work fine locally on System 2. Direct specification of the FDQN in PS script file doesn't solve the problem. Please, do not suggest to use PsExec instead of WMIC or establish remote connection using PowerShells. Thanks for the advices!

Resources