Docker for windows failing to start - powershell

I've just upgraded to the Windows 10 Pro creators update | 1703 | OS Build: 15063.138.
When docker tries to start I get the following error:
Unable to create: You cannot call a method on a null-valued expression.
at <ScriptBlock>, <No file>: line 137
at Get-NetAdapter<End>, <No file>: line 181
at New-Switch, <No file>: line 137
at <ScriptBlock>, <No file>: line 381
at Docker.Backend.HyperV.RunScript(String action, Dictionary`2 parameters)
at Docker.Backend.ContainerEngine.Linux.Start(Settings settings)
at Docker.Core.Pipe.NamedPipeServer.<>c__DisplayClass8_0.<Register>b__0(Object[] parameters)
at Docker.Core.Pipe.NamedPipeServer.RunAction(String action, Object[] parameters)
Now I've tried all the usual troubleshooting methods to try to fix it but have had no luck i.e. uninstall docker reninstall, turn off hyper-V then turn it back on again.
I've even tried running the following commands using Powershell in C:\Program Files\Docker\Docker\resources
.\MobyLinux.ps1 -Destroy
.\MobyLinux.ps1 -Create
The create task throws the following error:
? : You cannot call a method on a null-valued expression.
At C:\Program Files\Docker\Docker\resources\MobyLinux.ps1:137 char:37
+ ... Get-NetAdapter | ? { $_.Name.StartsWith("vEthernet ($SwitchName)") }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Where-Object], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull,Microsoft.PowerShell.Commands.WhereObjectCommand
Any ideas how to fix this?

For anyone experiencing the same what i did to fix it was.
Uninstall Docker and Remove Hyper-V from the control panel. Go into
device manager -> network adapters.
Right click and uninstall any that are not your actual physical network card
Reboot and Turn Hyper-V back on and reinstall Docker (Or just install Docker as it turns on Hyper-V for you).

Related

Azure Pipelines Command Line Task: "Cannot bind argument to parameter 'LiteralPath' because it is an empty string"

I have pipeline agents installed on multiple machines and each one has a .env file, since each one has slightly different local values for the environment vars.
One of them is not working, however. The agent was installed and configured the same way on every machine.
In my pipeline I have a command line task that works in the $(Build.Repository.LocalPath) folder. When it runs the command mvn clean install -DskipTests=true, I get the error thrown in the title about an empty string. In the file, I've made sure that M2_HOME is pointing to the maven directory and that Java and Maven are added to "Path". The formatting looks like this, and it is the same format for every .env file on all the machines. Any clues?
JAVA_HOME=C:\\softwarebuild\\soft\\java\\jdk-11.0.2
M2_HOME=C:\\Users\\[redacted]\\.m2\\wrapper\\dists\\apache-maven-3.6.0-bin\\3rgjh30jneo7541hun7uggltkb\\apache-maven-3.6.0
Path=JAVA_HOME;M2_HOME\\bin
EDIT: I ran with system diagnostics turned on. Is it telling me it can't find cmd.exe? The first line of "cmdline.ps1" is just [CmdletBinding()]:
2022-01-24T18:20:55.0366255Z Script contents:
2022-01-24T18:20:55.0380447Z mvn clean install -DskipTests=true
2022-01-24T18:20:55.0643303Z ##[debug]AGENT_VERSION: '2.196.2'
2022-01-24T18:20:55.0803490Z ##[debug]AGENT_TEMPDIRECTORY:
'C:\agents\_work\_temp'
2022-01-24T18:20:55.0844911Z ##[debug]Asserting container path exists:
'C:\agents\_work\_temp'
2022-01-24T18:20:55.1197587Z ##[debug]Leaving
C:\agents\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d-
86655b4d2ce9\2.198.0\cmdline.ps1.
2022-01-24T18:20:55.1295729Z ##[debug]Caught exception from task script.
2022-01-24T18:20:55.1356782Z ##[debug]Error record:
2022-01-24T18:20:55.2573018Z ##
[debug]C:\agents\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d-
86655b4d2ce9\2.198.0\cmdline.ps1 : Cannot bind argument to parameter
'LiteralPath' because it is an empty string.
2022-01-24T18:20:55.2589074Z ##[debug]At line:1 char:1
2022-01-24T18:20:55.2616630Z ##[debug]+ .
'C:\agents\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce ...
2022-01-24T18:20:55.2641009Z ##[debug]+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-01-24T18:20:55.2664818Z ##[debug] + CategoryInfo :
InvalidData: (:) [cmdline.ps1], ParameterBindingValidationException
2022-01-24T18:20:55.2688247Z ##[debug] + FullyQualifiedErrorId :
ParameterArgumentValidationErrorEmptyStringNotAllowed,cmdline.ps1
2022-01-24T18:20:55.2711281Z ##[debug]
2022-01-24T18:20:55.2751043Z ##[debug]Script stack trace:
2022-01-24T18:20:55.2827845Z ##[debug]at <ScriptBlock>,
C:\agents\_work\_tasks\CmdLine_d9bafed4-0b18-4f58-968d-
86655b4d2ce9\2.198.0\cmdline.ps1: line 42
2022-01-24T18:20:55.2852703Z ##[debug]at <ScriptBlock>, <No file>: line
1
2022-01-24T18:20:55.2878438Z ##[debug]at <ScriptBlock>, <No file>: line
22
2022-01-24T18:20:55.2903959Z ##[debug]at <ScriptBlock>, <No file>: line
18
2022-01-24T18:20:55.2932146Z ##[debug]at <ScriptBlock>, <No file>: line
1
2022-01-24T18:20:55.2974680Z ##[debug]Exception:
2022-01-24T18:20:55.3223441Z ##
[debug]System.Management.Automation.ParameterBindingValidationException:
Cannot bind argument to parameter 'LiteralPath' because it is an empty
string.
I was missing an evironment variable called "ComSpec". The script was expecting to find that variable, with the value of the path pointing to cmd.exe.

Azure file copy to blob failing

Trying the Azure file copy for the first time so not sure where I'm going wrong as it keeps failing with the details seen further below. It does create the 'Test' container though.
Also tried by changing the task version to 2 and 3. Same result
Any suggestions where to start looking?
Copied from 'View Yaml'
steps:
- task: AzureFileCopy#4
displayName: 'AzureBlob File Copy'
inputs:
SourcePath: '$(System.DefaultWorkingDirectory)/interace/interface brands/v20.08'
azureSubscription: Development
Destination: AzureBlob
storage: updates
ContainerName: Test
Log output:
2020-08-20T12:51:39.0807389Z INFO: AzCopy.exe: A newer version 10.6.0 is available to download
2020-08-20T12:51:39.0810239Z
2020-08-20T12:51:39.0923021Z ##[debug]Trying to disconnect from Azure and clear context at process scope
2020-08-20T12:51:39.0975253Z ##[debug]Cannot verify the Microsoft .NET Framework version 4.7.2 because it is not included in the list of permitted versions.
2020-08-20T12:51:39.0997871Z ##[debug]Populating RepositorySourceLocation property for module Az.Accounts.
2020-08-20T12:51:39.1022385Z ##[debug]Loading module from path 'C:\Modules\az_3.1.0\Az.Accounts\1.9.2\Az.Accounts.psm1'.
2020-08-20T12:51:39.1250145Z ##[command]Disconnect-AzAccount -Scope Process -ErrorAction Stop
2020-08-20T12:51:39.5095303Z ##[command]Clear-AzContext -Scope Process -ErrorAction Stop
2020-08-20T12:51:40.0741695Z ##[debug]Caught exception from task script.
2020-08-20T12:51:40.0773655Z ##[debug]Error record:
2020-08-20T12:51:40.1256747Z ##[debug]Upload to container: 'test' in storage account: 'updates' with blob prefix: '' failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' For more info please refer to https://aka.ms/azurefilecopyreadme
2020-08-20T12:51:40.1267682Z ##[debug]At D:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\4.171.3\Utility.ps1:109 char:5
2020-08-20T12:51:40.1278911Z ##[debug]+ throw "$errorMessage $helpMessage"
2020-08-20T12:51:40.1290483Z ##[debug]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-08-20T12:51:40.1301825Z ##[debug] + CategoryInfo : OperationStopped: (Upload to conta...efilecopyreadme:String) [], RuntimeException
2020-08-20T12:51:40.1313423Z ##[debug] + FullyQualifiedErrorId : Upload to container: 'test' in storage account: 'updates' with blob prefix: '' fa iled with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' For more info please refer to https://aka.ms/azurefilecopyreadme
2020-08-20T12:51:40.1323723Z ##[debug]
2020-08-20T12:51:40.1343144Z ##[debug]Script stack trace:
2020-08-20T12:51:40.1387327Z ##[debug]at ThrowError, D:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\4.171.3\Utility.ps1: line 109
2020-08-20T12:51:40.1399427Z ##[debug]at Upload-FilesToAzureContainer, D:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\4.171.3\Utility.ps1: line 248
2020-08-20T12:51:40.1410626Z ##[debug]at <ScriptBlock>, D:\a\_tasks\AzureFileCopy_eb72cb01-a7e5-427b-a8a1-1b31ccac8a43\4.171.3\AzureFileCopy.ps1: line 181
2020-08-20T12:51:40.1421592Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-08-20T12:51:40.1433593Z ##[debug]at <ScriptBlock>, <No file>: line 22
2020-08-20T12:51:40.1445293Z ##[debug]at <ScriptBlock>, <No file>: line 18
2020-08-20T12:51:40.1456696Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-08-20T12:51:40.1475711Z ##[debug]Exception:
2020-08-20T12:51:40.1517637Z ##[debug]System.Management.Automation.RuntimeException: Upload to container: 'test' in storage account: 'updates' with blob prefix: '' failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' For more info please refer to https://aka.ms/azurefilecopyreadme
2020-08-20T12:51:40.1704018Z ##[error]Upload to container: 'test' in storage account: 'updates' with blob prefix: '' failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' For more info please refer to https://aka.ms/azurefilecopyreadme
2020-08-20T12:51:40.1706605Z ##[debug]Processed: ##vso[task.logissue type=error]Upload to container: 'test' in storage account: 'updates' with blob prefix: '' failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.' For more info please refer to https://aka.ms/azurefilecopyreadme
2020-08-20T12:51:40.1726755Z ##[debug]Processed: ##vso[task.complete result=Failed]
2020-08-20T12:51:40.2315295Z ##[section]Finishing: AzureBlob File Copy
Azure file copy to blob failing
Since you tested the task version to 2 and 3 and got the same error, I guess there might be something wrong with authentication error from Azure instead of the task itsself.
We need to make sure the Service Principal we use in this task have access to the Storage Account. You could try to navigate to Storage accounts
-> Access control page and Add a role assignment(Storage Blob Data Contributor/owner role) to my Service Principal/Managed Identity:
Besides, check also your Service Connection in your Azure DevOps Project Settings for identifying that you are using the correct Resource Group.
You could check this thread for some more details.

TFS: Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information."

I have a release definition in TFS with 2 tasks. One of them passes perfectly, while the other throws an exception, though both have very smimlar configuration.
The successful task configuration:
CopyFile Task
Source: $(System.DefaultWorkingDirectory)/XXX Build Definition/drop
Machines $(WebServers)
Admin Login: server\user
Password: Password
Protocol: HTTP
Destination Folder: C:\DestFolder
Variables: WebServers: MyServer
The failing task configuration:
RunPowerShellOnRemoteComputer Task
Machines $(WebServers)
Admin Login: server\user
Password: Password
Protocol: HTTP
PowerShell Script: C:\...\script.ps1
Variables: WebServers: MyServer
When running the second task I receive this exception:
Exception calling "SetRight" with "2" argument(s): "Could not obtain
the user information." CategoryInfo :NotSpecified: (:) [],
MethodInvocationException FullyQualifiedErrorId :Exception --->
System.Management.Automation.RemoteException: Exception calling
"SetRight" with "2" argument(s): "Could not obtain the user
information."
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.PowershellExecutor.Invoke(String
errorContextMessage, Boolean writeResultToLog, Boolean isCancellable)
at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.RemoteDeploymentHelper.InstallServiceInternal(String
serviceSourcePath, String serviceName, String destinationFileName)
at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.RemoteDeploymentHelper.InstallService(String
serviceSourcePath, String serviceName, String destinationFileName)
at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.DeploymentClient.d__24.MoveNext()
---> (Inner Exception #0) System.Management.Automation.RemoteException: Exception calling
"SetRight" with "2" argument(s): "Could not obtain the user
information."<---
Deployment status for machine 'bgsovswops.eu.hpecorp.net:5985' : 'Failed' ##[error], MethodInvocationException\r\n
FullyQualifiedErrorId :Exception\r\n"}};]
##[error]System.Management.Automation.RuntimeException: Failed to install
'VisualStudioRemoteDeployer3e199746-ae71-4ba0-a2ef-f5ce8f25a631' from
service executable path VisualStudioRemoteDeployer.exe . Consult the
logs below: Exception calling "SetRight" with "2" argument(s): "Could
not obtain the user information." CategoryInfo :NotSpecified: (:)
[], MethodInvocationException FullyQualifiedErrorId :Exception
---> System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployer3e199746-ae71-4ba0-a2ef-f5ce8f25a631' from
service executable path VisualStudioRemoteDeployer.exe . Consult the
logs below: Exception calling "SetRight" with "2" argument(s): "Could
not obtain the user information." CategoryInfo :NotSpecified: (:)
[], MethodInvocationException FullyQualifiedErrorId :Exception
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable
input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace
rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace
rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1
input, PSDataCollection1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1
input, PSDataCollection1 output, PSInvocationSettings settings)
at Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[]
args)
When I go to the remote machine, I succesfully execute the 'Invoke-Expression' on the C:...\script.ps1.
Also, I successfully connect from the local machines' powerscript console to the remote machine.
Any suggestions appreciated.
Please include the domain in the username variable. If it’s not domain environment, it should be the machine name.
So, just try to update the UPN user name format to DOMAIN\Username or MACHINENAME\Username format.
Check NetLogon Windows Service
The target server that I was deploying to reported this error. I already had the username for the PowerShell on Target Machines task set to use full DOMAIN\Username, per Andy's answer.
It turned out that the machine's NetLogon service had not started properly when the machine booted, due to it running on an abnormally busy VSphere cluster.
A reboot of the machine ensured that the NetLogon Windows Service, and its dependent services were all started, following which a redeploy succeeded.

Jenkins Build successful even after PS script failed to execute

I am executing Jenkins Job which Builds my .csproj file and execute few PS scripts.
Issue is I get a successful email even if my PS script fails,How should I tell my Jenkins Job to trigger me an email also if PS script is failing.
Error Logs-
Copy-Item : The process cannot access the file
'\\10.0.1.190\d$\Build\RPC\abcde.RPC.AirSearch\Common.Logging.Core.dll' because it is being used by another process.
At C:\Users\Administrator\AppData\Local\Temp\hudson9059014122834846757.ps1:3 char:1
+ Copy-Item "C:\AirSearchBnd\src\abcde.Air.Search.RPC.Host\bin\Release\*" "\\$en ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
[AirSearchBnd] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\ADMINI~1\AppData\Local\Temp\hudson9149103993066004448.ps1'"
[SC] CreateService SUCCESS
SERVICE_NAME: AirSearchWindowsService
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 13784
FLAGS :
> C:\Program Files (x86)\Git\bin\git.exe tag -l RPCBUILD_6 # timeout=10
> C:\Program Files (x86)\Git\bin\git.exe tag -a -f -m Jenkins Git plugin tagging with RPCBUILD_6 RPCBUILD_6 # timeout=10
Pushing tag RPCBUILD_6 to repo Dev
> C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> C:\Program Files (x86)\Git\bin\git.exe push https://github.com/abcdeHoldings/abcde.Services.Air.Search.git RPCBUILD_6
Email was triggered for: Always
Sending email for trigger: Always
Request made to compress build log
Sending email to: abcde#software.com abcde#software.com abcde#software.com abcde#software.com
Finished: SUCCESS
The easiest way is to configure Jenkins to send e-mails on failed builds and in the Powershell step add the following at the end:
if ($error) { exit 1 }
The problem with Jenkins Powershell plugin is that it doesn't honor the errors that happen in Powershell, only the exit code of the shell itself, this will force build to fail and trigger the email.
There is an option of "Attaching Build Log". You can read the build log to see, if the ps script has failed.

Running tests with tcm.exe results in Field not found: 'Microsoft.TeamFoundation.TestManagement.Common.WitCategoryRefName.SharedDataSet'

I'm trying to run an automated test case in Microsoft Test Manager from the command line with the following command:
TCM.exe run /create /title:"Nightly Run" /planid:5554 /suiteid:6582 /configid:97 /collection:XXX /teamproject:XXX /include /builddir:'C:\Source\'
This results in the following error:
.\TCM.exe : Field not found: 'Microsoft.TeamFoundation.TestManagement.Common.WitCategoryRefName.SharedDataSet'.
At C:\Users\XXXX\Desktop\RunTest.ps1:2 char:1
+ .\TCM.exe run /create /title:"Nightly Run" /planid:5554 /suiteid:6582 /configid: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Field not found...SharedDataSet'.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
However, this error happens on a Windows Server 2012R2 machine with Visual Studio 2013.4 installed but not on my local dev machine (Windows 10 with VS2013.4).
I know that SharedDataSets are introduced in VS2013.4 but I don't know where this error is coming from since the command doesn't give this error on my local pc.
I've found the solution. Running the following commands on the Windows Server fixed the error:
ngen uninstall Microsoft.TeamFoundation.TestManagement.Client
ngen uninstall Microsoft.TeamFoundation.TestManagement.Common