SOLVED

MSgraph signinactivity

%3CLINGO-SUB%20id%3D%22lingo-sub-2714122%22%20slang%3D%22en-US%22%3EMSgraph%20signinactivity%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2714122%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20all%3C%2FP%3E%3CP%3EIm%20trying%20to%20get%20the%20%22%3CSPAN%3ElastSignInDateTime%22%20for%20a%20particular%20user%20using%20powershell.%20The%20below%20query%20works%20fine%20if%20i%20go%20to%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fgraph-explorer%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EGraph%20Explorer%20-%20Microsoft%20Graph%3C%2FA%3E%26nbsp%3B%20I%20have%20already%20setup%20the%20delegation%2C%20just%20need%20to%20understand%20how%20to%20do%20the%20same%20thing%20in%20powershell%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CA%20title%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fusers%3F%24filter%3Duserprincipalname%2Beq%2B%2527user.name%40domain.com%2527%26amp%3B%24select%3Ddisplayname%2Csigninactivity%22%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fusers%3F%24filter%3DuserPrincipalName%2Beq%2B%2527user.name%40domain.com%2527%26amp%3B%24select%3DdisplayName%2CsignInActivity%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fusers%3F%24filter%3DuserPrincipalName%2Beq%2B'user.name%40domain.com'%26amp%3B%24select%3DdisplayName%2CsignInActivity%3C%2FA%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2714122%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2715781%22%20slang%3D%22en-US%22%3ERe%3A%20MSgraph%20signinactivity%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2715781%22%20slang%3D%22en-US%22%3EI%20gave%20you%20a%20working%20example%20in%20the%20article%2Fscript%20I%20linked%20to%20in%20your%20other%20post...%3CBR%20%2F%3EAll%20you%20need%20to%20do%20is%20authenticate%2C%20then%20issue%20the%20request.%20If%20using%20filters%20and%20such%2C%20make%20sure%20to%20'escape'%20the%20%24%20character.%3C%2FLINGO-BODY%3E
Frequent Contributor

Hello all

Im trying to get the "lastSignInDateTime" for a particular user using powershell. The below query works fine if i go to Graph Explorer - Microsoft Graph  I have already setup the delegation, just need to understand how to do the same thing in powershell 

 

3 Replies
I gave you a working example in the article/script I linked to in your other post...
All you need to do is authenticate, then issue the request. If using filters and such, make sure to 'escape' the $ character.
best response confirmed by Skipster311-1 (Frequent Contributor)
Solution
I suppose using the Microsoft.Graph module might be the easiest option, if it supports what you need. You can switch to the beta profile using the Select-MgProfile cmdlet and then you do not have to worry about trying to do it manually.
Installing the graph powershell module was much easier.