It was likely a one-off incident on my particular PC and I could invest a ton of time in trying to reproduce it or troubleshoot it - or I could accept that I found a quick and easy fix. It's one of those scenarios where the cost benefit analysis doesn't really stack up to investigate it further. What caused this error to fire? I have no idea. It didn't specifically list the above error, but it did give me the PowerShell credentials equivalent of "turn it off and back on again" - the "Clear-AzContext" command!Īfter running Clear-AzContext, I was able to re-run Connect-AzAccount and pick up a default context successfully, then run my commands. What was helpful was this Doc regarding Azure PowerShell context objects. Not at all helpful in this context (see what I did there?). No matter what permutation I used of these search terms, the limited results I did find were related to API calls or application errors. On hitting this error I did what most seasoned IT Professionals would do - I searched the internet for the phrase "failed to acquire token silently as no token was found in the cache the refresh token had expired due to inactivity". In this case, with none selected, I issued the next command "Set-AzContext" and provided the -SubscriptionID that I wanted the commands to act against, only. Usually one is picked up by default but you can use the same process to switch to a different subscription or tenant if needed. This account has access to multiple subscriptions in a single tenant, so before we start issuing commands, we need to set the context. This was a slightly tricky question, as you may not be able to tell that I haven't blacked out the SubscriptionName or TenantID for security reasons. The login process seemed to then authorize my username and password without error, but there was something strange in what was returned (see if you can spot it, below): In PowerShell, I ran the "Connect-AzAccount" command, visited the website and entered the provided (redacted) code. So what happens if you hit an error with that very first step? The first step is connecting PowerShell to your tenant and subscription with valid credentials, using the "Connect-AzAccount" command. If you call GetThreadContext for the current thread, the function returns successfully however, the context returned is not valid.PowerShell provides an effective way to run queries or actions at scale, whether that's against Azure resources, Azure Active Directory identities or Office 365 environments (including Exchange Online, SharePoint Online and Microsoft Teams). Use the SuspendThread function to suspend the thread before calling GetThreadContext. You cannot get a valid context for a running thread. The thread identified by the hThread parameter is typically being debugged, but the function can also operate when the thread is not being debugged. The function retrieves a selective context based on the value of the ContextFlags member of the context structure. This function is used to retrieve the thread context of the specified thread. To get extended error information, call GetLastError. If the function fails, the return value is zero. If the function succeeds, the return value is nonzero. Refer to the WinNT.h header file for processor-specific definitions of this structures and any alignment requirements. The CONTEXT structure is highly processor specific. The value of the ContextFlags member of this structure specifies which portions of a thread's context are retrieved. Windows XP or Windows Server 2003: The handle must also have THREAD_QUERY_INFORMATION access.Ī pointer to a CONTEXT structure (such as ARM64_NT_CONTEXT) that receives the appropriate context of the specified thread. For more information, see Thread Security and Access Rights. The handle must have THREAD_GET_CONTEXT access to the thread. Syntax BOOL GetThreadContext(Ī handle to the thread whose context is to be retrieved. Retrieves the context of the specified thread.Ī 64-bit application can retrieve the context of a WOW64 thread using the Wow64GetThreadContext.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |