I am trying to use the Invoke-DscResource cmdlet in a series of tests (using Pester) to see if a configuration has been successfully applied to a VM.
This works 9/10 times, but sometimes the following error is thrown:
==> azure-arm.dsc_node: Cannot invoke the Invoke-DscResource cmdlet. The Consistency Check or Pull cmdlet is in progress and must return
==> azure-arm.dsc_node: before Invoke-DscResource can be invoked. Use -Force option if that is available to cancel the current operation.
==> azure-arm.dsc_node: + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
==> azure-arm.dsc_node: + FullyQualifiedErrorId : MI RESULT 1
==> azure-arm.dsc_node: + PSComputerName : localhost
Is there a way to force the Invoke-DscResource cmdlet?
The problem is that Desired State Configuration cannot run at the same time as another process is changing the configuration of the machine.
I would guess that you are running Invoke-DscResource before the process that you are testing is complete.
Try putting a pause in your test.
Related
I always have the following error when I install a virtual machine
launch failed: Failed to resize instance image - error executing powershell command. Detail: Resize-VHD : �������������̵Ĵ�С��
ϵͳ��������C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\multipassd\vault\instances\krun\ubuntu-20.04-serv
er-cloudimg-amd64.vhdx���Ĵ�С��
�������������̵Ĵ�С��
ϵͳ��������C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\multipassd\vault\instances\krun\ubuntu-20.04-serv
er-cloudimg-amd64.vhdx���Ĵ�С: ��һ����������ʹ�ô��ļ������������ʡ� (0x80070020)��
����λ�� ��:1 �ַ�: 1
Resize-VHD -Path C:/WINDOWS/system32/config/systemprofile/AppData/Roa ...
+ CategoryInfo : ResourceBusy: (:) [Resize-VHD], VirtualizationException
+ FullyQualifiedErrorId : ObjectInUse,Microsoft.Vhd.PowerShell.Cmdlets.ResizeVhd
Background
In my case, I changed the location of my multipass instance locations by following this post here. I then created a folder on my drive where I wanted the instances to be stored.
After doing so, multipass launch failed with your exact same error. After trying reboots, uninstall/reinstall multipass, etc. - I finally tried renaming the folder where I wanted to store my multipass instances, and this worked.
Apparently, if your destination multipass folder includes a space, some part of the script fails.
Workaround / Fix
When specifying a multipass instance destination:
MULTIPASS_STORAGE -Value "<path>"
Make sure there are NO SPACES in the "<path>" you have provided.
Hope this helps.
You have to add the HyperV module to powershell in "Turn Windows features on or off", if you don't check this the checkbox, "Resize-VHD" won't work and will fail the multipass launch.
The direct command is:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell
When I run simple powershell with only ls command in it through Azure pipeline self-hosted agent I see error:
An error occurred while creating the pipeline.
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RuntimeException
The same script runs fine locally in the same folder on the same machine (when no Azure agent is involved). The pipeline has not been changed in months.
The execution policy is set to "Unrestricted".
There is no difference whether the agent is run with admin permissions.
I checked and the files in the folders of the agent do not look blocked or read-only.
We run tests through powershell scripts and they started to fail last week, without any obvious reason. The only thing that I have installed on the same machine, is Visual Studio 2022 Preview 5, but I have restarted the machine immediately after the installation has passed successfully and the next day the tests have passed.
I had a look through similar errors here, in stackoverflow, but they were not useful, including this one PowerShell "an error occurred while creating the pipeline" #Requires -Version 3.0
Do you have an idea what can cause this?
The PowerShell scripts started passing when I changed the Azure Powershell pipeline task version from 1* to 2* (the latest available for our pipelines).
I do not know why this fixed the issue, as I think the difference between these 2 version is that version 2* can be executed on agents that have operating system that is not Windows.
I'm trying to start a nested VM on Windows2016 VM deployed on azure ( Size used allows Nested Virtualization ) and after all guides followed I'm not sure what i could be missing since i Do have Hyper V installed:
Role manager:
Services:
Error when i try to start the VM:
Start-VM : 'sfm-azure-01' failed to start.
Failed to start the virtual machine 'sfm-azure-01' because one of the Hyper-V components is not running.
'sfm-azure-01' failed to start. (Virtual machine ID BA61E565-9B2B-4180-B79D-FD3F16882314)
The Virtual Machine Management Service failed to start the virtual machine 'sfm-azure-01' because one of the Hyper-V components is
not running (Virtual machine ID BA61E565-9B2B-4180-B79D-FD3F16882314).
At line:1 char:1
+ Start-VM -Name sfm-azure-01
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-VM], VirtualizationException
+ FullyQualifiedErrorId : OperationFailed,Microsoft.HyperV.PowerShell.Commands.StartVM
References used: https://learn.microsoft.com/azure/virtual-machines/windows/nested-virtualization
Did you try this script for enabling nest virtualisation.
It looks like it checks all the prerequisites.
https://github.com/charlieding/Virtualization-Documentation/tree/live/hyperv-tools/Nested
I have a Service Fabric standalone cluster where I can connect to it with Connect-ServiceFabricCluster just fine, but whenever I run other commands such as Start-ServiceFabricClusterConfigurationUpgrade, it keeps timing out. I've tried running commands with longer timeouts (as long as 10 min) with the same results. Any ideas what I might be doing wrong?
This works..
PS C:\WINDOWS\system32> Connect-ServiceFabricCluster -ConnectionEndpoint "localhost:19000"
True
ConnectionEndpoint : {localhost:19000}
...
But these commands time out...
PS C:\WINDOWS\system32> Get-ServiceFabricClusterConfiguration -TimeoutSec 300
Get-ServiceFabricClusterConfiguration : Operation timed out.
At line:1 char:1
+ Get-ServiceFabricClusterConfiguration -TimeoutSec 300
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationTimeout: (Microsoft.Servi...usterConnection:ClusterConnection) [Get-ServiceFabr
icClusterConfiguration], TimeoutException
+ FullyQualifiedErrorId : GetClusterConfigurationErrorId,Microsoft.ServiceFabric.Powershell.GetClusterConfiguratio
n
Start-ServiceFabricClusterConfigurationUpgrade -ClusterConfigPath ClusterConfig.Unsecure.DevCluster.v2.json
Start-ServiceFabricClusterConfigurationUpgrade : Operation timed out.
At line:1 char:1
+ Start-ServiceFabricClusterConfigurationUpgrade -ClusterConfigPath Clu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationTimeout: (Microsoft.Servi...usterConnection:ClusterConnection) [Start-ServiceFa
...gurationUpgrade], TimeoutException
+ FullyQualifiedErrorId : StartClusterConfigurationUpgradeErrorId,Microsoft.ServiceFabric.Powershell.StartClusterC
onfigurationUpgrade
I believe this a single node dev cluster? If so, it can't be upgraded and needs to be recreated instead.
You can upgrade your cluster to the new version only if you're using a
production-style node configuration, where each Service Fabric node is
allocated on a separate physical or virtual machine. If you have a
development cluster, where more than one Service Fabric node is on a
single physical or virtual machine, you must re-create the cluster
with the new version.
To fix:
Create backups for all desired service partitions.
Update the client tooling using the web platform installer.
Remove the old cluster and recreate it using the Local Cluster Manager tool (in the tray, if on Windows).
Redeploy applications.
Restore service backups.
I'm trying to launch a BITS service download in a GPO Startup Script. Startup Scripts are started as the local SYSTEM account, which works well for background downloads as per Microsoft's documentation https://msdn.microsoft.com/en-us/library/windows/desktop/aa363152(v=vs.85).aspx
Sadly when I try to start a download (disregarding valid source or destination) I get the following error:
Start-BitsTransfer : The operation being requested was not performed because
the user has not logged on to the network. The specified service does not
exist. (Exception from HRESULT: 0x800704DD)
At line:1 char:1
+ Start-BitsTransfer -Source localhost -Destination c:\temp
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand
This is just a test, the actual BITS transfer is started within a c# application that is launched within the GPO Startup Script. Further tests with a manually created process through Sysinternals PSExec yield the same error.
Additional checks for security principals in whoami /all look fine:
User Name SID
=================== ========
nt authority\system S-1-5-18
GROUP INFORMATION
-----------------
...
CONSOLE LOGON Well-known group S-1-2-1
...
LOCAL Well-known group S-1-2-0
BUILTIN\Administrators Alias S-1-5-32-544
I checked for services BITS and SENS - all running.
To summarize:
How can i successfully launch a BITS download as SYSTEM in Startup Script?
How does the error "user has not logged on to the network" make sense, considering System account is always logged on? What is the meaning of "The specified service does not exist." - what service?